From c67b1b8a376d0f87728abd51550ba013376d6a66 Mon Sep 17 00:00:00 2001 From: lukman Date: Mon, 30 Sep 2024 10:47:49 +0800 Subject: [PATCH] style : update style Deskripsi: - update style home - update validasi jabatan No Issue --- src/app/api/home/notification/route.ts | 1 + src/module/_global/layout/layout_drawer.tsx | 2 +- src/module/division_new/ui/list_task.tsx | 2 +- src/module/home/ui/list_divisi.tsx | 4 +- src/module/home/ui/list_project.tsx | 4 +- .../position/ui/drawer_detail_position.tsx | 30 ++++++--- .../position/ui/drawer_list_position.tsx | 61 +++++++++++-------- 7 files changed, 65 insertions(+), 39 deletions(-) diff --git a/src/app/api/home/notification/route.ts b/src/app/api/home/notification/route.ts index 80213ce..0aebe27 100644 --- a/src/app/api/home/notification/route.ts +++ b/src/app/api/home/notification/route.ts @@ -3,6 +3,7 @@ import { funGetUserByCookies } from "@/module/auth"; import { createLogUser } from "@/module/user"; import _ from "lodash"; import moment from "moment"; +import "moment/locale/id"; import { NextResponse } from "next/server"; // GET ALL NOTIFIKASI diff --git a/src/module/_global/layout/layout_drawer.tsx b/src/module/_global/layout/layout_drawer.tsx index 31a31f2..804a922 100644 --- a/src/module/_global/layout/layout_drawer.tsx +++ b/src/module/_global/layout/layout_drawer.tsx @@ -8,7 +8,7 @@ export default function LayoutDrawer({ opened, onClose, title, children, size }: const tema = useHookstate(TEMA) return ( - {title}} onClose={onClose} position={"bottom"} size={(size == 'lg') ? '80%' : '40%'} + {title}} onClose={onClose} position={"bottom"} size={(size == 'lg') ? '80%' : '40%' } styles={{ content: { backgroundColor: "white", diff --git a/src/module/division_new/ui/list_task.tsx b/src/module/division_new/ui/list_task.tsx index b989569..892d35b 100644 --- a/src/module/division_new/ui/list_task.tsx +++ b/src/module/division_new/ui/list_task.tsx @@ -66,7 +66,7 @@ export default function ListTaskOnDetailDivision() { : <> } - + {data.map((v, i) => Tidak ada divisi : - + {isData.map((v) => - + Tidak ada kegiatan terbaru : - + {isData.map((v) => - + v == true)) + return false + onSubmit() + } + + function onValidation(kategori: string, val: string) { + if (kategori == 'name') { + setData({...data, name: val}) + if (val == "" || val.length < 3) { + setTouched({ ...touched, name: true }) + } else { + setTouched({ ...touched, name: false }) + } + } + } + async function nonActive(val: boolean) { try { if (val) { @@ -156,7 +173,6 @@ export default function DrawerDetailPosition({ onUpdated, id, isActive }: { {loading ? - : @@ -172,16 +188,14 @@ export default function DrawerDetailPosition({ onUpdated, id, isActive }: { required size="md" value={String(data.name)} - onChange={(e) => { - setData({ ...data, name: e.target.value }) - setTouched({ ...touched, name: false }) - }} + onChange={(e) => { onValidation('name', e.target.value) }} onBlur={() => setTouched({ ...touched, name: true })} error={ - touched.name && ( - data.name == "" ? "Nama Jabatan Tidak Boleh Kosong" : null + touched.name && + (data.name == "" ? "Error! harus memasukkan Nama Jabatan" : + data.name.length < 3 ? "Masukkan Minimal 3 karakter" : "" ) - } + } radius={10} placeholder="Nama Jabatan" /> diff --git a/src/module/position/ui/drawer_list_position.tsx b/src/module/position/ui/drawer_list_position.tsx index 283b4ee..fdb4485 100644 --- a/src/module/position/ui/drawer_list_position.tsx +++ b/src/module/position/ui/drawer_list_position.tsx @@ -73,6 +73,30 @@ export default function DrawerListPosition({ onCreated }: { onCreated: (val: boo } } + function onCheck() { + if (Object.values(touched).some((v) => v == true)) + return false + onSubmit() + } + + function onValidation(kategori: string, val: string) { + if (kategori == 'name') { + setListData({...listData, name: val}) + if (val == "" || val.length < 3) { + setTouched({ ...touched, name: true }) + } else { + setTouched({ ...touched, name: false }) + } + } else if (kategori == 'idGroup') { + setListData({ ...listData, idGroup: val }) + if (val == "") { + setTouched({ ...touched, idGroup: true }) + } else { + setTouched({ ...touched, idGroup: false }) + } + } + } + return ( @@ -102,9 +126,9 @@ export default function DrawerListPosition({ onCreated }: { onCreated: (val: boo setOpenDrawerGroup(false)} title={'Tambah Jabatan'} size="lg"> @@ -125,13 +149,9 @@ export default function DrawerListPosition({ onCreated }: { onCreated: (val: boo radius={10} mb={5} withAsterisk - onChange={(val: any) => { - setListData({ - ...listData, - idGroup: val - }) - setTouched({ ...touched, idGroup: false }) - }} + onChange={(e: any) => + { onValidation('idGroup', e) } + } styles={{ input: { color: tema.get().utama, @@ -144,8 +164,6 @@ export default function DrawerListPosition({ onCreated }: { onCreated: (val: boo listData.idGroup == "" ? "Grup Tidak Boleh Kosong" : null ) } - onFocus={() => setTouched({ ...touched, idGroup: true })} - onBlur={() => setTouched({ ...touched, idGroup: true })} /> } { - setListData({ - ...listData, - name: event.target.value - }) - setTouched({ ...touched, name: false }) - }} + onChange={(e) => { onValidation('name', e.target.value) }} radius={10} placeholder="Nama Jabatan" error={ - touched.name && ( - listData.name == "" ? "Nama Jabatan Tidak Boleh Kosong" : null + touched.name && + (listData.name == "" ? "Error! harus memasukkan Nama Jabatan" : + listData.name.length < 3 ? "Masukkan Minimal 3 karakter" : "" ) - } - onFocus={() => setTouched({ ...touched, name: true })} - onBlur={() => setTouched({ ...touched, name: true })} + } required /> @@ -184,7 +195,7 @@ export default function DrawerListPosition({ onCreated }: { onCreated: (val: boo size="lg" radius={30} fullWidth - onClick={onSubmit} + onClick={() => { onCheck() }} > SIMPAN