feat: show isDummy flag on village detail and list pages
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
import { AreaChart } from '@mantine/charts'
|
import { AreaChart } from '@mantine/charts'
|
||||||
import {
|
import {
|
||||||
|
Badge,
|
||||||
Box,
|
Box,
|
||||||
Button,
|
Button,
|
||||||
Card,
|
Card,
|
||||||
@@ -10,6 +11,7 @@ import {
|
|||||||
SegmentedControl,
|
SegmentedControl,
|
||||||
SimpleGrid,
|
SimpleGrid,
|
||||||
Stack,
|
Stack,
|
||||||
|
Switch,
|
||||||
Text,
|
Text,
|
||||||
Textarea,
|
Textarea,
|
||||||
TextInput,
|
TextInput,
|
||||||
@@ -31,6 +33,7 @@ import {
|
|||||||
TbLayoutKanban,
|
TbLayoutKanban,
|
||||||
TbMapPin,
|
TbMapPin,
|
||||||
TbPower,
|
TbPower,
|
||||||
|
TbTestPipe,
|
||||||
TbUser,
|
TbUser,
|
||||||
TbUsers,
|
TbUsers,
|
||||||
TbUsersGroup,
|
TbUsersGroup,
|
||||||
@@ -153,7 +156,7 @@ function VillageDetailPage() {
|
|||||||
const [editModalOpened, { open: openEditModal, close: closeEditModal }] = useDisclosure(false)
|
const [editModalOpened, { open: openEditModal, close: closeEditModal }] = useDisclosure(false)
|
||||||
const [isUpdating, setIsUpdating] = useState(false)
|
const [isUpdating, setIsUpdating] = useState(false)
|
||||||
const [isEditing, setIsEditing] = useState(false)
|
const [isEditing, setIsEditing] = useState(false)
|
||||||
const [editForm, setEditForm] = useState({ name: '', desc: '' })
|
const [editForm, setEditForm] = useState({ name: '', desc: '', isDummy: false })
|
||||||
|
|
||||||
const village = infoRes?.data
|
const village = infoRes?.data
|
||||||
const stats = gridRes?.data
|
const stats = gridRes?.data
|
||||||
@@ -161,7 +164,8 @@ function VillageDetailPage() {
|
|||||||
const openEdit = () => {
|
const openEdit = () => {
|
||||||
setEditForm({
|
setEditForm({
|
||||||
name: village?.name || '',
|
name: village?.name || '',
|
||||||
desc: village?.desc || ''
|
desc: village?.desc || '',
|
||||||
|
isDummy: village?.isDummy ?? false,
|
||||||
})
|
})
|
||||||
openEditModal()
|
openEditModal()
|
||||||
}
|
}
|
||||||
@@ -188,7 +192,8 @@ function VillageDetailPage() {
|
|||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
id: village.id,
|
id: village.id,
|
||||||
name: editForm.name,
|
name: editForm.name,
|
||||||
desc: editForm.desc
|
desc: editForm.desc,
|
||||||
|
isDummy: editForm.isDummy,
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -361,7 +366,20 @@ function VillageDetailPage() {
|
|||||||
</ThemeIcon>
|
</ThemeIcon>
|
||||||
|
|
||||||
<Stack gap={6}>
|
<Stack gap={6}>
|
||||||
<Title order={2} style={{ color: 'white', lineHeight: 1.1 }}>{village.name}</Title>
|
<Group gap="xs" align="center">
|
||||||
|
<Title order={2} style={{ color: 'white', lineHeight: 1.1 }}>{village.name}</Title>
|
||||||
|
{village.isDummy && (
|
||||||
|
<Badge
|
||||||
|
size="sm"
|
||||||
|
variant="light"
|
||||||
|
color="yellow"
|
||||||
|
leftSection={<TbTestPipe size={11} />}
|
||||||
|
style={{ textTransform: 'none' }}
|
||||||
|
>
|
||||||
|
Dummy
|
||||||
|
</Badge>
|
||||||
|
)}
|
||||||
|
</Group>
|
||||||
|
|
||||||
<Group gap={6}>
|
<Group gap={6}>
|
||||||
<TbMapPin size={14} color="rgba(255,255,255,0.8)" />
|
<TbMapPin size={14} color="rgba(255,255,255,0.8)" />
|
||||||
@@ -526,6 +544,12 @@ function VillageDetailPage() {
|
|||||||
value={editForm.desc}
|
value={editForm.desc}
|
||||||
onChange={(e) => setEditForm(prev => ({ ...prev, desc: e.currentTarget.value }))}
|
onChange={(e) => setEditForm(prev => ({ ...prev, desc: e.currentTarget.value }))}
|
||||||
/>
|
/>
|
||||||
|
<Switch
|
||||||
|
label="Dummy Village"
|
||||||
|
description="Tandai desa ini sebagai data dummy"
|
||||||
|
checked={editForm.isDummy}
|
||||||
|
onChange={(e) => setEditForm(prev => ({ ...prev, isDummy: e.currentTarget.checked }))}
|
||||||
|
/>
|
||||||
<Group justify="flex-end" gap="sm" mt="md">
|
<Group justify="flex-end" gap="sm" mt="md">
|
||||||
<Button variant="light" color="gray" onClick={closeEditModal} radius="md">
|
<Button variant="light" color="gray" onClick={closeEditModal} radius="md">
|
||||||
Cancel
|
Cancel
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ import {
|
|||||||
TbMapPin,
|
TbMapPin,
|
||||||
TbPlus,
|
TbPlus,
|
||||||
TbSearch,
|
TbSearch,
|
||||||
|
TbTestPipe,
|
||||||
TbUser,
|
TbUser,
|
||||||
TbX,
|
TbX,
|
||||||
} from 'react-icons/tb'
|
} from 'react-icons/tb'
|
||||||
@@ -50,6 +51,7 @@ interface APIVillage {
|
|||||||
id: string
|
id: string
|
||||||
name: string
|
name: string
|
||||||
isActive: boolean
|
isActive: boolean
|
||||||
|
isDummy: boolean
|
||||||
createdAt: string
|
createdAt: string
|
||||||
perbekel: string | null
|
perbekel: string | null
|
||||||
}
|
}
|
||||||
@@ -95,9 +97,16 @@ function VillageGridCard({ village, onClick }: { village: APIVillage; onClick: (
|
|||||||
>
|
>
|
||||||
<TbHome2 size={22} />
|
<TbHome2 size={22} />
|
||||||
</ThemeIcon>
|
</ThemeIcon>
|
||||||
<Badge color={cfg.color} variant="light" radius="sm" size="sm">
|
<Group gap={6}>
|
||||||
{cfg.label}
|
{village.isDummy && (
|
||||||
</Badge>
|
<Badge color="yellow" variant="light" radius="sm" size="sm" leftSection={<TbTestPipe size={11} />}>
|
||||||
|
Dummy
|
||||||
|
</Badge>
|
||||||
|
)}
|
||||||
|
<Badge color={cfg.color} variant="light" radius="sm" size="sm">
|
||||||
|
{cfg.label}
|
||||||
|
</Badge>
|
||||||
|
</Group>
|
||||||
</Group>
|
</Group>
|
||||||
|
|
||||||
<Text fw={800} size="lg" mb={2}>
|
<Text fw={800} size="lg" mb={2}>
|
||||||
@@ -175,6 +184,11 @@ function VillageListRow({ village, onClick }: { village: APIVillage; onClick: ()
|
|||||||
<Stack gap={2}>
|
<Stack gap={2}>
|
||||||
<Group gap="sm">
|
<Group gap="sm">
|
||||||
<Text fw={700} size="sm">{village.name}</Text>
|
<Text fw={700} size="sm">{village.name}</Text>
|
||||||
|
{village.isDummy && (
|
||||||
|
<Badge color="yellow" variant="light" radius="sm" size="xs" leftSection={<TbTestPipe size={10} />}>
|
||||||
|
Dummy
|
||||||
|
</Badge>
|
||||||
|
)}
|
||||||
<Badge color={cfg.color} variant="light" radius="sm" size="xs">
|
<Badge color={cfg.color} variant="light" radius="sm" size="xs">
|
||||||
{cfg.label}
|
{cfg.label}
|
||||||
</Badge>
|
</Badge>
|
||||||
|
|||||||
Reference in New Issue
Block a user