From 46cfd0fbc55ab552d01c5f1ec8d327d31b7722f4 Mon Sep 17 00:00:00 2001 From: amel Date: Fri, 27 Sep 2024 12:04:14 +0800 Subject: [PATCH 1/2] upd Deskripsi: - tugas hari ini di halaman detail divisi No Issues --- src/app/api/division/[id]/detail/route.ts | 22 ++++++++++++++++---- src/module/division_new/lib/type_division.ts | 3 ++- src/module/division_new/ui/list_task.tsx | 4 ++-- 3 files changed, 22 insertions(+), 7 deletions(-) diff --git a/src/app/api/division/[id]/detail/route.ts b/src/app/api/division/[id]/detail/route.ts index 1f8d403..730e272 100644 --- a/src/app/api/division/[id]/detail/route.ts +++ b/src/app/api/division/[id]/detail/route.ts @@ -86,7 +86,12 @@ export async function GET(request: Request, context: { params: { id: string } }) idDivision: String(id), status: 0, isActive: true, - dateStart: new Date(), + dateStart: { + lte: new Date() + }, + dateEnd: { + gte: new Date() + }, DivisionProject: { status: { lt: 3 @@ -98,13 +103,22 @@ export async function GET(request: Request, context: { params: { id: string } }) title: true, dateStart: true, dateEnd: true, + DivisionProject: { + select: { + title: true + } + } + }, + orderBy: { + dateEnd: "asc" } }) allData = tugas.map((v: any) => ({ - ..._.omit(v, ["dateStart", "dateEnd"]), - dateStart: moment(v.dateStart).format("LL"), - dateEnd: moment(v.dateEnd).format("LL") + ..._.omit(v, ["dateStart", "dateEnd", "DivisionProject"]), + dateStart: moment(v.dateStart).format("ll"), + dateEnd: moment(v.dateEnd).format("ll"), + projectTitle: v.DivisionProject.title })) } else if (kategori == "new-file") { allData = await prisma.divisionDocumentFolderFile.findMany({ diff --git a/src/module/division_new/lib/type_division.ts b/src/module/division_new/lib/type_division.ts index 6487148..4bd051a 100644 --- a/src/module/division_new/lib/type_division.ts +++ b/src/module/division_new/lib/type_division.ts @@ -33,7 +33,8 @@ export interface IDataTaskOnDetailDivision { id: string, title: string, dateStart: string, - dateEnd: string + dateEnd: string, + projectTitle: string } export interface IDataKalenderOnDetailDivision { diff --git a/src/module/division_new/ui/list_task.tsx b/src/module/division_new/ui/list_task.tsx index 9ae596f..b989569 100644 --- a/src/module/division_new/ui/list_task.tsx +++ b/src/module/division_new/ui/list_task.tsx @@ -73,11 +73,11 @@ export default function ListTaskOnDetailDivision() { base: isMobile ? 230 : 300, md: 400 }} onClick={() => router.push(`/task/${v.id}`)} bg={"white"} style={{ borderRadius: 10, border: `1px solid ${"#D6D8F6"}` }}> - {_.startCase(v.title)} + {v.title+' - '+ v.projectTitle} - {v.dateStart} + {v.dateStart} - {v.dateEnd} From 5e6079785aea76c7d3aff62e5af83516d4745963 Mon Sep 17 00:00:00 2001 From: amel Date: Fri, 27 Sep 2024 15:36:37 +0800 Subject: [PATCH 2/2] fix: edit profile Deskripsi: - validasi edit profile No Issues --- src/app/(application)/profile/edit/page.tsx | 4 +- src/module/_global/layout/layout_modal.tsx | 11 +- .../user/profile/ui/edit_profile copy.tsx | 311 ------------------ src/module/user/profile/ui/edit_profile.tsx | 160 ++++----- 4 files changed, 85 insertions(+), 401 deletions(-) delete mode 100644 src/module/user/profile/ui/edit_profile copy.tsx diff --git a/src/app/(application)/profile/edit/page.tsx b/src/app/(application)/profile/edit/page.tsx index e87a120..da3e588 100644 --- a/src/app/(application)/profile/edit/page.tsx +++ b/src/app/(application)/profile/edit/page.tsx @@ -1,10 +1,8 @@ import { EditProfile } from "@/module/user" -import EditProfileCopy from "@/module/user/profile/ui/edit_profile copy" function Page() { return ( - // - + ) } diff --git a/src/module/_global/layout/layout_modal.tsx b/src/module/_global/layout/layout_modal.tsx index 88b9cdb..b93d8b7 100644 --- a/src/module/_global/layout/layout_modal.tsx +++ b/src/module/_global/layout/layout_modal.tsx @@ -1,12 +1,9 @@ import { Button, Flex, Modal, SimpleGrid, Text } from '@mantine/core'; -import React, { useState } from 'react'; -import { BsQuestionCircleFill } from 'react-icons/bs'; import { useMediaQuery } from '@mantine/hooks'; +import { BsQuestionCircleFill } from 'react-icons/bs'; -export default function LayoutModal({ opened, onClose, description, onYes }: { opened: boolean, onClose: () => void, description: string, onYes: (val: boolean) => void }) { - const [isValModal, setValModal] = useState(opened) +export default function LayoutModal({ opened, onClose, description, onYes, loading }: { opened: boolean, onClose: () => void, loading?: boolean, description: string, onYes: (val: boolean) => void }) { const isMobile = useMediaQuery('(max-width: 768px)'); - const [loading, setLoading] = useState(false) return ( @@ -38,9 +33,7 @@ export default function LayoutModal({ opened, onClose, description, onYes }: { o <> diff --git a/src/module/user/profile/ui/edit_profile copy.tsx b/src/module/user/profile/ui/edit_profile copy.tsx deleted file mode 100644 index 16776f0..0000000 --- a/src/module/user/profile/ui/edit_profile copy.tsx +++ /dev/null @@ -1,311 +0,0 @@ -"use client"; -import { LayoutNavbarNew, TEMA } from "@/module/_global"; -import { - Avatar, - Box, - Button, - Flex, - Indicator, - Modal, - rem, - Select, - Skeleton, - Stack, - Text, - TextInput, -} from "@mantine/core"; -import toast from "react-hot-toast"; -import LayoutModal from "@/module/_global/layout/layout_modal"; -import { useRef, useState } from "react"; -import { IEditDataProfile, IProfileById } from "../lib/type_profile"; -import { - funEditProfileByCookies, - funGetProfileByCookies, -} from "../lib/api_profile"; -import { useShallowEffect } from "@mantine/hooks"; -import { FaCamera, FaShare } from "react-icons/fa6"; -import { Dropzone } from "@mantine/dropzone"; -import _ from "lodash"; -import { useRouter } from "next/navigation"; -import { useHookstate } from "@hookstate/core"; -import { useForm } from "@mantine/form"; - -export default function EditProfileCopy() { - const [isValModal, setValModal] = useState(false); - const [isDataEdit, setDataEdit] = useState([]); - const openRef = useRef<() => void>(null); - const [img, setIMG] = useState(); - const [imgForm, setImgForm] = useState(); - const router = useRouter(); - const [loading, setLoading] = useState(true); - const tema = useHookstate(TEMA); - - const [data, setData] = useState({ - id: "", - nik: "", - name: "", - phone: "", - email: "", - gender: "", - img: "", - }); - - async function getAllProfile() { - try { - setLoading(true); - const res = await funGetProfileByCookies(); - setData(res.data); - setIMG(`https://wibu-storage.wibudev.com/api/files/${res.data.img}`); - setLoading(false); - } catch (error) { - console.error(error); - } finally { - setLoading(false); - } - } - - useShallowEffect(() => { - getAllProfile(); - }, []); - - async function onEditProfile(val: boolean) { - try { - if (val) { - const fd = new FormData(); - fd.append("file", imgForm); - fd.append("data", JSON.stringify(data)); - - const res = await funEditProfileByCookies(fd); - if (res.success) { - setValModal(false); - toast.success(res.message); - router.push("/profile"); - } else { - toast.error(res.message); - } - } - setValModal(false); - } catch (error) { - console.error(error); - toast.error("Gagal edit profil, coba lagi nanti"); - } - } - - return ( - - - - { - if (!files || _.isEmpty(files)) - return toast.error("Tidak ada gambar yang dipilih"); - setImgForm(files[0]); - const buffer = URL.createObjectURL( - new Blob([new Uint8Array(await files[0].arrayBuffer())]) - ); - setIMG(buffer); - }} - activateOnClick={false} - maxSize={1 * 1024 ** 2} - accept={["image/png", "image/jpeg", "image/heic"]} - onReject={(files) => { - return toast.error( - "File yang diizinkan: .png, .jpg, dan .heic dengan ukuran maksimal 1 MB" - ); - }} - > - - {loading ? ( - - ) : ( - } - size={40} - onClick={() => openRef.current?.()} - > - - - )} - {loading ? ( - <> - - - - - - - ) : ( - <> - { - setData({ ...data, nik: e.target.value }); - }} - value={data.nik} - /> - { - setData({ ...data, name: e.target.value }); - }} - /> - { - setData({ ...data, email: e.target.value }); - }} - value={data.email} - /> - +62} - onChange={(e) => { - setData({ ...data, phone: e.target.value }); - }} - value={data.phone} - /> - { - setData({ ...data, gender: val }); - setTouched({ ...touched, gender: false }); - }} + onChange={(val: any) => { onValidation('gender', val) }} value={data.gender} - onBlur={() => setTouched({ ...touched, gender: true })} error={ touched.gender && - (data.gender == "" ? "Jenis Kelamin Tidak Boleh Kosong" : null) + (data.gender == "" || data.gender == null ? "Jenis Kelamin Tidak Boleh Kosong" : null) } /> @@ -328,28 +343,17 @@ export default function EditProfile() { )} setValModal(false)} description="Apakah Anda yakin ingin