Fix: Event
Deskripsi: - Fix database event - Fix style detal
This commit is contained in:
@@ -1,12 +1,20 @@
|
||||
"use client";
|
||||
|
||||
import { MainColor } from "@/app_modules/_global/color/color_pallet";
|
||||
import ComponentGlobal_ErrorInput from "@/app_modules/_global/component/error_input";
|
||||
import ComponentGlobal_InputCountDown from "@/app_modules/_global/component/input_countdown";
|
||||
import { ComponentGlobal_NotifikasiBerhasil } from "@/app_modules/_global/notif_global/notifikasi_berhasil";
|
||||
import { ComponentGlobal_NotifikasiGagal } from "@/app_modules/_global/notif_global/notifikasi_gagal";
|
||||
import { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/_global/notif_global/notifikasi_peringatan";
|
||||
import { MODEL_DEFAULT_MASTER_OLD } from "@/app_modules/model_global/interface";
|
||||
import { Button, Select, Stack, TextInput, Textarea } from "@mantine/core";
|
||||
import {
|
||||
Button,
|
||||
Select,
|
||||
Stack,
|
||||
Text,
|
||||
TextInput,
|
||||
Textarea,
|
||||
} from "@mantine/core";
|
||||
import { DateTimePicker } from "@mantine/dates";
|
||||
import _ from "lodash";
|
||||
import moment from "moment";
|
||||
@@ -15,7 +23,7 @@ import { useRouter } from "next/navigation";
|
||||
import { useState } from "react";
|
||||
import { Event_funEditById } from "../fun/edit/fun_edit_by_id";
|
||||
import { MODEL_EVENT } from "../model/interface";
|
||||
import { MainColor } from "@/app_modules/_global/color/color_pallet";
|
||||
import ComponentEvent_ErrorMaximalInput from "../component/error_maksimal_input";
|
||||
|
||||
export default function Event_Edit({
|
||||
dataEvent,
|
||||
@@ -30,10 +38,11 @@ export default function Event_Edit({
|
||||
const [value, setValue] = useState(dataEvent);
|
||||
const [tipe, setTipe] = useState(listTipeAcara);
|
||||
|
||||
// Masimal karakter state
|
||||
const [maxTitle, setMaxTitle] = useState("");
|
||||
const [maxLokasi, setMaxLokasi] = useState("");
|
||||
const [maxDeskripsi, setMaxDeskripsi] = useState("");
|
||||
const [isTimeStart, setIsTimeStart] = useState(false);
|
||||
const [diffTimeStart, setDiffTimeStart] = useState(0);
|
||||
const [isTimeEnd, setIsTimeEnd] = useState(false);
|
||||
const [diffTimeEnd, setDiffTimeEnd] = useState(0);
|
||||
|
||||
return (
|
||||
<>
|
||||
{/* <pre>{JSON.stringify(value, null, 2)}</pre> */}
|
||||
@@ -57,7 +66,6 @@ export default function Event_Edit({
|
||||
)
|
||||
}
|
||||
onChange={(val) => {
|
||||
setMaxTitle(val.target.value);
|
||||
setValue({
|
||||
...value,
|
||||
title: val.target.value,
|
||||
@@ -108,13 +116,23 @@ export default function Event_Edit({
|
||||
)
|
||||
}
|
||||
onChange={(val) => {
|
||||
setMaxLokasi(val.target.value);
|
||||
setValue({
|
||||
...value,
|
||||
lokasi: val.target.value,
|
||||
});
|
||||
}}
|
||||
/>
|
||||
|
||||
{/* <Text c={"green"}>{JSON.stringify(diffTimeStart, null, 2)}</Text>
|
||||
<Text c={"red"}>{JSON.stringify(diffTimeEnd, null, 2)}</Text>
|
||||
<Text c={"yellow"}>
|
||||
{JSON.stringify(
|
||||
moment(value.tanggal.toISOString().toString()),
|
||||
null,
|
||||
2
|
||||
)}
|
||||
</Text> */}
|
||||
|
||||
<DateTimePicker
|
||||
styles={{
|
||||
label: {
|
||||
@@ -125,20 +143,27 @@ export default function Event_Edit({
|
||||
return moment(date).diff(Date.now(), "days") < 0;
|
||||
}}
|
||||
withAsterisk
|
||||
label="Tanggal & Waktu "
|
||||
placeholder="Masukan tangal dan waktu acara"
|
||||
label="Tanggal & Waktu Mulai"
|
||||
placeholder="Masukan tangal dan waktu"
|
||||
value={value.tanggal}
|
||||
error={
|
||||
moment(value.tanggal.toISOString().toString()).diff(
|
||||
moment(),
|
||||
"minutes"
|
||||
) < 0 ? (
|
||||
<ComponentGlobal_ErrorInput text="Invalid Time" />
|
||||
isTimeStart ? (
|
||||
<ComponentEvent_ErrorMaximalInput text="Invalid Time !" />
|
||||
) : (
|
||||
""
|
||||
)
|
||||
}
|
||||
onChange={(val) => {
|
||||
const diffTime = moment(val?.toISOString().toString()).diff(
|
||||
moment(),
|
||||
"minutes"
|
||||
);
|
||||
setDiffTimeStart(diffTime);
|
||||
|
||||
moment(val?.toISOString().toString()).diff(moment(), "minutes") < 0
|
||||
? setIsTimeStart(true)
|
||||
: setIsTimeStart(false);
|
||||
|
||||
setValue({
|
||||
...(value as any),
|
||||
tanggal: val,
|
||||
@@ -146,6 +171,47 @@ export default function Event_Edit({
|
||||
}}
|
||||
/>
|
||||
|
||||
<DateTimePicker
|
||||
styles={{
|
||||
label: {
|
||||
color: "white",
|
||||
},
|
||||
}}
|
||||
excludeDate={(date) => {
|
||||
return moment(date).diff(Date.now(), "days") < 0;
|
||||
}}
|
||||
withAsterisk
|
||||
label="Tanggal & Waktu Berakhir"
|
||||
placeholder="Masukan tangal dan waktu"
|
||||
value={value.tanggalSelesai}
|
||||
error={
|
||||
isTimeEnd ? (
|
||||
<ComponentEvent_ErrorMaximalInput text="Invalid Time !" />
|
||||
) : moment(value.tanggalSelesai?.toISOString().toString()) <
|
||||
moment(value.tanggal.toISOString().toString()) ? (
|
||||
<ComponentGlobal_ErrorInput text="Invalid Time !" />
|
||||
) : (
|
||||
""
|
||||
)
|
||||
}
|
||||
onChange={(val) => {
|
||||
const diffTime = moment(val?.toISOString().toString()).diff(
|
||||
moment(),
|
||||
"minutes"
|
||||
);
|
||||
setDiffTimeEnd(diffTime);
|
||||
|
||||
moment(val?.toISOString().toString()).diff(moment(), "minutes") < 0
|
||||
? setIsTimeEnd(true)
|
||||
: setIsTimeEnd(false);
|
||||
|
||||
setValue({
|
||||
...(value as any),
|
||||
tanggalSelesai: val,
|
||||
});
|
||||
}}
|
||||
/>
|
||||
|
||||
<Stack spacing={5}>
|
||||
<Textarea
|
||||
styles={{
|
||||
@@ -167,7 +233,6 @@ export default function Event_Edit({
|
||||
)
|
||||
}
|
||||
onChange={(val) => {
|
||||
setMaxDeskripsi(val.target.value);
|
||||
setValue({
|
||||
...value,
|
||||
deskripsi: val.target.value,
|
||||
@@ -189,9 +254,8 @@ export default function Event_Edit({
|
||||
value.lokasi === "" ||
|
||||
value.deskripsi === "" ||
|
||||
value.eventMaster_TipeAcaraId === 0 ||
|
||||
value.tanggal.toISOString.toString() ===
|
||||
"function Date() { [native code] }" ||
|
||||
moment(value.tanggal).diff(moment(), "minutes") < 0
|
||||
moment(value.tanggalSelesai?.toISOString().toString()) <
|
||||
moment(value.tanggal.toISOString().toString())
|
||||
}
|
||||
loaderPosition="center"
|
||||
loading={isLoading ? true : false}
|
||||
|
||||
Reference in New Issue
Block a user