# Voting prototype
- feat - Tampilan beranda - Tampilan status - Tampilan kontribusi - Tampilan riwayat ## No Issue
This commit is contained in:
@@ -7,6 +7,7 @@ import {
|
||||
Divider,
|
||||
Group,
|
||||
List,
|
||||
Modal,
|
||||
Paper,
|
||||
SimpleGrid,
|
||||
Stack,
|
||||
@@ -23,8 +24,11 @@ import { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/component_gl
|
||||
import { ComponentGlobal_NotifikasiBerhasil } from "@/app_modules/component_global/notif_global/notifikasi_berhasil";
|
||||
import { ComponentGlobal_NotifikasiGagal } from "@/app_modules/component_global/notif_global/notifikasi_gagal";
|
||||
import { AdminEvent_getListTipeAcara } from "../fun/get/get_list_tipe_acara";
|
||||
import { IconEditCircle } from "@tabler/icons-react";
|
||||
import { IconEditCircle, IconTrash } from "@tabler/icons-react";
|
||||
import { AdminEvent_funEditTipeAcara } from "../fun/edit/fun_edit_tipe_acara";
|
||||
import { useDisclosure } from "@mantine/hooks";
|
||||
import { AdminEvent_funEditActivationTipeAcaraById } from "../fun/edit/fun_edit_activation_tipe_acara";
|
||||
import { number } from "echarts";
|
||||
|
||||
export default function AdminEvent_DetailTipeAcara({
|
||||
listTipe,
|
||||
@@ -46,8 +50,35 @@ function DetailTipeAcara({ listTipe }: { listTipe: MODEL_DEFAULT_MASTER[] }) {
|
||||
const [name, setName] = useState("");
|
||||
const [openEditor, setOpenEditor] = useState(false);
|
||||
const [edit, setEdit] = useState<MODEL_DEFAULT_MASTER | null>(null);
|
||||
const [opened, { open, close }] = useDisclosure(false);
|
||||
const [hapusTipe, setHapusTipe] = useState({
|
||||
id: "",
|
||||
name: "",
|
||||
});
|
||||
|
||||
return (
|
||||
<>
|
||||
<Modal opened={opened} onClose={close} centered withCloseButton={false}>
|
||||
<Stack>
|
||||
<Title order={6}>
|
||||
Anda yakin akan menghapus{" "}
|
||||
<Text span c={"red"} inherit>
|
||||
{hapusTipe.name}
|
||||
</Text>{" "}
|
||||
?
|
||||
</Title>
|
||||
<Group position="center">
|
||||
<Button onClick={() => close()}>Batal</Button>
|
||||
<Button
|
||||
onClick={() => onDelete(hapusTipe as any, close, setTipe)}
|
||||
color="red"
|
||||
>
|
||||
Hapus
|
||||
</Button>
|
||||
</Group>
|
||||
</Stack>
|
||||
</Modal>
|
||||
|
||||
<SimpleGrid
|
||||
cols={3}
|
||||
spacing="lg"
|
||||
@@ -86,15 +117,30 @@ function DetailTipeAcara({ listTipe }: { listTipe: MODEL_DEFAULT_MASTER[] }) {
|
||||
<Stack key={e.id} spacing={"xs"}>
|
||||
<Group position="apart">
|
||||
<Text>{e.name}</Text>
|
||||
<ActionIcon
|
||||
variant="transparent"
|
||||
onClick={() => {
|
||||
setOpenEditor(true);
|
||||
setEdit(e);
|
||||
}}
|
||||
>
|
||||
<IconEditCircle color="green" />
|
||||
</ActionIcon>
|
||||
<Group>
|
||||
<ActionIcon
|
||||
variant="transparent"
|
||||
onClick={() => {
|
||||
setOpenEditor(true);
|
||||
setEdit(e);
|
||||
}}
|
||||
>
|
||||
<IconEditCircle color="green" />
|
||||
</ActionIcon>{" "}
|
||||
<ActionIcon
|
||||
variant="transparent"
|
||||
onClick={() => {
|
||||
open();
|
||||
setHapusTipe({
|
||||
...hapusTipe,
|
||||
id: e.id,
|
||||
name: e.name,
|
||||
});
|
||||
}}
|
||||
>
|
||||
<IconTrash color="red" />
|
||||
</ActionIcon>
|
||||
</Group>
|
||||
</Group>
|
||||
<Divider />
|
||||
</Stack>
|
||||
@@ -175,3 +221,18 @@ async function onUpdate(id: any, edit: any, setTipe: any, setOpenEditor: any) {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
async function onDelete(data: MODEL_DEFAULT_MASTER, close: any, setTipe: any) {
|
||||
await AdminEvent_funEditActivationTipeAcaraById(data.id as any).then(
|
||||
async (res) => {
|
||||
if (res.status === 200) {
|
||||
const data = await AdminEvent_getListTipeAcara();
|
||||
setTipe(data);
|
||||
ComponentGlobal_NotifikasiBerhasil(res.message);
|
||||
close();
|
||||
} else {
|
||||
ComponentGlobal_NotifikasiGagal(res.message);
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
"use server";
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import { revalidatePath } from "next/cache";
|
||||
|
||||
export async function AdminEvent_funEditActivationTipeAcaraById(id: number) {
|
||||
const updt = await prisma.eventMaster_TipeAcara.update({
|
||||
where: {
|
||||
id: id,
|
||||
},
|
||||
data: {
|
||||
active: false,
|
||||
},
|
||||
});
|
||||
|
||||
if(!updt) return {status: 400, message: "Gagal Update"}
|
||||
revalidatePath("/dev/admin/event/child/tipe_acara");
|
||||
return {
|
||||
status: 200,
|
||||
message: "Update Berhasil"
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,9 @@ export async function AdminEvent_getListTipeAcara(){
|
||||
const data = await prisma.eventMaster_TipeAcara.findMany({
|
||||
orderBy:{
|
||||
id: "asc"
|
||||
},
|
||||
where: {
|
||||
active: true
|
||||
}
|
||||
})
|
||||
return data
|
||||
|
||||
Reference in New Issue
Block a user