Merge pull request #420 from bipproduction/amalia/14-apr-25
upd: notifikasi pengumuman
This commit is contained in:
BIN
public/assets/img/announcement.jpg
Normal file
BIN
public/assets/img/announcement.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 68 KiB |
@@ -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.1", tahap: "beta", update: "- update baru : menampilkan notifikasi pengumuman setelah login; - fix random nomer kode otp 4 digit" }, { status: 200 });
|
return NextResponse.json({ success: true, version: "1.3.2", tahap: "beta", update: "- update baru : menampilkan notifikasi pengumuman setelah login (fixed tampilan); - fix random nomer kode otp 4 digit" }, { 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 });
|
||||||
|
|||||||
105
src/module/_global/components/notification_custome_center.tsx
Normal file
105
src/module/_global/components/notification_custome_center.tsx
Normal file
@@ -0,0 +1,105 @@
|
|||||||
|
"use client"
|
||||||
|
import { useHookstate } from '@hookstate/core';
|
||||||
|
import { Box, Button, Center, Flex, Image, rem, SimpleGrid, Text, Transition } from '@mantine/core';
|
||||||
|
import { useShallowEffect } from '@mantine/hooks';
|
||||||
|
import { useState } from 'react';
|
||||||
|
import { IoCloseOutline } from 'react-icons/io5';
|
||||||
|
import { TEMA } from '../bin/val_global';
|
||||||
|
|
||||||
|
export default function NotificationCustomeCenter({ title, desc, onClick }: { title: string, desc: string, onClick: (val: string) => void, }) {
|
||||||
|
const [opened, setOpened] = useState(false);
|
||||||
|
const tema = useHookstate(TEMA)
|
||||||
|
|
||||||
|
useShallowEffect(() => {
|
||||||
|
const timer = setTimeout(() => {
|
||||||
|
setOpened(true);
|
||||||
|
}, 50);
|
||||||
|
return () => clearTimeout(timer);
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
function reloadData() {
|
||||||
|
setOpened(false)
|
||||||
|
}
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<Center>
|
||||||
|
<Transition
|
||||||
|
mounted={opened}
|
||||||
|
transition="fade-down"
|
||||||
|
duration={400}
|
||||||
|
timingFunction="ease"
|
||||||
|
>
|
||||||
|
{(state) => (
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
...state,
|
||||||
|
zIndex: 999,
|
||||||
|
position: 'fixed',
|
||||||
|
flex: 1,
|
||||||
|
display: 'flex',
|
||||||
|
margin: 0,
|
||||||
|
justifyContent: 'center',
|
||||||
|
alignItems: 'center',
|
||||||
|
top: '30%'
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Box p={rem(15)} w={"90%"} style={{
|
||||||
|
maxWidth: rem(450),
|
||||||
|
zIndex: 999,
|
||||||
|
backgroundColor: "#ffffff",
|
||||||
|
borderRadius: 15,
|
||||||
|
border: `1px solid ${tema.get().bgTotalKegiatan}`
|
||||||
|
}}>
|
||||||
|
<Flex justify={'flex-end'} align={"center"}>
|
||||||
|
<IoCloseOutline onClick={reloadData} size={25} />
|
||||||
|
</Flex>
|
||||||
|
<Flex
|
||||||
|
mih={50}
|
||||||
|
gap="xs"
|
||||||
|
justify="center"
|
||||||
|
align="center"
|
||||||
|
direction="column"
|
||||||
|
wrap="wrap"
|
||||||
|
>
|
||||||
|
<Image
|
||||||
|
style={{
|
||||||
|
maxWidth: '30%',
|
||||||
|
maxHeight: '30%',
|
||||||
|
}}
|
||||||
|
fit="contain"
|
||||||
|
alt={'pengumuman'}
|
||||||
|
src={"/assets/img/announcement.jpg"}
|
||||||
|
/>
|
||||||
|
<Text size="xl" fw={500} ta="center">PENGUMUMAN</Text>
|
||||||
|
<Text size="sm" ta="center">{desc}</Text>
|
||||||
|
<SimpleGrid cols={2} spacing="xs" w={'90%'}>
|
||||||
|
<Button
|
||||||
|
fullWidth
|
||||||
|
radius="md"
|
||||||
|
onClick={() => {
|
||||||
|
setOpened(false)
|
||||||
|
onClick('check')
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Periksa Detail
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
fullWidth
|
||||||
|
radius="md"
|
||||||
|
onClick={() => {
|
||||||
|
setOpened(false)
|
||||||
|
onClick('read')
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Tandai Telah Dibaca
|
||||||
|
</Button>
|
||||||
|
</SimpleGrid>
|
||||||
|
</Flex>
|
||||||
|
</Box>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</Transition>
|
||||||
|
</Center >
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
'use client'
|
'use client'
|
||||||
import { NotificationCustome } from "@/module/_global";
|
import NotificationCustomeCenter from "@/module/_global/components/notification_custome_center";
|
||||||
import { useShallowEffect } from "@mantine/hooks";
|
import { useShallowEffect } from "@mantine/hooks";
|
||||||
import { useRouter } from "next/navigation";
|
import { useRouter } from "next/navigation";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
@@ -21,10 +21,6 @@ export default function NotificationAnnouncement() {
|
|||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
} finally {
|
|
||||||
setTimeout(() => {
|
|
||||||
setTampilNotif(false);
|
|
||||||
}, 6000);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -32,11 +28,13 @@ export default function NotificationAnnouncement() {
|
|||||||
fetchData();
|
fetchData();
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
async function onClickNotif(category: string, idContent: string, idData: string) {
|
async function onClickNotif(category: string, idContent: string, idData: string, action: string) {
|
||||||
try {
|
try {
|
||||||
const response = await funReadNotification({ id: idData });
|
const response = await funReadNotification({ id: idData });
|
||||||
if (response.success) {
|
if (response.success) {
|
||||||
router.push(`/${category}/${idContent}`);
|
if (action == "check") {
|
||||||
|
router.push(`/${category}/${idContent}`);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
toast.error(response.message);
|
toast.error(response.message);
|
||||||
}
|
}
|
||||||
@@ -46,15 +44,15 @@ export default function NotificationAnnouncement() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{
|
{
|
||||||
tampilNotif &&
|
tampilNotif &&
|
||||||
<NotificationCustome
|
<NotificationCustomeCenter
|
||||||
title={isData[0]?.title}
|
title={isData[0]?.title}
|
||||||
desc={isData[0]?.desc}
|
desc={isData[0]?.desc}
|
||||||
onClick={() => { onClickNotif(isData[0]?.category, isData[0]?.idContent, isData[0]?.id) }}
|
onClick={(val) => { onClickNotif(isData[0]?.category, isData[0]?.idContent, isData[0]?.id, val) }}
|
||||||
onClose={() => { '' }}
|
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
</>
|
</>
|
||||||
|
|||||||
Reference in New Issue
Block a user