refactor: improve code quality
All checks were successful
Backend Check Build (NixCN CMS) TeamCity build finished
Client CMS Check Build (NixCN CMS) TeamCity build finished

Signed-off-by: Noa Virellia <noa@requiem.garden>
This commit is contained in:
2026-02-13 11:56:25 +08:00
parent 545facba22
commit d230d7474e
5 changed files with 89 additions and 67 deletions

View File

@@ -1,3 +1,4 @@
import { useMemo } from 'react';
import { useEvents } from '@/hooks/data/useEvents';
import { Button } from '../../ui/button';
import { DialogTrigger } from '../../ui/dialog';
@@ -10,30 +11,36 @@ import { EventGridView } from './event-grid.view';
export function EventGridContainer() {
const { data, isLoading } = useEvents();
const events = useMemo(() => {
return data?.pages.flatMap(page => page.data ?? []).map(toEventInfo) ?? [];
}, [data]);
return (
isLoading
? <EventGridSkeleton />
: (
<EventGridView
events={data.pages.flatMap(page => page.data ?? []).map(toEventInfo)}
footer={(eventInfo) => {
const Container = eventInfo.requireKyc ? KycDialogContainer : EventJoinDialogContainer;
<EventGridView
events={events}
footer={(eventInfo) => {
const Container = eventInfo.requireKyc ? KycDialogContainer : EventJoinDialogContainer;
return (
<Container event={eventInfo}>
{eventInfo.isJoined ? (
<Button className="w-full" disabled>
</Button>
) : (
<DialogTrigger asChild>
<Button className="w-full"></Button>
</DialogTrigger>
)}
</Container>
);
}}
/>
)
return (
<Container event={eventInfo}>
{eventInfo.isJoined
? (
<Button className="w-full" disabled>
</Button>
)
: (
<DialogTrigger asChild>
<Button className="w-full"></Button>
</DialogTrigger>
)}
</Container>
);
}}
/>
)
);
}