upd: menerapkan log pada semua aksi
This commit is contained in:
@@ -34,4 +34,5 @@ export const API_URLS = {
|
||||
getBugs: (page: number, search: string, app: string, status: string) =>
|
||||
`/api/bugs?page=${page}&search=${encodeURIComponent(search)}&app=${app}&status=${status}`,
|
||||
createBug: () => `/api/bugs`,
|
||||
createLog: () => `/api/logs`,
|
||||
}
|
||||
|
||||
@@ -1,33 +1,30 @@
|
||||
import { useEffect, useState } from 'react'
|
||||
import { notifications } from '@mantine/notifications'
|
||||
import { VillageActivityLineChart, VillageComparisonBarChart } from '@/frontend/components/DashboardCharts'
|
||||
import { ErrorDataTable } from '@/frontend/components/ErrorDataTable'
|
||||
import { SummaryCard } from '@/frontend/components/SummaryCard'
|
||||
import {
|
||||
ActionIcon,
|
||||
Badge,
|
||||
Button,
|
||||
Group,
|
||||
Modal,
|
||||
SimpleGrid,
|
||||
Stack,
|
||||
Text,
|
||||
Title,
|
||||
Modal,
|
||||
Button,
|
||||
TextInput,
|
||||
Switch,
|
||||
Badge,
|
||||
Text,
|
||||
Textarea,
|
||||
Skeleton
|
||||
TextInput,
|
||||
Title
|
||||
} from '@mantine/core'
|
||||
import { useDisclosure } from '@mantine/hooks'
|
||||
import { createFileRoute, useParams, useNavigate } from '@tanstack/react-router'
|
||||
import useSWR from 'swr'
|
||||
import { notifications } from '@mantine/notifications'
|
||||
import { createFileRoute, useNavigate, useParams } from '@tanstack/react-router'
|
||||
import { useEffect, useState } from 'react'
|
||||
import {
|
||||
TbActivity,
|
||||
TbAlertTriangle,
|
||||
TbBuildingCommunity,
|
||||
TbRefresh,
|
||||
TbVersions
|
||||
} from 'react-icons/tb'
|
||||
import useSWR from 'swr'
|
||||
import { API_URLS } from '../config/api'
|
||||
|
||||
export const Route = createFileRoute('/apps/$appId/')({
|
||||
@@ -89,6 +86,12 @@ function AppOverviewPage() {
|
||||
})
|
||||
|
||||
if (response.ok) {
|
||||
await fetch(API_URLS.createLog(), {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ type: 'UPDATE', message: `Update version information: ${JSON.stringify({ latestVersion, minVersion, maintenance, messageUpdate })}` })
|
||||
}).catch(console.error)
|
||||
|
||||
notifications.show({
|
||||
title: 'Update Successful',
|
||||
message: 'Application version information has been updated.',
|
||||
@@ -118,29 +121,29 @@ function AppOverviewPage() {
|
||||
<>
|
||||
<Modal opened={versionModalOpened} onClose={closeVersionModal} title="Update Version Information" radius="md">
|
||||
<Stack gap="md">
|
||||
<TextInput
|
||||
label="Active Version"
|
||||
<TextInput
|
||||
label="Active Version"
|
||||
placeholder="e.g. 2.0.5"
|
||||
value={latestVersion}
|
||||
value={latestVersion}
|
||||
onChange={(e) => setLatestVersion(e.currentTarget.value)}
|
||||
/>
|
||||
<TextInput
|
||||
label="Minimum Version"
|
||||
<TextInput
|
||||
label="Minimum Version"
|
||||
placeholder="e.g. 2.0.0"
|
||||
value={minVersion}
|
||||
value={minVersion}
|
||||
onChange={(e) => setMinVersion(e.currentTarget.value)}
|
||||
/>
|
||||
<Textarea
|
||||
label="Update Message"
|
||||
placeholder="Enter release notes or update message..."
|
||||
<Textarea
|
||||
label="Update Message"
|
||||
placeholder="Enter release notes or update message..."
|
||||
value={messageUpdate}
|
||||
onChange={(e) => setMessageUpdate(e.currentTarget.value)}
|
||||
minRows={3}
|
||||
autosize
|
||||
/>
|
||||
<Switch
|
||||
label="Maintenance Mode"
|
||||
description="Enable to put the app in maintenance mode for users."
|
||||
<Switch
|
||||
label="Maintenance Mode"
|
||||
description="Enable to put the app in maintenance mode for users."
|
||||
checked={maintenance}
|
||||
onChange={(e) => setMaintenance(e.currentTarget.checked)}
|
||||
/>
|
||||
|
||||
@@ -169,6 +169,12 @@ function UsersIndexPage() {
|
||||
const result = await res.json()
|
||||
|
||||
if (result.success) {
|
||||
await fetch(API_URLS.createLog(), {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ type: 'CREATE', message: `Didaftarkan user (${appId}) baru: ${form.name}-${form.nik}` })
|
||||
}).catch(console.error)
|
||||
|
||||
notifications.show({
|
||||
title: 'Success',
|
||||
message: 'User has been created successfully.',
|
||||
@@ -252,6 +258,12 @@ function UsersIndexPage() {
|
||||
const result = await res.json()
|
||||
|
||||
if (result.success) {
|
||||
await fetch(API_URLS.createLog(), {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ type: 'UPDATE', message: `Data user (${appId}) diperbarui: ${editForm.name}-${editForm.id}` })
|
||||
}).catch(console.error)
|
||||
|
||||
notifications.show({
|
||||
title: 'Success',
|
||||
message: 'User has been updated successfully.',
|
||||
|
||||
@@ -196,6 +196,12 @@ function VillageDetailPage() {
|
||||
})
|
||||
|
||||
if (res.ok) {
|
||||
await fetch(API_URLS.createLog(), {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ type: 'UPDATE', message: `Data desa (${appId}) diperbarui: ${editForm.name}-${village.id}` })
|
||||
}).catch(console.error)
|
||||
|
||||
notifications.show({
|
||||
title: 'Success',
|
||||
message: 'Village data has been updated successfully.',
|
||||
@@ -238,6 +244,12 @@ function VillageDetailPage() {
|
||||
})
|
||||
|
||||
if (res.ok) {
|
||||
await fetch(API_URLS.createLog(), {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ type: 'UPDATE', message: `Status desa (${appId}) diperbarui (${!village.isActive ? 'activated' : 'deactivated'}): ${village.name}-${village.id}` })
|
||||
}).catch(console.error)
|
||||
|
||||
notifications.show({
|
||||
title: 'Success',
|
||||
message: `Village status has been ${!village.isActive ? 'activated' : 'deactivated'}.`,
|
||||
@@ -477,9 +489,9 @@ function VillageDetailPage() {
|
||||
<Button variant="light" color="gray" onClick={closeConfirmModal} radius="md">
|
||||
Cancel
|
||||
</Button>
|
||||
<Button
|
||||
color={village.isActive ? 'red' : 'green'}
|
||||
onClick={handleConfirmToggle}
|
||||
<Button
|
||||
color={village.isActive ? 'red' : 'green'}
|
||||
onClick={handleConfirmToggle}
|
||||
loading={isUpdating}
|
||||
radius="md"
|
||||
>
|
||||
@@ -488,7 +500,7 @@ function VillageDetailPage() {
|
||||
</Group>
|
||||
</Stack>
|
||||
</Modal>
|
||||
|
||||
|
||||
{/* ── Edit Village Modal ── */}
|
||||
<Modal
|
||||
opened={editModalOpened}
|
||||
|
||||
@@ -283,6 +283,12 @@ function AppVillagesIndexPage() {
|
||||
})
|
||||
|
||||
if (res.ok) {
|
||||
await fetch(API_URLS.createLog(), {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ type: 'CREATE', message: `Desa baru didaftarkan: ${form.name}` })
|
||||
}).catch(console.error)
|
||||
|
||||
notifications.show({
|
||||
title: 'Success',
|
||||
message: 'Village has been successfully registered.',
|
||||
|
||||
@@ -92,6 +92,12 @@ function ListErrorsPage() {
|
||||
})
|
||||
|
||||
if (res.ok) {
|
||||
await fetch(API_URLS.createLog(), {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ type: 'CREATE', message: `Report bug baru ditambahkan: ${createForm.description.substring(0, 50)}${createForm.description.length > 50 ? '...' : ''}` })
|
||||
}).catch(console.error)
|
||||
|
||||
notifications.show({
|
||||
title: 'Success',
|
||||
message: 'Bug report has been created.',
|
||||
|
||||
Reference in New Issue
Block a user