# Event Join
## feat - Join event - kontribusi event - histoty in progress ### No Issue
This commit is contained in:
@@ -13,11 +13,12 @@ import {
|
||||
Image,
|
||||
MultiSelect,
|
||||
Paper,
|
||||
Select,
|
||||
Stack,
|
||||
TextInput,
|
||||
Textarea,
|
||||
} from "@mantine/core";
|
||||
import { DateTimePicker } from "@mantine/dates";
|
||||
import { DateInput, DatePicker, DateTimePicker } from "@mantine/dates";
|
||||
import { TimeInput } from "@mantine/dates";
|
||||
import { IconCamera } from "@tabler/icons-react";
|
||||
import { useAtom } from "jotai";
|
||||
@@ -25,38 +26,101 @@ import { AppRouterInstance } from "next/dist/shared/lib/app-router-context.share
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useState } from "react";
|
||||
import { gs_event_status } from "../global_state";
|
||||
import { MODEL_DEFAULT_MASTER } from "@/app_modules/model_global/interface";
|
||||
import { Event_funCreate } from "../fun/create/fun_create";
|
||||
import { ComponentGlobal_NotifikasiGagal } from "@/app_modules/component_global/notif_global/notifikasi_gagal";
|
||||
import { kMaxLength } from "buffer";
|
||||
|
||||
export default function Event_Create({ listUser }: { listUser: MODEL_USER[] }) {
|
||||
export default function Event_Create({
|
||||
listTipeAcara,
|
||||
authorId,
|
||||
}: {
|
||||
listTipeAcara: MODEL_DEFAULT_MASTER[];
|
||||
authorId: string;
|
||||
}) {
|
||||
const router = useRouter();
|
||||
const [img, setImg] = useState<any>();
|
||||
const [file, setFile] = useState<any>();
|
||||
const [tabsStatus, setTabsStatus] = useAtom(gs_event_status);
|
||||
const [listTipe, setListTipe] = useState(listTipeAcara);
|
||||
|
||||
const [value, setValue] = useState({
|
||||
title: "",
|
||||
lokasi: "",
|
||||
deskripsi: "",
|
||||
tanggal: Date,
|
||||
eventMaster_TipeAcaraId: 0,
|
||||
authorId: authorId,
|
||||
});
|
||||
|
||||
return (
|
||||
<>
|
||||
<Stack px={"sm"}>
|
||||
<TextInput label="Judul" placeholder="Masukan judul" withAsterisk />
|
||||
<TextInput
|
||||
label="Judul"
|
||||
placeholder="Masukan judul"
|
||||
withAsterisk
|
||||
onChange={(val) =>
|
||||
setValue({
|
||||
...value,
|
||||
title: val.target.value,
|
||||
})
|
||||
}
|
||||
/>
|
||||
|
||||
<Select
|
||||
label="Tipe Acara"
|
||||
placeholder="Pilih Tipe Acara"
|
||||
data={listTipe.map((e) => ({
|
||||
value: e.id,
|
||||
label: e.name,
|
||||
}))}
|
||||
onChange={(val: any) =>
|
||||
setValue({
|
||||
...value,
|
||||
eventMaster_TipeAcaraId: val,
|
||||
})
|
||||
}
|
||||
/>
|
||||
|
||||
<TextInput
|
||||
label="Lokasi"
|
||||
placeholder="Masukan lokasi acara"
|
||||
withAsterisk
|
||||
onChange={(val) =>
|
||||
setValue({
|
||||
...value,
|
||||
lokasi: val.target.value,
|
||||
})
|
||||
}
|
||||
/>
|
||||
<DateTimePicker
|
||||
withAsterisk
|
||||
label="Tanggal & Waktu "
|
||||
placeholder="Masukan tangal dan waktu acara"
|
||||
onChange={(val) => console.log(val)}
|
||||
onChange={(val: any) =>
|
||||
setValue({
|
||||
...value,
|
||||
tanggal: val,
|
||||
})
|
||||
}
|
||||
/>
|
||||
<Textarea
|
||||
label="Deskripsi"
|
||||
placeholder="Deskripsikan acara yang akan di selenggarakan"
|
||||
withAsterisk
|
||||
maxLength={500}
|
||||
autosize
|
||||
onChange={(val) =>
|
||||
setValue({
|
||||
...value,
|
||||
deskripsi: val.target.value,
|
||||
})
|
||||
}
|
||||
/>
|
||||
|
||||
<Button
|
||||
radius={"xl"}
|
||||
mt={"xl"}
|
||||
onClick={() => onSave(router, setTabsStatus)}
|
||||
onClick={() => onSave(router, setTabsStatus, value)}
|
||||
>
|
||||
Simpan
|
||||
</Button>
|
||||
@@ -65,8 +129,18 @@ export default function Event_Create({ listUser }: { listUser: MODEL_USER[] }) {
|
||||
);
|
||||
}
|
||||
|
||||
async function onSave(router: AppRouterInstance, setTabsStatus: any) {
|
||||
ComponentGlobal_NotifikasiBerhasil("Berhasil disimpan");
|
||||
setTabsStatus("Review");
|
||||
router.push(RouterEvent.status_page);
|
||||
async function onSave(
|
||||
router: AppRouterInstance,
|
||||
setTabsStatus: any,
|
||||
value: any
|
||||
) {
|
||||
await Event_funCreate(value).then((res) => {
|
||||
if (res.status === 201) {
|
||||
ComponentGlobal_NotifikasiBerhasil(res.message);
|
||||
setTabsStatus("Review");
|
||||
router.push(RouterEvent.status_page);
|
||||
} else {
|
||||
ComponentGlobal_NotifikasiGagal(res.message);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user