From 82211071e1f1aaa5c2d879d724d3fe673d6a7eb9 Mon Sep 17 00:00:00 2001 From: amel Date: Mon, 8 Jul 2024 15:23:00 +0800 Subject: [PATCH] update : profile Deskripsi: - menghapus info - mengganti variable global menjadi usestate - mengganti layoutnavbar new No Issues --- .../_global/layout/layout_icon_back.tsx | 2 +- src/module/_global/layout/layout_modal.tsx | 5 ++-- .../user/profile/component/edit_profile.tsx | 29 ++++++++++--------- .../component/ui/header_edit_profile.tsx | 14 ++------- .../user/profile/component/ui/ui_profile.tsx | 2 +- src/module/user/profile/view/view_profile.tsx | 4 +-- 6 files changed, 24 insertions(+), 32 deletions(-) diff --git a/src/module/_global/layout/layout_icon_back.tsx b/src/module/_global/layout/layout_icon_back.tsx index f3a6dc3..5d4e66a 100644 --- a/src/module/_global/layout/layout_icon_back.tsx +++ b/src/module/_global/layout/layout_icon_back.tsx @@ -11,7 +11,7 @@ function LayoutIconBack({ back }: { back?: string }) { return ( { - if (!_.isUndefined(back) && !_.isNull(back)) { + if (!_.isUndefined(back) && !_.isNull(back) && !_.isEmpty(back)) { return router.push(back) } else { return router.back() diff --git a/src/module/_global/layout/layout_modal.tsx b/src/module/_global/layout/layout_modal.tsx index 2c60bed..650b46e 100644 --- a/src/module/_global/layout/layout_modal.tsx +++ b/src/module/_global/layout/layout_modal.tsx @@ -1,11 +1,12 @@ import { useHookstate } from '@hookstate/core'; import { Box, Button, Flex, Modal, Text } from '@mantine/core'; -import React from 'react'; +import React, { useState } from 'react'; import { BsQuestionCircleFill } from 'react-icons/bs'; import { isModal } from '../val/isModal'; export default function LayoutModal({ opened, onClose, description, onYes }: { opened: boolean, onClose: () => void, description: string, onYes: (val: boolean) => void }) { const openModal = useHookstate(isModal) + const [isValModal, setValModal] = useState(opened) return ( {description} - + diff --git a/src/module/user/profile/component/edit_profile.tsx b/src/module/user/profile/component/edit_profile.tsx index bff9b82..311f698 100644 --- a/src/module/user/profile/component/edit_profile.tsx +++ b/src/module/user/profile/component/edit_profile.tsx @@ -1,23 +1,24 @@ "use client" -import { isModal, WARNA } from "@/module/_global"; +import { LayoutNavbarNew, WARNA } from "@/module/_global"; import { Box, Button, Flex, Modal, Stack, Text, TextInput } from "@mantine/core"; -import HeaderEditProfile from "../component/ui/header_edit_profile"; import { HiUser } from "react-icons/hi2"; -import { useHookstate } from "@hookstate/core"; -import { BsQuestionCircleFill } from "react-icons/bs" import toast from "react-hot-toast"; import LayoutModal from "@/module/_global/layout/layout_modal"; +import { useState } from "react"; export default function EditProfile() { - const openModal = useHookstate(isModal) + const [isValModal, setValModal] = useState(false) - function onTrue() { - toast.success("Sukses! Data tersimpan"); - openModal.set(false) + function onTrue(val: boolean) { + if (val) { + toast.success("Sukses! Data tersimpan"); + } + setValModal(false) } + return ( - + openModal.set(true)} + onClick={() => setValModal(true)} > Simpan - openModal.set(false)} - description="Apakah Anda Ingin Mengganti - Status Aktivasi Data?" - onYes={onTrue} /> + setValModal(false)} + description="Apakah Anda yakin ingin + melakukan perubahan data?" + onYes={(val) => { onTrue(val) }} /> ) } diff --git a/src/module/user/profile/component/ui/header_edit_profile.tsx b/src/module/user/profile/component/ui/header_edit_profile.tsx index c357a5f..c41217b 100644 --- a/src/module/user/profile/component/ui/header_edit_profile.tsx +++ b/src/module/user/profile/component/ui/header_edit_profile.tsx @@ -1,21 +1,11 @@ 'use client' -import { LayoutIconBack, LayoutNavbarHome } from '@/module/_global'; +import { LayoutIconBack, LayoutNavbarHome, LayoutNavbarNew } from '@/module/_global'; import { Box, Grid, Text } from '@mantine/core'; import React from 'react'; export default function HeaderEditProfile() { return ( - - - - - - - EDIT PROFIL - - - - + ); } diff --git a/src/module/user/profile/component/ui/ui_profile.tsx b/src/module/user/profile/component/ui/ui_profile.tsx index 839487a..a1f4397 100644 --- a/src/module/user/profile/component/ui/ui_profile.tsx +++ b/src/module/user/profile/component/ui/ui_profile.tsx @@ -8,7 +8,7 @@ export function InfoTitleProfile() { return ( Informasi - router.push('/profile/edit')}>Edit + router.push('/profile/edit')}>Edit ) } \ No newline at end of file diff --git a/src/module/user/profile/view/view_profile.tsx b/src/module/user/profile/view/view_profile.tsx index 437959b..40fe47d 100644 --- a/src/module/user/profile/view/view_profile.tsx +++ b/src/module/user/profile/view/view_profile.tsx @@ -13,9 +13,9 @@ export default function ViewProfile() { - + {/* - + */}