diff --git a/src/pages/darmasaba/update_data_surat.tsx b/src/pages/darmasaba/update_data_surat.tsx index 730ac6a..e983dfc 100644 --- a/src/pages/darmasaba/update_data_surat.tsx +++ b/src/pages/darmasaba/update_data_surat.tsx @@ -712,7 +712,7 @@ function DataUpdate({ (n: any) => n.key === item.key, )?.value, ) - : parseTanggalID(item.value) + : parseTanggalID(item.value) } /> ) : ( diff --git a/src/pages/scr/dashboard/pelayanan-surat/detail_pelayanan_page.tsx b/src/pages/scr/dashboard/pelayanan-surat/detail_pelayanan_page.tsx index 767efc6..b51e64d 100644 --- a/src/pages/scr/dashboard/pelayanan-surat/detail_pelayanan_page.tsx +++ b/src/pages/scr/dashboard/pelayanan-surat/detail_pelayanan_page.tsx @@ -2,7 +2,9 @@ import ModalFile from "@/components/ModalFile"; import ModalSurat from "@/components/ModalSurat"; import notification from "@/components/notificationGlobal"; import apiFetch from "@/lib/apiFetch"; +import { parseTanggalID } from "@/server/lib/stringToDate"; import { + ActionIcon, Anchor, Badge, Button, @@ -14,24 +16,31 @@ import { Group, List, Modal, + Select, Spoiler, Stack, Table, Text, Textarea, + TextInput, ThemeIcon, Title, + Tooltip } from "@mantine/core"; +import { DateInput } from "@mantine/dates"; import { useDisclosure, useShallowEffect } from "@mantine/hooks"; import { IconAlignJustified, IconCheck, + IconEdit, IconFileCertificate, IconFileCheck, + IconInfoCircle, IconMessageReport, IconPhone, IconUser, } from "@tabler/icons-react"; +import dayjs from "dayjs"; import type { User } from "generated/prisma"; import type { JsonValue } from "generated/prisma/runtime/library"; import _ from "lodash"; @@ -93,6 +102,7 @@ function DetailDataPengajuan({ dataText: any; onAction: () => void; }) { + const [opened, { open, close }] = useDisclosure(false); const [catModal, setCatModal] = useState<"tolak" | "terima">("tolak"); const [keterangan, setKeterangan] = useState(""); @@ -103,6 +113,9 @@ function DetailDataPengajuan({ const [permissions, setPermissions] = useState([]); const [viewImg, setViewImg] = useState({ file: "", folder: "" }); const [uploading, setUploading] = useState({ ok: false, file: "" }); + const [editValue, setEditValue] = useState({ id: "", jenis: "", val: "", option: null as any, type: "", key: "" }) + const [openEdit, setOpenEdit] = useState(false) + const [loadingUpdate, setLoadingUpdate] = useState(false) useEffect(() => { async function fetchHost() { @@ -215,6 +228,43 @@ function DetailDataPengajuan({ } }; + async function updateDataText() { + try { + setLoadingUpdate(true) + const res = await apiFetch.api.pelayanan["update-data-pelengkap"].post({ + id: editValue.id, + value: editValue.val, + jenis: editValue.key, + idUser: host?.id ?? "", + }) + + if (res?.status === 200) { + notification({ + title: "Success", + message: "Success update data", + type: "success", + }) + } else { + notification({ + title: "Error", + message: "Failed to update data", + type: "error", + }) + } + } catch (error) { + console.error(error) + notification({ + title: "Error", + message: "Failed to update data", + type: "error", + }) + } finally { + setLoadingUpdate(false) + setOpenEdit(false) + onAction() + } + } + useShallowEffect(() => { if (viewImg) { setOpenedPreviewFile(true); @@ -231,9 +281,86 @@ function DetailDataPengajuan({ } }, [uploading]); + function FieldLabel({ label, hint }: { label: string; hint?: string }) { + return ( + + {label} + {hint && ( + + + + + + )} + + ); + } return ( <> + {/* MODAL EDIT DATA PELENGKAP */} + setOpenEdit(false)} + title={"Edit"} + overlayProps={{ backgroundOpacity: 0.55, blur: 3 }} + > + + {editValue.type == "enum" ? ( +