fixed event participant

This commit is contained in:
PxlLoewe
2025-03-07 15:43:49 -07:00
parent 6fc20a66ef
commit 77b266e0bf
3 changed files with 21 additions and 17 deletions

View File

@@ -5,13 +5,16 @@ export const handleParticipantFinished = async (
participant: Participant, participant: Participant,
user: User, user: User,
) => { ) => {
const discordID = prisma.discordAccount.findFirst({ const discordID = await prisma.discordAccount.findFirst({
where: { where: {
userId: user.id, userId: user.id,
}, },
}); });
prisma.user.update({ //TODO: Send Discord Message
//TODO: Send Email
await prisma.user.update({
where: { where: {
id: user.id, id: user.id,
}, },
@@ -23,7 +26,7 @@ export const handleParticipantFinished = async (
}, },
}); });
prisma.participant.update({ await prisma.participant.update({
where: { where: {
id: participant.id, id: participant.id,
}, },

View File

@@ -7,7 +7,7 @@ import {
ParticipantOptionalDefaultsSchema, ParticipantOptionalDefaultsSchema,
} from "@repo/db/zod"; } from "@repo/db/zod";
import { useSession } from "next-auth/react"; import { useSession } from "next-auth/react";
import { Controller, useForm } from "react-hook-form"; import { Controller, useForm, UseFormReturn } from "react-hook-form";
import { deleteAppoinement, upsertAppointment } from "../action"; import { deleteAppoinement, upsertAppointment } from "../action";
import { Button } from "../../../../_components/ui/Button"; import { Button } from "../../../../_components/ui/Button";
import { import {
@@ -23,21 +23,21 @@ interface AppointmentModalProps {
event?: Event; event?: Event;
ref: RefObject<HTMLDialogElement | null>; ref: RefObject<HTMLDialogElement | null>;
appointmentsTableRef: React.RefObject<PaginatedTableRef>; appointmentsTableRef: React.RefObject<PaginatedTableRef>;
appointmentForm: UseFormReturn<
EventAppointmentOptionalDefaults,
any,
undefined
>;
} }
export const AppointmentModal = ({ export const AppointmentModal = ({
event, event,
ref, ref,
appointmentsTableRef, appointmentsTableRef,
appointmentForm,
}: AppointmentModalProps) => { }: AppointmentModalProps) => {
const { data: session } = useSession(); const { data: session } = useSession();
const appointmentForm = useForm<EventAppointmentOptionalDefaults>({
resolver: zodResolver(EventAppointmentOptionalDefaultsSchema),
defaultValues: {
eventId: event?.id,
presenterId: session?.user?.id,
},
});
const participantTableRef = useRef<PaginatedTableRef>(null); const participantTableRef = useRef<PaginatedTableRef>(null);
const participantForm = useForm<Participant>({ const participantForm = useForm<Participant>({
resolver: zodResolver(ParticipantOptionalDefaultsSchema), resolver: zodResolver(ParticipantOptionalDefaultsSchema),
@@ -129,7 +129,7 @@ export const AppointmentModal = ({
}} }}
include={{ User: true }} include={{ User: true }}
leftOfPagination={ leftOfPagination={
<div className="space-x-1"> <div className="flex gap-2">
<Button type="submit" className="btn btn-primary"> <Button type="submit" className="btn btn-primary">
Speichern Speichern
</Button> </Button>
@@ -187,7 +187,10 @@ export const AppointmentModal = ({
<h3 className="text-xl">Verlauf</h3> <h3 className="text-xl">Verlauf</h3>
{participantForm.watch("statusLog").map((s) => { {participantForm.watch("statusLog").map((s) => {
return ( return (
<div className="flex justify-between"> <div
className="flex justify-between"
key={(s as any).timestamp}
>
<p>{(s as any).event}</p> <p>{(s as any).event}</p>
<p>{new Date((s as any).timestamp).toLocaleString()}</p> <p>{new Date((s as any).timestamp).toLocaleString()}</p>
</div> </div>

View File

@@ -54,16 +54,14 @@ export const Form = ({ event }: { event?: Event }) => {
}, },
}); });
const appointmentsTableRef = useRef<PaginatedTableRef>(null); const appointmentsTableRef = useRef<PaginatedTableRef>(null);
const participantTableRef = useRef<PaginatedTableRef>(null);
const [loading, setLoading] = useState(false); const [loading, setLoading] = useState(false);
const [deleteLoading, setDeleteLoading] = useState(false); const [deleteLoading, setDeleteLoading] = useState(false);
const appointmentModal = useRef<HTMLDialogElement>(null); const appointmentModal = useRef<HTMLDialogElement>(null);
const participantForm = useForm<Participant>({
resolver: zodResolver(ParticipantOptionalDefaultsSchema),
});
return ( return (
<> <>
<AppointmentModal <AppointmentModal
appointmentForm={appointmentForm}
ref={appointmentModal} ref={appointmentModal}
appointmentsTableRef={appointmentsTableRef} appointmentsTableRef={appointmentsTableRef}
/> />