Merge pull request #428 from bipproduction/amalia/22-apr-25
Amalia/22 apr 25
This commit is contained in:
@@ -2,7 +2,7 @@ import { NextResponse } from "next/server";
|
||||
|
||||
export async function GET(request: Request) {
|
||||
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) {
|
||||
console.error(error);
|
||||
return NextResponse.json({ success: false, version: "Gagal mendapatkan version, coba lagi nanti (error: 500)", reason: (error as Error).message, }, { status: 500 });
|
||||
|
||||
@@ -2,14 +2,19 @@
|
||||
import { TEMA } from '@/module/_global';
|
||||
import { useHookstate } from '@hookstate/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 { LuCheckCheck } from 'react-icons/lu';
|
||||
import { funGetHome } from '../lib/api_home';
|
||||
import { funReadAllNotification } from '../lib/api_notification';
|
||||
import { globalRefreshNotif } from '../lib/val_home';
|
||||
|
||||
export default function DrawerNotification({ onDone }: { onDone: () => void }) {
|
||||
const tema = useHookstate(TEMA)
|
||||
const reloadNotif = useHookstate(globalRefreshNotif)
|
||||
const [disabled, setDisabled] = useState(false)
|
||||
const [notif, setNotif] = useState(0)
|
||||
|
||||
async function handleReadAll() {
|
||||
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 (
|
||||
<Box>
|
||||
<Stack pt={10}>
|
||||
<SimpleGrid
|
||||
cols={{ base: 3, sm: 3, lg: 3 }}
|
||||
>
|
||||
<Flex onClick={() => { handleReadAll() }} justify={'center'} align={'center'} direction={'column'} >
|
||||
<SimpleGrid cols={{ base: 3, sm: 3, lg: 3 }} >
|
||||
<Flex onClick={() => { !disabled && handleReadAll() }} justify={'center'} align={'center'} direction={'column'} >
|
||||
<Box>
|
||||
<LuCheckCheck size={30} color={tema.get().utama} />
|
||||
<LuCheckCheck size={30} color={disabled ? 'gray' : tema.get().utama} />
|
||||
</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>
|
||||
</Flex>
|
||||
</SimpleGrid>
|
||||
|
||||
@@ -22,24 +22,30 @@ export default function ViewSearch() {
|
||||
const isMobile2 = useMediaQuery("(max-width: 460px)");
|
||||
|
||||
async function featchSearch(cari: string) {
|
||||
try {
|
||||
setLoading(true)
|
||||
setSearch(cari)
|
||||
if (cari != "") {
|
||||
const res = await funGetSearchAll("?search=" + cari);
|
||||
setDataUser(res.data.user);
|
||||
setDataProject(res.data.project);
|
||||
setDataDivision(res.data.division);
|
||||
} else {
|
||||
setDataUser([]);
|
||||
setDataProject([]);
|
||||
setDataDivision([]);
|
||||
if (cari.length >= 3) {
|
||||
try {
|
||||
setLoading(true)
|
||||
setSearch(cari)
|
||||
if (cari != "") {
|
||||
const res = await funGetSearchAll("?search=" + cari);
|
||||
setDataUser(res.data.user);
|
||||
setDataProject(res.data.project);
|
||||
setDataDivision(res.data.division);
|
||||
} else {
|
||||
setDataUser([]);
|
||||
setDataProject([]);
|
||||
setDataDivision([]);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
toast.error("Gagal mendapatkan data, coba lagi nanti");
|
||||
} finally {
|
||||
setLoading(false)
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
toast.error("Gagal mendapatkan data, coba lagi nanti");
|
||||
} finally {
|
||||
setLoading(false)
|
||||
} else {
|
||||
setDataUser([]);
|
||||
setDataProject([]);
|
||||
setDataDivision([]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user