From f1ee53a7b970ee4cf98fbd51c1658863d892a68d Mon Sep 17 00:00:00 2001 From: nico Date: Tue, 5 May 2026 12:26:18 +0800 Subject: [PATCH] fix(kesehatan): konsolidasi balita, ibu-hamil, ringkasan-kesehatan ke dalam posyandu tabs + fix semua routing path - bump 0.1.53 Co-Authored-By: Claude Sonnet 4.6 --- package.json | 2 +- .../kesehatan/posyandu/_com/layoutTabs.tsx | 161 ++++++++++++++++++ .../{ => posyandu}/balita/create/page.tsx | 5 +- .../{ => posyandu}/balita/edit/[id]/page.tsx | 5 +- .../kesehatan/{ => posyandu}/balita/page.tsx | 7 +- .../{ => posyandu}/ibu-hamil/create/page.tsx | 5 +- .../ibu-hamil/edit/[id]/page.tsx | 4 +- .../{ => posyandu}/ibu-hamil/page.tsx | 7 +- .../(dashboard)/kesehatan/posyandu/layout.tsx | 35 ++++ .../{ => list-posyandu}/[id]/edit/page.tsx | 5 +- .../{ => list-posyandu}/[id]/page.tsx | 11 +- .../{ => list-posyandu}/create/page.tsx | 7 +- .../posyandu/{ => list-posyandu}/page.tsx | 22 +-- .../ringkasan-kesehatan/page.tsx | 7 +- src/app/admin/_com/list_PageAdmin.tsx | 53 +----- 15 files changed, 248 insertions(+), 88 deletions(-) create mode 100644 src/app/admin/(dashboard)/kesehatan/posyandu/_com/layoutTabs.tsx rename src/app/admin/(dashboard)/kesehatan/{ => posyandu}/balita/create/page.tsx (97%) rename src/app/admin/(dashboard)/kesehatan/{ => posyandu}/balita/edit/[id]/page.tsx (97%) rename src/app/admin/(dashboard)/kesehatan/{ => posyandu}/balita/page.tsx (95%) rename src/app/admin/(dashboard)/kesehatan/{ => posyandu}/ibu-hamil/create/page.tsx (96%) rename src/app/admin/(dashboard)/kesehatan/{ => posyandu}/ibu-hamil/edit/[id]/page.tsx (96%) rename src/app/admin/(dashboard)/kesehatan/{ => posyandu}/ibu-hamil/page.tsx (95%) create mode 100644 src/app/admin/(dashboard)/kesehatan/posyandu/layout.tsx rename src/app/admin/(dashboard)/kesehatan/posyandu/{ => list-posyandu}/[id]/edit/page.tsx (98%) rename src/app/admin/(dashboard)/kesehatan/posyandu/{ => list-posyandu}/[id]/page.tsx (93%) rename src/app/admin/(dashboard)/kesehatan/posyandu/{ => list-posyandu}/create/page.tsx (97%) rename src/app/admin/(dashboard)/kesehatan/posyandu/{ => list-posyandu}/page.tsx (94%) rename src/app/admin/(dashboard)/kesehatan/{ => posyandu}/ringkasan-kesehatan/page.tsx (95%) diff --git a/package.json b/package.json index 95ff8a01..5b708480 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "desa-darmasaba", - "version": "0.1.52", + "version": "0.1.53", "private": true, "scripts": { "dev": "next dev", diff --git a/src/app/admin/(dashboard)/kesehatan/posyandu/_com/layoutTabs.tsx b/src/app/admin/(dashboard)/kesehatan/posyandu/_com/layoutTabs.tsx new file mode 100644 index 00000000..7f317cdf --- /dev/null +++ b/src/app/admin/(dashboard)/kesehatan/posyandu/_com/layoutTabs.tsx @@ -0,0 +1,161 @@ +/* eslint-disable react-hooks/exhaustive-deps */ +'use client' +import colors from '@/con/colors'; +import { Box, ScrollArea, Stack, Tabs, TabsList, TabsPanel, TabsTab, Title } from '@mantine/core'; +import { IconBabyCarriage, IconCategory, IconClipboard, IconClipboardText, IconGenderDemigirl, IconNews } from '@tabler/icons-react'; +import { usePathname, useRouter } from 'next/navigation'; +import React, { useEffect, useState } from 'react'; + +function LayoutTabsPosyandu({ children }: { children: React.ReactNode }) { + const router = useRouter(); + const pathname = usePathname(); + + const tabs = [ + { + label: "List Posyandu", + value: "list_posyandu", + href: "/admin/kesehatan/posyandu/list-posyandu", + icon: + }, + { + label: "Balita", + value: "balita", + href: "/admin/kesehatan/posyandu/balita", + icon: + }, + { + label: "Ibu Hamil", + value: "ibu_hamil", + href: "/admin/kesehatan/posyandu/ibu-hamil", + icon: + }, + { + label: "Ringkasan Kesehatan", + value: "ringkasan_kesehatan", + href: "/admin/kesehatan/posyandu/ringkasan-kesehatan", + icon: + } + ]; + + const currentTab = tabs.find(tab => tab.href === pathname) + const [activeTab, setActiveTab] = useState(currentTab?.value || tabs[0].value); + + const handleTabChange = (value: string | null) => { + const tab = tabs.find(t => t.value === value) + if (tab) { + router.push(tab.href) + } + setActiveTab(value) + } + + useEffect(() => { + const match = tabs.find(tab => tab.href === pathname) + if (match) { + setActiveTab(match.value) + } + }, [pathname]) + + return ( + + Layanan + + {/* ✅ Scroll horizontal wrapper */} + + + + {tabs.map((tab, i) => ( + + {tab.label} + + ))} + + + + + + + + + {tabs.map((tab, i) => ( + + {tab.label} + + ))} + + + + + {tabs.map((tab, i) => ( + + {/* Konten dummy, bisa diganti sesuai routing */} + <>{children} + + ))} + + + ); +} + +export default LayoutTabsPosyandu; diff --git a/src/app/admin/(dashboard)/kesehatan/balita/create/page.tsx b/src/app/admin/(dashboard)/kesehatan/posyandu/balita/create/page.tsx similarity index 97% rename from src/app/admin/(dashboard)/kesehatan/balita/create/page.tsx rename to src/app/admin/(dashboard)/kesehatan/posyandu/balita/create/page.tsx index 480f41f8..cdb365c5 100644 --- a/src/app/admin/(dashboard)/kesehatan/balita/create/page.tsx +++ b/src/app/admin/(dashboard)/kesehatan/posyandu/balita/create/page.tsx @@ -1,5 +1,6 @@ 'use client'; +import balitaState from '@/app/admin/(dashboard)/_state/kesehatan/balita/balita'; import colors from '@/con/colors'; import { Box, @@ -19,7 +20,7 @@ import { import { IconArrowBack } from '@tabler/icons-react'; import { useRouter } from 'next/navigation'; import { useProxy } from 'valtio/utils'; -import balitaState from '../../../_state/kesehatan/balita/balita'; + export default function BalitaCreatePage() { const router = useRouter(); @@ -30,7 +31,7 @@ export default function BalitaCreatePage() { const ok = await balitaState.create.submit(); if (ok) { balitaState.create.reset(); - router.push('/admin/kesehatan/balita'); + router.push('/admin/kesehatan/posyandu/balita'); } }; diff --git a/src/app/admin/(dashboard)/kesehatan/balita/edit/[id]/page.tsx b/src/app/admin/(dashboard)/kesehatan/posyandu/balita/edit/[id]/page.tsx similarity index 97% rename from src/app/admin/(dashboard)/kesehatan/balita/edit/[id]/page.tsx rename to src/app/admin/(dashboard)/kesehatan/posyandu/balita/edit/[id]/page.tsx index 5423519e..11674c45 100644 --- a/src/app/admin/(dashboard)/kesehatan/balita/edit/[id]/page.tsx +++ b/src/app/admin/(dashboard)/kesehatan/posyandu/balita/edit/[id]/page.tsx @@ -1,5 +1,6 @@ 'use client'; +import balitaState from '@/app/admin/(dashboard)/_state/kesehatan/balita/balita'; import colors from '@/con/colors'; import { Box, @@ -20,7 +21,7 @@ import { IconArrowBack } from '@tabler/icons-react'; import { useParams, useRouter } from 'next/navigation'; import { useEffect } from 'react'; import { useProxy } from 'valtio/utils'; -import balitaState from '../../../../_state/kesehatan/balita/balita'; + export default function BalitaEditPage() { const router = useRouter(); @@ -35,7 +36,7 @@ export default function BalitaEditPage() { const handleSubmit = async () => { const ok = await balitaState.edit.update(); - if (ok) router.push('/admin/kesehatan/balita'); + if (ok) router.push('/admin/kesehatan/posyandu/balita'); }; return ( diff --git a/src/app/admin/(dashboard)/kesehatan/balita/page.tsx b/src/app/admin/(dashboard)/kesehatan/posyandu/balita/page.tsx similarity index 95% rename from src/app/admin/(dashboard)/kesehatan/balita/page.tsx rename to src/app/admin/(dashboard)/kesehatan/posyandu/balita/page.tsx index 5de9bc7b..029efd2e 100644 --- a/src/app/admin/(dashboard)/kesehatan/balita/page.tsx +++ b/src/app/admin/(dashboard)/kesehatan/posyandu/balita/page.tsx @@ -20,7 +20,8 @@ import { IconEdit, IconPlus, IconSearch, IconTrash } from '@tabler/icons-react'; import { useRouter } from 'next/navigation'; import { useEffect, useState } from 'react'; import { useProxy } from 'valtio/utils'; -import balitaState from '../../_state/kesehatan/balita/balita'; +import balitaState from '../../../_state/kesehatan/balita/balita'; + const STUNTING_COLORS: Record = { NORMAL: 'green', @@ -81,7 +82,7 @@ export default function BalitaPage() { router.push(`/admin/kesehatan/balita/edit/${d.id}`)} + onClick={() => router.push(`/admin/kesehatan/posyandu/balita/edit/${d.id}`)} > @@ -104,7 +105,7 @@ export default function BalitaPage() { Balita Terdaftar {/* Desktop Table */} - - + +
Nama Posyandu @@ -130,7 +132,7 @@ function ListPosyandu({ search }: { search: string }) { variant="light" color="blue" leftSection={} - onClick={() => router.push(`/admin/kesehatan/posyandu/${item.id}`)} + onClick={() => router.push(`/admin/kesehatan/posyandu/list-posyandu/${item.id}`)} > Detail @@ -192,7 +194,7 @@ function ListPosyandu({ search }: { search: string }) { variant="light" color="blue" leftSection={} - onClick={() => router.push(`/admin/kesehatan/posyandu/${item.id}`)} + onClick={() => router.push(`/admin/kesehatan/posyandu/list-posyandu/${item.id}`)} fullWidth > Detail diff --git a/src/app/admin/(dashboard)/kesehatan/ringkasan-kesehatan/page.tsx b/src/app/admin/(dashboard)/kesehatan/posyandu/ringkasan-kesehatan/page.tsx similarity index 95% rename from src/app/admin/(dashboard)/kesehatan/ringkasan-kesehatan/page.tsx rename to src/app/admin/(dashboard)/kesehatan/posyandu/ringkasan-kesehatan/page.tsx index 7953dffe..afab982f 100644 --- a/src/app/admin/(dashboard)/kesehatan/ringkasan-kesehatan/page.tsx +++ b/src/app/admin/(dashboard)/kesehatan/posyandu/ringkasan-kesehatan/page.tsx @@ -26,7 +26,8 @@ import { import { useRouter } from 'next/navigation'; import { useEffect, useCallback } from 'react'; import { useProxy } from 'valtio/utils'; -import ringkasanKesehatanState from '../../_state/kesehatan/ringkasan-kesehatan/ringkasanKesehatan'; +import ringkasanKesehatanState from '../../../_state/kesehatan/ringkasan-kesehatan/ringkasanKesehatan'; + type StatCardProps = { label: string; @@ -197,7 +198,7 @@ export default function RingkasanKesehatanPage() { color="pink" radius="md" rightSection={} - onClick={() => router.push('/admin/kesehatan/ibu-hamil')} + onClick={() => router.push('/admin/kesehatan/posyandu/ibu-hamil')} > Kelola Ibu Hamil @@ -206,7 +207,7 @@ export default function RingkasanKesehatanPage() { color="blue" radius="md" rightSection={} - onClick={() => router.push('/admin/kesehatan/balita')} + onClick={() => router.push('/admin/kesehatan/posyandu/balita')} > Kelola Balita diff --git a/src/app/admin/_com/list_PageAdmin.tsx b/src/app/admin/_com/list_PageAdmin.tsx index 5c5541e4..7b9ab159 100644 --- a/src/app/admin/_com/list_PageAdmin.tsx +++ b/src/app/admin/_com/list_PageAdmin.tsx @@ -135,7 +135,7 @@ export const devBar = [ { id: "Kesehatan_1", name: "Posyandu", - path: "/admin/kesehatan/posyandu" + path: "/admin/kesehatan/posyandu/list-posyandu" }, { id: "Kesehatan_2", @@ -166,21 +166,6 @@ export const devBar = [ id: "Kesehatan_7", name: "Info Wabah/Penyakit", path: "/admin/kesehatan/info-wabah-penyakit" - }, - { - id: "Kesehatan_8", - name: "Ringkasan Kesehatan", - path: "/admin/kesehatan/ringkasan-kesehatan" - }, - { - id: "Kesehatan_9", - name: "Ibu Hamil", - path: "/admin/kesehatan/ibu-hamil" - }, - { - id: "Kesehatan_10", - name: "Balita", - path: "/admin/kesehatan/balita" } ] }, @@ -586,7 +571,7 @@ export const navBar = [ { id: "Kesehatan_1", name: "Posyandu", - path: "/admin/kesehatan/posyandu" + path: "/admin/kesehatan/posyandu/list-posyandu/list_posyandu" }, { id: "Kesehatan_2", @@ -617,21 +602,6 @@ export const navBar = [ id: "Kesehatan_7", name: "Info Wabah/Penyakit", path: "/admin/kesehatan/info-wabah-penyakit" - }, - { - id: "Kesehatan_8", - name: "Ringkasan Kesehatan", - path: "/admin/kesehatan/ringkasan-kesehatan" - }, - { - id: "Kesehatan_9", - name: "Ibu Hamil", - path: "/admin/kesehatan/ibu-hamil" - }, - { - id: "Kesehatan_10", - name: "Balita", - path: "/admin/kesehatan/balita" } ] }, @@ -1228,7 +1198,7 @@ export const role1 = [ } ] }, - { + { id: "Kependudukan", name: "Kependudukan", path: "", @@ -1271,7 +1241,7 @@ export const role2 = [ { id: "Kesehatan_1", name: "Posyandu", - path: "/admin/kesehatan/posyandu" + path: "/admin/kesehatan/posyandu/list-posyandu/list_posyandu" }, { id: "Kesehatan_2", @@ -1302,21 +1272,6 @@ export const role2 = [ id: "Kesehatan_7", name: "Info Wabah/Penyakit", path: "/admin/kesehatan/info-wabah-penyakit" - }, - { - id: "Kesehatan_8", - name: "Ringkasan Kesehatan", - path: "/admin/kesehatan/ringkasan-kesehatan" - }, - { - id: "Kesehatan_9", - name: "Ibu Hamil", - path: "/admin/kesehatan/ibu-hamil" - }, - { - id: "Kesehatan_10", - name: "Balita", - path: "/admin/kesehatan/balita" } ] },