Files
hipmi/src/app_modules/vote/fun/create/create_pilihan_voting.ts
2024-04-19 10:18:59 +08:00

25 lines
664 B
TypeScript

"use server";
import prisma from "@/app/lib/prisma";
import { user_getOneUserId } from "@/app_modules/fun_global/get_user_token";
import { revalidatePath } from "next/cache";
export async function Vote_funCreatePilihanVotingById(
namaVotingId: string,
votingId: string
) {
const authorId = await user_getOneUserId();
const create = await prisma.voting_Kontributor.create({
data: {
voting_DaftarNamaVoteId: namaVotingId,
votingId: votingId,
authorId: authorId,
},
});
if(!create) return {status: 400, message: "Gagal Voting"}
revalidatePath("/dev/vote/detail/main/");
return {status: 201, message: "Berhasil Voting"}
}