Fix: event
Deskripsi: - Create event konfirmasi
This commit is contained in:
@@ -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" };
|
||||
}
|
||||
27
src/app_modules/event/fun/get/fun_check_kehadiran.ts
Normal file
27
src/app_modules/event/fun/get/fun_check_kehadiran.ts
Normal 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;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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,
|
||||
},
|
||||
});
|
||||
|
||||
@@ -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 };
|
||||
|
||||
Reference in New Issue
Block a user