diff --git a/app/[locale]/(admin)/admin/settings/tenant/component/columns.tsx b/app/[locale]/(admin)/admin/settings/tenant/component/columns.tsx index 44a277d..87b645d 100644 --- a/app/[locale]/(admin)/admin/settings/tenant/component/columns.tsx +++ b/app/[locale]/(admin)/admin/settings/tenant/component/columns.tsx @@ -19,6 +19,7 @@ import { error } from "@/lib/swal"; import Swal from "sweetalert2"; import withReactContent from "sweetalert2-react-content"; import Link from "next/link"; +import { deleteUserLevel } from "@/service/tenant"; const useTableColumns = () => { const MySwal = withReactContent(Swal); @@ -38,7 +39,7 @@ const useTableColumns = () => { ), }, - { + { accessorKey: "aliasName", header: "Name", cell: ({ row }) => ( @@ -64,7 +65,7 @@ const useTableColumns = () => { ), }, - { + { accessorKey: "parentLevelName", header: "Parent Level", cell: ({ row }) => ( @@ -185,19 +186,16 @@ const useTableColumns = () => { const router = useRouter(); const MySwal = withReactContent(Swal); - async function doDelete(id: any) { - const data = { id }; - const response = await deleteMedia(data); + async function doDelete(id: number) { + const response = await deleteUserLevel(id); if (response?.error) { - error(response.message); - return false; + error(response.message || "Gagal menghapus data"); + return; } - success(); - } - function success() { MySwal.fire({ title: "Sukses", + text: "User Level berhasil dihapus.", icon: "success", confirmButtonColor: "#3085d6", confirmButtonText: "OK", @@ -208,6 +206,23 @@ const useTableColumns = () => { }); } + const handleDelete = (id: number) => { + MySwal.fire({ + title: "Yakin ingin menghapus?", + text: "Data ini tidak dapat dikembalikan!", + icon: "warning", + showCancelButton: true, + confirmButtonText: "Ya, hapus", + cancelButtonText: "Batal", + confirmButtonColor: "#d33", + cancelButtonColor: "#3085d6", + }).then((result) => { + if (result.isConfirmed) { + doDelete(id); + } + }); + }; + const handleDeleteMedia = (id: any) => { MySwal.fire({ title: "Hapus Data", @@ -230,7 +245,9 @@ const useTableColumns = () => { React.useEffect(() => { if (userLevelId !== undefined && roleId !== undefined) { - setIsMabesApprover(Number(userLevelId) === 216 && Number(roleId) === 3); + setIsMabesApprover( + Number(userLevelId) === 216 && Number(roleId) === 3 + ); } }, [userLevelId, roleId]); @@ -246,22 +263,22 @@ const useTableColumns = () => { - View - + */} {/* {(Number(row.original.uploadedById) === Number(userId) || isMabesApprover) && ( */} - - - - Edit - - + + + + Edit + + {/* )} */} handleDeleteMedia(row.original.id)} diff --git a/app/[locale]/(admin)/admin/settings/tenant/detail/[id]/page.tsx b/app/[locale]/(admin)/admin/settings/tenant/detail/[id]/page.tsx new file mode 100644 index 0000000..983ebb8 --- /dev/null +++ b/app/[locale]/(admin)/admin/settings/tenant/detail/[id]/page.tsx @@ -0,0 +1,9 @@ +import React from 'react' + +const page = () => { + return ( +
page
+ ) +} + +export default page \ No newline at end of file diff --git a/app/[locale]/(admin)/admin/settings/tenant/update/[id]/page.tsx b/app/[locale]/(admin)/admin/settings/tenant/update/[id]/page.tsx new file mode 100644 index 0000000..983ebb8 --- /dev/null +++ b/app/[locale]/(admin)/admin/settings/tenant/update/[id]/page.tsx @@ -0,0 +1,9 @@ +import React from 'react' + +const page = () => { + return ( +
page
+ ) +} + +export default page \ No newline at end of file diff --git a/components/form/tenant/tenant-detail-form.tsx b/components/form/tenant/tenant-detail-form.tsx new file mode 100644 index 0000000..d3de439 --- /dev/null +++ b/components/form/tenant/tenant-detail-form.tsx @@ -0,0 +1,9 @@ +import React from 'react' + +const TenantDetailForm = () => { + return ( +
TenantDetailForm
+ ) +} + +export default TenantDetailForm \ No newline at end of file diff --git a/components/form/tenant/tenant-update-form.tsx b/components/form/tenant/tenant-update-form.tsx new file mode 100644 index 0000000..9073bc2 --- /dev/null +++ b/components/form/tenant/tenant-update-form.tsx @@ -0,0 +1,9 @@ +import React from 'react' + +const TenantUpdateForm = () => { + return ( +
TenantUpdateForm
+ ) +} + +export default TenantUpdateForm \ No newline at end of file diff --git a/components/landing-page/navbar.tsx b/components/landing-page/navbar.tsx index bb9b32b..6c8ee53 100644 --- a/components/landing-page/navbar.tsx +++ b/components/landing-page/navbar.tsx @@ -36,10 +36,9 @@ export default function Navbar() { const [isDropdownOpen, setDropdownOpen] = useState(false); const [showProfileMenu, setShowProfileMenu] = useState(false); + const [isLoggedIn, setIsLoggedIn] = useState(false); const pathname = usePathname(); - - // useEffect(() => { // const roleId = getCookiesDecrypt("urie"); // console.log("roleId", roleId); @@ -81,24 +80,64 @@ export default function Navbar() { // } // }, []); - const roleId = getCookiesDecrypt("urie"); - const isLoggedIn = roleId !== null; + // const roleId = getCookiesDecrypt("urie"); + // const isLoggedIn = roleId !== null; + // 🔍 Fungsi untuk mengecek apakah user sedang login + const checkLoginStatus = () => { + const roleId = getCookiesDecrypt("urie"); + const fullname = Cookies.get("ufne"); + return roleId && fullname ? true : false; + }; + + // 🔄 Cek status login saat pertama kali load + useEffect(() => { + setIsLoggedIn(checkLoginStatus()); + }, []); + + // const filteredNavItems = isLoggedIn + // ? NAV_ITEMS.filter((item) => item.label !== "Mengikuti") + // : NAV_ITEMS; + + // 🔁 Gunakan isLoggedIn untuk menentukan navigasi const filteredNavItems = isLoggedIn ? NAV_ITEMS.filter((item) => item.label !== "Mengikuti") : NAV_ITEMS; + // 🚪 Fungsi logout const handleLogout = () => { + // Hapus semua cookie dengan kemungkinan variasi path dan domain Object.keys(Cookies.get()).forEach((cookieName) => { - Cookies.remove(cookieName); + Cookies.remove(cookieName, { path: "/" }); + Cookies.remove(cookieName, { + path: "", + domain: window.location.hostname, + }); + Cookies.remove(cookieName, { + path: "/", + domain: window.location.hostname, + }); }); - window.location.href = "/"; - - // setUser(null); + // Ubah state login jadi false agar tampilan langsung berubah + setIsLoggedIn(false); setShowProfileMenu(false); + + // Redirect ke homepage + window.location.href = "/"; }; + // const handleLogout = () => { + // Object.keys(Cookies.get()).forEach((cookieName) => { + // Cookies.remove(cookieName); + // }); + + // window.location.href = "/"; + + // // setUser(null); + // setShowProfileMenu(false); + // }; + const username = Cookies.get("username"); const fullname = Cookies.get("ufne"); // const router = useRouter(); @@ -215,8 +254,8 @@ export default function Navbar() { >