Merge pull request #428 from bipproduction/amalia/22-apr-25

Amalia/22 apr 25
This commit is contained in:
Amalia
2025-04-22 14:08:20 +08:00
committed by GitHub
3 changed files with 56 additions and 24 deletions

View File

@@ -2,7 +2,7 @@ import { NextResponse } from "next/server";
export async function GET(request: Request) { export async function GET(request: Request) {
try { try {
return NextResponse.json({ success: true, version: "1.3.4", tahap: "beta", update: "- update baru : menampilkan notifikasi pengumuman setelah login (fixed tampilan); - rich text di pengumuman (tambah dan edit); - fitur tandai dibaca semua notifikasi" }, { status: 200 }); return NextResponse.json({ success: true, version: "1.4.0", tahap: "beta", update: "- user role developer; -pencarian minimal 3 karakter; -fitur baca semua notifikasi disable saat tidak ada notifikasi yg blm dibaca" }, { status: 200 });
} catch (error) { } catch (error) {
console.error(error); console.error(error);
return NextResponse.json({ success: false, version: "Gagal mendapatkan version, coba lagi nanti (error: 500)", reason: (error as Error).message, }, { status: 500 }); return NextResponse.json({ success: false, version: "Gagal mendapatkan version, coba lagi nanti (error: 500)", reason: (error as Error).message, }, { status: 500 });

View File

@@ -2,14 +2,19 @@
import { TEMA } from '@/module/_global'; import { TEMA } from '@/module/_global';
import { useHookstate } from '@hookstate/core'; import { useHookstate } from '@hookstate/core';
import { Box, Flex, SimpleGrid, Stack, Text } from '@mantine/core'; import { Box, Flex, SimpleGrid, Stack, Text } from '@mantine/core';
import { useShallowEffect } from '@mantine/hooks';
import { useState } from 'react';
import toast from 'react-hot-toast'; import toast from 'react-hot-toast';
import { LuCheckCheck } from 'react-icons/lu'; import { LuCheckCheck } from 'react-icons/lu';
import { funGetHome } from '../lib/api_home';
import { funReadAllNotification } from '../lib/api_notification'; import { funReadAllNotification } from '../lib/api_notification';
import { globalRefreshNotif } from '../lib/val_home'; import { globalRefreshNotif } from '../lib/val_home';
export default function DrawerNotification({ onDone }: { onDone: () => void }) { export default function DrawerNotification({ onDone }: { onDone: () => void }) {
const tema = useHookstate(TEMA) const tema = useHookstate(TEMA)
const reloadNotif = useHookstate(globalRefreshNotif) const reloadNotif = useHookstate(globalRefreshNotif)
const [disabled, setDisabled] = useState(false)
const [notif, setNotif] = useState(0)
async function handleReadAll() { async function handleReadAll() {
try { try {
@@ -28,18 +33,39 @@ export default function DrawerNotification({ onDone }: { onDone: () => void }) {
} }
} }
const fetchData = async () => {
try {
setDisabled(true)
const response = await funGetHome('?cat=header')
if (response.success) {
setNotif(response.data.totalNotif)
if (response.data.totalNotif > 0) {
setDisabled(false)
}
} else {
toast.error(response.message);
}
} catch (error) {
toast.error("Gagal mendapatkan data, coba lagi nanti");
console.error(error);
}
};
useShallowEffect(() => {
fetchData();
}, []);
return ( return (
<Box> <Box>
<Stack pt={10}> <Stack pt={10}>
<SimpleGrid <SimpleGrid cols={{ base: 3, sm: 3, lg: 3 }} >
cols={{ base: 3, sm: 3, lg: 3 }} <Flex onClick={() => { !disabled && handleReadAll() }} justify={'center'} align={'center'} direction={'column'} >
>
<Flex onClick={() => { handleReadAll() }} justify={'center'} align={'center'} direction={'column'} >
<Box> <Box>
<LuCheckCheck size={30} color={tema.get().utama} /> <LuCheckCheck size={30} color={disabled ? 'gray' : tema.get().utama} />
</Box> </Box>
<Box> <Box>
<Text c={tema.get().utama} ta={"center"}>Tandai Dibaca Semua</Text> <Text c={disabled ? 'gray' : tema.get().utama} ta={"center"}>Tandai Dibaca Semua</Text>
</Box> </Box>
</Flex> </Flex>
</SimpleGrid> </SimpleGrid>

View File

@@ -22,24 +22,30 @@ export default function ViewSearch() {
const isMobile2 = useMediaQuery("(max-width: 460px)"); const isMobile2 = useMediaQuery("(max-width: 460px)");
async function featchSearch(cari: string) { async function featchSearch(cari: string) {
try { if (cari.length >= 3) {
setLoading(true) try {
setSearch(cari) setLoading(true)
if (cari != "") { setSearch(cari)
const res = await funGetSearchAll("?search=" + cari); if (cari != "") {
setDataUser(res.data.user); const res = await funGetSearchAll("?search=" + cari);
setDataProject(res.data.project); setDataUser(res.data.user);
setDataDivision(res.data.division); setDataProject(res.data.project);
} else { setDataDivision(res.data.division);
setDataUser([]); } else {
setDataProject([]); setDataUser([]);
setDataDivision([]); setDataProject([]);
setDataDivision([]);
}
} catch (error) {
console.error(error);
toast.error("Gagal mendapatkan data, coba lagi nanti");
} finally {
setLoading(false)
} }
} catch (error) { } else {
console.error(error); setDataUser([]);
toast.error("Gagal mendapatkan data, coba lagi nanti"); setDataProject([]);
} finally { setDataDivision([]);
setLoading(false)
} }
} }