feat : update calender

This commit is contained in:
lukman
2024-08-15 11:53:26 +08:00
parent d34a0a1a82
commit 2cfa96c0ed
14 changed files with 121 additions and 9 deletions

View File

@@ -0,0 +1,3 @@
import NavbarDivisionCalender from "./ui/navbar_division_calender";
export { NavbarDivisionCalender }

View File

@@ -0,0 +1,4 @@
export const funGetAllCalender = async (path?: string) => {
const response = await fetch(`/api/calender${(path) ? path : ''}`, { next: { tags: ['calender'] } });
return await response.json().catch(() => null);
}

View File

@@ -0,0 +1,10 @@
export interface IDataCalender {
id: string
title: string
desc: string
status: number
dateStart: string
dateEnd: string
createdAt: string
user_name: string
}

View File

@@ -1,8 +1,11 @@
import { WARNA } from '@/module/_global';
import { Box, Divider, Group, Indicator, Text } from '@mantine/core';
import { DatePicker, DatePickerProps } from '@mantine/dates';
import { useRouter } from 'next/navigation';
import React from 'react';
import { useParams, useRouter } from 'next/navigation';
import React, { useState } from 'react';
import { funGetAllCalender } from '../lib/api_calender';
import { useShallowEffect } from '@mantine/hooks';
import { IDataCalender } from '../lib/type_calender';
const HariIni = [
{
@@ -38,7 +41,24 @@ const Besok = [
]
export default function DateEventDivision() {
const[isData, setData] = useState<IDataCalender[]>([])
const router = useRouter()
const param = useParams<{ id: string }>()
const getData = async () => {
try {
const response = await funGetAllCalender('?division=' + param.id)
setData(response.data)
} catch (error) {
console.log(error)
}
}
useShallowEffect(() => {
getData()
}, [])
const dayRenderer: DatePickerProps['renderDay'] = (date) => {
const day = date.getDate();
return (
@@ -49,6 +69,7 @@ export default function DateEventDivision() {
};
return (
<Box>
<pre>{JSON.stringify(isData, null, 1)}</pre>
<Group
justify="center"
bg={"white"}

View File

@@ -18,10 +18,10 @@ export default function NavbarDivisionCalender() {
}
/>
<Box p={20}>
<DateEventDivision/>
<DateEventDivision />
</Box>
<LayoutDrawer opened={openDrawer} title={'Menu'} onClose={() => setOpenDrawer(false)}>
<DawerDivisionCalender/>
<DawerDivisionCalender />
</LayoutDrawer>
</div>
);

View File

@@ -38,6 +38,9 @@ export default function DetailDiscussion({ id, idDivision }: { id: string, idDiv
const sendComent = async () => {
try {
if (isComent.trim() == "") {
return toast.error("Masukkan Komentar Anda")
}
const response = await funCreateComent(id, {
comment: isComent,
idDiscussion: param.detail

View File

@@ -1,11 +1,11 @@
import React from 'react';
import NavbarDivisionCalender from '../components/navbar_division_calender';
import NavbarDivisionCalender from '../../../../calender/ui/navbar_division_calender';
import { Box } from '@mantine/core';
export default function ViewDivisionCalender() {
return (
<Box>
<NavbarDivisionCalender/>
<NavbarDivisionCalender />
</Box>
);
}

View File

@@ -44,6 +44,7 @@ export interface IDataKalenderOnDetailDivision {
export interface IDataDiscussionOnDetailDivision {
id: string,
desc: string,
title: string,
date: string,
user: string

View File

@@ -116,7 +116,7 @@ export default function ListDiscussionOnDetailDivision() {
<GoDiscussionClosed size={25} />
<Box w={{ base: 230, md: 400 }}>
<Text fw={"bold"} truncate="end">
{v.title}
{v.desc}
</Text>
</Box>
</Group>