feat(events): refactor event and participant list entries to use schema validation
This commit is contained in:
parent
4a4d3b73d6
commit
8bbb7e4c85
6 changed files with 28 additions and 44 deletions
|
@ -3,26 +3,24 @@ import Image from 'next/image';
|
|||
import { user_default_dark } from '@/assets/usericon/default/defaultusericon-export';
|
||||
import { user_default_light } from '@/assets/usericon/default/defaultusericon-export';
|
||||
import { useTheme } from 'next-themes';
|
||||
import zod from 'zod/v4';
|
||||
import { ParticipantSchema } from '@/app/api/event/[eventID]/participant/validation';
|
||||
|
||||
type ParticipantListEntryProps = {
|
||||
participant: string;
|
||||
imageSrc?: string | null;
|
||||
};
|
||||
type ParticipantListEntryProps = zod.output<typeof ParticipantSchema>;
|
||||
|
||||
export default function ParticipantListEntry({
|
||||
participant,
|
||||
imageSrc,
|
||||
user,
|
||||
}: ParticipantListEntryProps) {
|
||||
const { resolvedTheme } = useTheme();
|
||||
const defaultImage =
|
||||
resolvedTheme === 'dark' ? user_default_dark : user_default_light;
|
||||
|
||||
const finalImageSrc = imageSrc ?? defaultImage;
|
||||
const finalImageSrc = user.image ?? defaultImage;
|
||||
|
||||
return (
|
||||
<div className='flex items-center gap-2 py-1 ml-5'>
|
||||
<Image src={finalImageSrc} alt='Avatar' width={30} height={30} />
|
||||
<span>{participant}</span>
|
||||
<span>{user.name}</span>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue