upd: project dan task

Deskripsi:
- tambah project
- perbaiki task

No Issues
This commit is contained in:
amel
2024-08-23 18:10:11 +08:00
parent df2f61e833
commit 5b05edaf38
14 changed files with 163 additions and 115 deletions

View File

@@ -31,12 +31,13 @@ export const funGetAllMemberById = async (path?: string) => {
}
export const funDeleteDetailProject = async (path: string) => {
export const funDeleteDetailProject = async (path: string, data: { idProject: string }) => {
const response = await fetch(`/api/project/detail/${path}`, {
method: "DELETE",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify(data),
});
return await response.json().catch(() => null);
}

View File

@@ -8,7 +8,7 @@ export interface IDataProject {
export interface IDataListTaskProject {
id: string
name: string
title: string
desc: string
status: number
dateStart: string

View File

@@ -4,7 +4,6 @@ import React, { useState } from 'react';
import { IDataMemberProject, IDataMemberProjectDetail } from '../lib/type_project';
import toast from 'react-hot-toast';
import { funAddMemberProject, funGetAllMemberById, funGetOneProjectById } from '../lib/api_project';
import { funGetDivisionById } from '@/module/division_new';
import { useShallowEffect } from '@mantine/hooks';
import { Avatar, Box, Button, Divider, Flex, Group, Stack, Text } from '@mantine/core';
import { LayoutNavbarNew, WARNA } from '@/module/_global';
@@ -103,11 +102,9 @@ export default function AddMemberDetailProject() {
<Box>
<LayoutNavbarNew
back=""
title="Pilih Anggotak"
title="Pilih Anggota"
menu
/>
<pre>{JSON.stringify(isData, null, 1)}</pre>
<pre>{JSON.stringify(isDataMember, null, 1)}</pre>
<Box p={20}>
{/* <TextInput
styles={{

View File

@@ -46,7 +46,7 @@ export default function EditDetailTaskProject() {
try {
const res = await funGetDetailProject(param.id);
if (res.success) {
setName(res.data.name)
setName(res.data.title)
setValue([
new Date(moment(res.data.dateStart).format('YYYY-MM-DD')),
new Date(moment(res.data.dateEnd).format('YYYY-MM-DD')),

View File

@@ -40,7 +40,7 @@ export default function EditTaskProject() {
try {
const res = await funGetOneProjectById(param.id, 'data');
if (res.success) {
setName(res.data.name);
setName(res.data.title);
} else {
toast.error(res.message);
}
@@ -57,7 +57,7 @@ export default function EditTaskProject() {
return (
<Box>
<LayoutNavbarNew back="" title={"Edit Judul Tugas"} menu />
<LayoutNavbarNew back="" title={"Edit Judul Proyek"} menu />
<Box p={20}>
<Stack pt={15}>
<Input

View File

@@ -49,12 +49,13 @@ export default function ListTugasDetailProject() {
async function onDelete() {
try {
const res = await funDeleteDetailProject(idData);
const res = await funDeleteDetailProject(idData, { idProject: param.id });
if (res.success) {
toast.success(res.message);
getOneData();
setIdData("")
setOpenDrawer(false)
refresh.set(true)
} else {
toast.error(res.message);
}
@@ -125,7 +126,7 @@ export default function ListTugasDetailProject() {
>
<Group>
<AiOutlineFileSync size={25} />
<Text>{item.name}</Text>
<Text>{item.title}</Text>
</Group>
</Box>
<Box>
@@ -206,51 +207,51 @@ export default function ListTugasDetailProject() {
</LayoutDrawer>
<LayoutModal opened={isOpenModal} onClose={() => setOpenModal(false)}
description="Apakah Anda yakin ingin menghapus proyek ini?"
onYes={(val) => {
if (val) {
onDelete()
}
setOpenModal(false)
description="Apakah Anda yakin ingin menghapus proyek ini?"
onYes={(val) => {
if (val) {
onDelete()
}
setOpenModal(false)
}} />
<LayoutDrawer opened={openDrawerStatus} title={'Status'} onClose={() => setOpenDrawerStatus(false)}>
<Box>
<Stack pt={10}>
{
valStatusDetailProject.map((item, index) => {
return (
<Box mb={5} key={index} onClick={() => { onUpdateStatus(item.value) }}>
<Flex justify={"space-between"} align={"center"}>
<Group>
<Text style={{
cursor: 'pointer',
display: 'flex',
alignItems: 'center',
}}>
{item.name}
</Text>
</Group>
<Text
style={{
cursor: 'pointer',
display: 'flex',
alignItems: 'center',
paddingLeft: 20,
}}
>
{statusData === item.value ? <FaCheck style={{ marginRight: 10 }} /> : ""}
</Text>
</Flex>
<Divider my={"md"} />
</Box>
)
})
}
</Stack>
</Box>
</LayoutDrawer>
<LayoutDrawer opened={openDrawerStatus} title={'Status'} onClose={() => setOpenDrawerStatus(false)}>
<Box>
<Stack pt={10}>
{
valStatusDetailProject.map((item, index) => {
return (
<Box mb={5} key={index} onClick={() => { onUpdateStatus(item.value) }}>
<Flex justify={"space-between"} align={"center"}>
<Group>
<Text style={{
cursor: 'pointer',
display: 'flex',
alignItems: 'center',
}}>
{item.name}
</Text>
</Group>
<Text
style={{
cursor: 'pointer',
display: 'flex',
alignItems: 'center',
paddingLeft: 20,
}}
>
{statusData === item.value ? <FaCheck style={{ marginRight: 10 }} /> : ""}
</Text>
</Flex>
<Divider my={"md"} />
</Box>
)
})
}
</Stack>
</Box>
</LayoutDrawer>
</Box>
</>

View File

@@ -21,7 +21,7 @@ export default function NavbarDetailProject() {
try {
const res = await funGetOneProjectById(param.id, 'data');
if (res.success) {
setName(res.data.name);
setName(res.data.title);
} else {
toast.error(res.message);
}

View File

@@ -3,7 +3,7 @@ import { WARNA } from '@/module/_global';
import { useHookstate } from '@hookstate/core';
import { ActionIcon, Box, Grid, Progress, Text } from '@mantine/core';
import { useParams } from 'next/navigation';
import React, { useEffect, useState } from 'react';
import React, { useState } from 'react';
import { HiMiniPresentationChartBar } from 'react-icons/hi2';
import { globalRefreshProject } from '../lib/val_project';
import toast from 'react-hot-toast';
@@ -39,7 +39,7 @@ export default function ProgressDetailProject() {
}
}
useEffect(() => {
useShallowEffect(() => {
onRefresh()
}, [refresh.get()])