feat : update calender
This commit is contained in:
3
src/module/calender/index.ts
Normal file
3
src/module/calender/index.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
import NavbarDivisionCalender from "./ui/navbar_division_calender";
|
||||
|
||||
export { NavbarDivisionCalender }
|
||||
4
src/module/calender/lib/api_calender.ts
Normal file
4
src/module/calender/lib/api_calender.ts
Normal 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);
|
||||
}
|
||||
10
src/module/calender/lib/type_calender.ts
Normal file
10
src/module/calender/lib/type_calender.ts
Normal 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
|
||||
}
|
||||
@@ -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"}
|
||||
@@ -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>
|
||||
);
|
||||
@@ -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
|
||||
|
||||
@@ -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>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -44,6 +44,7 @@ export interface IDataKalenderOnDetailDivision {
|
||||
|
||||
export interface IDataDiscussionOnDetailDivision {
|
||||
id: string,
|
||||
desc: string,
|
||||
title: string,
|
||||
date: string,
|
||||
user: string
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user