Fix: event

Deskripsi:
- Create event konfirmasi
This commit is contained in:
2024-12-03 10:24:37 +08:00
parent ff6ebece93
commit fc388133a6
17 changed files with 429 additions and 11 deletions

View File

@@ -0,0 +1,24 @@
"use server";
import { prisma } from "@/app/lib";
export async function event_funUpdateKehadiran({
userId,
eventId,
}: {
userId: string;
eventId: string;
}) {
const updt = await prisma.event_Peserta.updateMany({
where: {
userId: userId,
eventId: eventId,
},
data: {
isPresent: true,
},
});
if(!updt) return { status: 400, message: "Gagal Update" };
return { status: 200, message: "Anda telah terkonfirmasi" };
}

View File

@@ -0,0 +1,27 @@
"use server";
import { prisma } from "@/app/lib";
export async function event_funCheckKehadiran({
userId,
eventId,
}: {
userId: string;
eventId: string;
}) {
const checkKehadiran = await prisma.event_Peserta.findFirst({
where: {
userId: userId,
eventId: eventId,
},
select: {
isPresent: true,
},
});
if (checkKehadiran?.isPresent) {
return true;
} else {
return false;
}
}

View File

@@ -0,0 +1,24 @@
"use server";
import { prisma } from "@/app/lib";
export async function event_funCheckPesertaByUserId({
userId,
eventId,
}: {
userId: string;
eventId: string;
}) {
const check = await prisma.event_Peserta.findFirst({
where: {
userId: userId,
eventId: eventId,
},
});
if (check != null) {
return true;
} else {
return false;
}
}

View File

@@ -13,12 +13,14 @@ export async function Event_getListPesertaById(eventId: string) {
createdAt: true,
updatedAt: true,
userId: true,
isPresent: true,
User: {
select: {
Profile: true,
},
},
// Event: true,
Event: true,
eventId: true,
},
});

View File

@@ -1,5 +1,11 @@
import { event_funUpdateKehadiran } from "./edit/fun_update_konfirmasi_by_user_id";
import { event_funCheckKehadiran } from "./get/fun_check_kehadiran";
import { event_funCheckPesertaByUserId } from "./get/fun_check_peserta_by_user_id";
import { event_getAllByStatusId } from "./get/status/get_all_by_status_id";
import { event_getMasterStatus } from "./master/get_status_event";
export { event_getAllByStatusId };
export { event_getMasterStatus };
export { event_funCheckPesertaByUserId };
export { event_funUpdateKehadiran };
export { event_funCheckKehadiran };