fixed event participant
This commit is contained in:
@@ -5,13 +5,16 @@ export const handleParticipantFinished = async (
|
||||
participant: Participant,
|
||||
user: User,
|
||||
) => {
|
||||
const discordID = prisma.discordAccount.findFirst({
|
||||
const discordID = await prisma.discordAccount.findFirst({
|
||||
where: {
|
||||
userId: user.id,
|
||||
},
|
||||
});
|
||||
|
||||
prisma.user.update({
|
||||
//TODO: Send Discord Message
|
||||
//TODO: Send Email
|
||||
|
||||
await prisma.user.update({
|
||||
where: {
|
||||
id: user.id,
|
||||
},
|
||||
@@ -23,7 +26,7 @@ export const handleParticipantFinished = async (
|
||||
},
|
||||
});
|
||||
|
||||
prisma.participant.update({
|
||||
await prisma.participant.update({
|
||||
where: {
|
||||
id: participant.id,
|
||||
},
|
||||
|
||||
@@ -7,7 +7,7 @@ import {
|
||||
ParticipantOptionalDefaultsSchema,
|
||||
} from "@repo/db/zod";
|
||||
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 { Button } from "../../../../_components/ui/Button";
|
||||
import {
|
||||
@@ -23,21 +23,21 @@ interface AppointmentModalProps {
|
||||
event?: Event;
|
||||
ref: RefObject<HTMLDialogElement | null>;
|
||||
appointmentsTableRef: React.RefObject<PaginatedTableRef>;
|
||||
appointmentForm: UseFormReturn<
|
||||
EventAppointmentOptionalDefaults,
|
||||
any,
|
||||
undefined
|
||||
>;
|
||||
}
|
||||
|
||||
export const AppointmentModal = ({
|
||||
event,
|
||||
ref,
|
||||
appointmentsTableRef,
|
||||
appointmentForm,
|
||||
}: AppointmentModalProps) => {
|
||||
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 participantForm = useForm<Participant>({
|
||||
resolver: zodResolver(ParticipantOptionalDefaultsSchema),
|
||||
@@ -129,7 +129,7 @@ export const AppointmentModal = ({
|
||||
}}
|
||||
include={{ User: true }}
|
||||
leftOfPagination={
|
||||
<div className="space-x-1">
|
||||
<div className="flex gap-2">
|
||||
<Button type="submit" className="btn btn-primary">
|
||||
Speichern
|
||||
</Button>
|
||||
@@ -187,7 +187,10 @@ export const AppointmentModal = ({
|
||||
<h3 className="text-xl">Verlauf</h3>
|
||||
{participantForm.watch("statusLog").map((s) => {
|
||||
return (
|
||||
<div className="flex justify-between">
|
||||
<div
|
||||
className="flex justify-between"
|
||||
key={(s as any).timestamp}
|
||||
>
|
||||
<p>{(s as any).event}</p>
|
||||
<p>{new Date((s as any).timestamp).toLocaleString()}</p>
|
||||
</div>
|
||||
|
||||
@@ -54,16 +54,14 @@ export const Form = ({ event }: { event?: Event }) => {
|
||||
},
|
||||
});
|
||||
const appointmentsTableRef = useRef<PaginatedTableRef>(null);
|
||||
const participantTableRef = useRef<PaginatedTableRef>(null);
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [deleteLoading, setDeleteLoading] = useState(false);
|
||||
const appointmentModal = useRef<HTMLDialogElement>(null);
|
||||
const participantForm = useForm<Participant>({
|
||||
resolver: zodResolver(ParticipantOptionalDefaultsSchema),
|
||||
});
|
||||
|
||||
return (
|
||||
<>
|
||||
<AppointmentModal
|
||||
appointmentForm={appointmentForm}
|
||||
ref={appointmentModal}
|
||||
appointmentsTableRef={appointmentsTableRef}
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user