Fix QC Kak Inno Admin, Fix QC Keano UI User, Fix QC Pak jun tabel apbdes
This commit is contained in:
@@ -66,7 +66,7 @@ function Page() {
|
||||
</Container>
|
||||
|
||||
{/* Tabs Menu */}
|
||||
<Tabs color={colors['blue-button']} variant="pills" defaultValue="semua">
|
||||
<Tabs color={colors['blue-button']} variant="pills" value="semua">
|
||||
<Box px={{ base: "md", md: 100 }} py="md" bg={colors['BG-trans']} >
|
||||
<Grid>
|
||||
<GridCol span={{ base: 12, md: 9, lg: 8, xl: 9 }}>
|
||||
|
||||
@@ -8,76 +8,59 @@ import { useEffect, useState } from 'react';
|
||||
import BackButton from '../../layanan/_com/BackButto';
|
||||
import type { SearchBarProps } from './searchBar';
|
||||
|
||||
// Define tabs outside the component to ensure consistency between server and client
|
||||
// ✅ Definisikan tabs di luar komponen (statis, aman untuk SSR)
|
||||
const TABS = [
|
||||
{
|
||||
label: "Foto",
|
||||
value: "foto",
|
||||
href: "/darmasaba/desa/galery/foto",
|
||||
},
|
||||
{
|
||||
label: "Video",
|
||||
value: "video",
|
||||
href: "/darmasaba/desa/galery/video",
|
||||
},
|
||||
{ label: 'Foto', value: 'foto', href: '/darmasaba/desa/galery/foto' },
|
||||
{ label: 'Video', value: 'video', href: '/darmasaba/desa/galery/video' },
|
||||
] as const;
|
||||
|
||||
const SearchBar = dynamic<SearchBarProps>(
|
||||
() => import('./searchBar').then(mod => mod.SearchBar),
|
||||
() => import('./searchBar').then((mod) => mod.SearchBar),
|
||||
{ ssr: false }
|
||||
);
|
||||
|
||||
type HeaderSearchProps = {
|
||||
type LayoutTabsGaleryProps = {
|
||||
children?: React.ReactNode;
|
||||
};
|
||||
|
||||
function LayoutTabsGalery({ children }: HeaderSearchProps) {
|
||||
export default function LayoutTabsGalery({ children }: LayoutTabsGaleryProps) {
|
||||
const router = useRouter();
|
||||
const pathname = usePathname();
|
||||
const [isClient, setIsClient] = useState(false);
|
||||
const [activeTab, setActiveTab] = useState<string>(TABS[0].value);
|
||||
|
||||
// Set default active tab to empty string to prevent hydration mismatch
|
||||
const [activeTab, setActiveTab] = useState('');
|
||||
|
||||
// Set client flag on mount
|
||||
// 🧠 Update tab aktif berdasarkan URL
|
||||
useEffect(() => {
|
||||
setIsClient(true);
|
||||
}, []);
|
||||
|
||||
// Update active tab based on current route - only on client side
|
||||
useEffect(() => {
|
||||
if (!isClient) return;
|
||||
|
||||
const currentTab = TABS.find(tab => pathname.includes(tab.value));
|
||||
if (currentTab) {
|
||||
setActiveTab(currentTab.value);
|
||||
} else {
|
||||
// Default to first tab if no match found
|
||||
setActiveTab(TABS[0].value);
|
||||
}
|
||||
}, [pathname, isClient]);
|
||||
const found = TABS.find((tab) => pathname.includes(tab.value));
|
||||
if (found) setActiveTab(found.value);
|
||||
else setActiveTab(TABS[0].value);
|
||||
}, [pathname]);
|
||||
|
||||
// 🖱️ Handle perubahan tab
|
||||
const handleTabChange = (value: string | null) => {
|
||||
if (!value) return;
|
||||
const tab = TABS.find(tab => tab.value === value);
|
||||
if (tab) {
|
||||
// Only update if we're on the client
|
||||
if (typeof window !== 'undefined') {
|
||||
setActiveTab(value);
|
||||
router.push(tab.href);
|
||||
}
|
||||
const selected = TABS.find((tab) => tab.value === value);
|
||||
if (selected) {
|
||||
setActiveTab(selected.value);
|
||||
router.push(selected.href);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<Stack pos="relative" bg={colors.Bg} py="xl" gap="22">
|
||||
{/* Header */}
|
||||
<Box px={{ base: "md", md: 100 }}>
|
||||
{/* 🔙 Header */}
|
||||
<Box px={{ base: 'md', md: 100 }}>
|
||||
<BackButton />
|
||||
</Box>
|
||||
<Box px={{ base: "md", md: 100 }}>
|
||||
|
||||
{/* 🏷️ Title & Search */}
|
||||
<Box px={{ base: 'md', md: 100 }}>
|
||||
<Stack align="center" gap="0">
|
||||
<Text fz={{ base: "2rem", md: "3.4rem" }} c={colors["blue-button"]} fw="bold" ta="center">
|
||||
<Text
|
||||
fz={{ base: '2rem', md: '3.4rem' }}
|
||||
c={colors['blue-button']}
|
||||
fw="bold"
|
||||
ta="center"
|
||||
>
|
||||
Galeri Kegiatan Desa Darmasaba
|
||||
</Text>
|
||||
</Stack>
|
||||
@@ -86,35 +69,26 @@ function LayoutTabsGalery({ children }: HeaderSearchProps) {
|
||||
</Box>
|
||||
</Box>
|
||||
|
||||
{/* 🗂️ Tabs Section */}
|
||||
<Tabs
|
||||
value={isClient ? activeTab : undefined}
|
||||
defaultValue={TABS[0].value}
|
||||
value={activeTab}
|
||||
onChange={handleTabChange}
|
||||
color={colors['blue-button']}
|
||||
variant="pills"
|
||||
keepMounted={false}
|
||||
>
|
||||
<Box px={{ base: "md", md: 100 }} py="md" bg={colors['BG-trans']}>
|
||||
<Box px={{ base: 'md', md: 100 }} py="md" bg={colors['BG-trans']}>
|
||||
<TabsList>
|
||||
{TABS.map((tab) => (
|
||||
<TabsTab
|
||||
key={tab.value}
|
||||
value={tab.value}
|
||||
component="button"
|
||||
type="button"
|
||||
>
|
||||
<TabsTab key={tab.value} value={tab.value}>
|
||||
{tab.label}
|
||||
</TabsTab>
|
||||
))}
|
||||
</TabsList>
|
||||
</Box>
|
||||
|
||||
<Container size={'xl'}>
|
||||
{children}
|
||||
</Container>
|
||||
<Container size="xl">{children}</Container>
|
||||
</Tabs>
|
||||
</Stack>
|
||||
);
|
||||
}
|
||||
|
||||
export default LayoutTabsGalery;
|
||||
@@ -166,7 +166,7 @@ function PengaduanMasyarakat() {
|
||||
}}
|
||||
onReject={() => toast.error('File tidak valid.')}
|
||||
maxSize={5 * 1024 ** 2} // Maks 5MB
|
||||
accept={{ 'image/*': [] }}
|
||||
accept={{ 'image/*': ['.jpeg', '.jpg', '.png', '.webp'] }}
|
||||
>
|
||||
<Group justify="center" gap="xl" mih={220} style={{ pointerEvents: 'none' }}>
|
||||
<Dropzone.Accept>
|
||||
|
||||
@@ -195,7 +195,7 @@ function Page() {
|
||||
>
|
||||
<Stack gap="md">
|
||||
<TextInput
|
||||
defaultValue={stateLaporan.create.form.judul}
|
||||
value={stateLaporan.create.form.judul}
|
||||
onChange={(e) => (stateLaporan.create.form.judul = e.target.value)}
|
||||
label={<Text fw="bold" fz="sm">Judul Laporan Publik</Text>}
|
||||
placeholder="Masukkan judul laporan publik"
|
||||
@@ -203,7 +203,7 @@ function Page() {
|
||||
/>
|
||||
|
||||
<TextInput
|
||||
defaultValue={stateLaporan.create.form.lokasi}
|
||||
value={stateLaporan.create.form.lokasi}
|
||||
onChange={(e) => (stateLaporan.create.form.lokasi = e.target.value)}
|
||||
label={<Text fw="bold" fz="sm">Lokasi Laporan Publik</Text>}
|
||||
placeholder="Masukkan lokasi laporan publik"
|
||||
@@ -212,7 +212,7 @@ function Page() {
|
||||
|
||||
<DateTimePicker
|
||||
label={<Text fw="bold" fz="sm">Tanggal Laporan Publik</Text>}
|
||||
defaultValue={
|
||||
value={
|
||||
stateLaporan.create.form.tanggalWaktu
|
||||
? new Date(stateLaporan.create.form.tanggalWaktu)
|
||||
: null
|
||||
|
||||
@@ -333,7 +333,7 @@ const state = useProxy(indeksKepuasanState.responden);
|
||||
label="Nama"
|
||||
type='text'
|
||||
placeholder="Masukkan nama"
|
||||
defaultValue={state.create.form.name}
|
||||
value={state.create.form.name}
|
||||
onChange={(val) => {
|
||||
state.create.form.name = val.currentTarget.value;
|
||||
}}
|
||||
@@ -342,7 +342,7 @@ const state = useProxy(indeksKepuasanState.responden);
|
||||
label="Tanggal"
|
||||
type="date"
|
||||
placeholder="masukkan tanggal"
|
||||
defaultValue={state.create.form.tanggal}
|
||||
value={state.create.form.tanggal}
|
||||
onChange={(val) => {
|
||||
state.create.form.tanggal = val.currentTarget.value;
|
||||
}}
|
||||
@@ -351,7 +351,7 @@ const state = useProxy(indeksKepuasanState.responden);
|
||||
key={"jenisKelamin"}
|
||||
label={"Jenis Kelamin"}
|
||||
placeholder={indeksKepuasanState.jenisKelaminResponden.findMany.loading ? 'Memuat...' : 'Pilih jenis kelamin'}
|
||||
defaultValue={state.create.form.jenisKelaminId || ""}
|
||||
value={state.create.form.jenisKelaminId || ""}
|
||||
onChange={(val) => {
|
||||
state.create.form.jenisKelaminId = val ?? "";
|
||||
}}
|
||||
@@ -369,7 +369,7 @@ const state = useProxy(indeksKepuasanState.responden);
|
||||
key={"rating_responden"}
|
||||
label={"Rating"}
|
||||
placeholder={indeksKepuasanState.pilihanRatingResponden.findMany.loading ? 'Memuat...' : 'Pilih rating'}
|
||||
defaultValue={state.create.form.ratingId || ""}
|
||||
value={state.create.form.ratingId || ""}
|
||||
onChange={(val) => {
|
||||
state.create.form.ratingId = val ?? "";
|
||||
}}
|
||||
@@ -387,7 +387,7 @@ const state = useProxy(indeksKepuasanState.responden);
|
||||
key={"kelompokUmur"}
|
||||
label={"Kelompok Umur"}
|
||||
placeholder={indeksKepuasanState.kelompokUmurResponden.findMany.loading ? 'Memuat...' : 'Pilih kelompok umur'}
|
||||
defaultValue={state.create.form.kelompokUmurId || ""}
|
||||
value={state.create.form.kelompokUmurId || ""}
|
||||
onChange={(val) => {
|
||||
state.create.form.kelompokUmurId = val ?? "";
|
||||
}}
|
||||
@@ -599,7 +599,7 @@ const state = useProxy(indeksKepuasanState.responden);
|
||||
label="Nama"
|
||||
type='text'
|
||||
placeholder="masukkan nama"
|
||||
defaultValue={state.create.form.name}
|
||||
value={state.create.form.name}
|
||||
onChange={(val) => {
|
||||
state.create.form.name = val.currentTarget.value;
|
||||
}}
|
||||
@@ -608,7 +608,7 @@ const state = useProxy(indeksKepuasanState.responden);
|
||||
label="Tanggal Pengisian"
|
||||
type="date"
|
||||
placeholder="masukkan tanggal"
|
||||
defaultValue={state.create.form.tanggal}
|
||||
value={state.create.form.tanggal}
|
||||
onChange={(val) => {
|
||||
state.create.form.tanggal = val.currentTarget.value;
|
||||
}}
|
||||
@@ -617,7 +617,7 @@ const state = useProxy(indeksKepuasanState.responden);
|
||||
key={"jenisKelamin"}
|
||||
label={"Jenis Kelamin"}
|
||||
placeholder={indeksKepuasanState.jenisKelaminResponden.findMany.loading ? 'Memuat...' : 'Pilih jenis kelamin'}
|
||||
defaultValue={state.create.form.jenisKelaminId || ""}
|
||||
value={state.create.form.jenisKelaminId || ""}
|
||||
onChange={(val) => {
|
||||
state.create.form.jenisKelaminId = val ?? "";
|
||||
}}
|
||||
@@ -635,7 +635,7 @@ const state = useProxy(indeksKepuasanState.responden);
|
||||
key={"rating_responden"}
|
||||
label={"Rating"}
|
||||
placeholder={indeksKepuasanState.pilihanRatingResponden.findMany.loading ? 'Memuat...' : 'Pilih rating'}
|
||||
defaultValue={state.create.form.ratingId || ""}
|
||||
value={state.create.form.ratingId || ""}
|
||||
onChange={(val) => {
|
||||
state.create.form.ratingId = val ?? "";
|
||||
}}
|
||||
@@ -653,7 +653,7 @@ const state = useProxy(indeksKepuasanState.responden);
|
||||
key={"kelompokUmur"}
|
||||
label={"Kelompok Umur"}
|
||||
placeholder={indeksKepuasanState.kelompokUmurResponden.findMany.loading ? 'Memuat...' : 'Pilih kelompok umur'}
|
||||
defaultValue={state.create.form.kelompokUmurId || ""}
|
||||
value={state.create.form.kelompokUmurId || ""}
|
||||
onChange={(val) => {
|
||||
state.create.form.kelompokUmurId = val ?? "";
|
||||
}}
|
||||
|
||||
Reference in New Issue
Block a user