feat : update api project

This commit is contained in:
lukman
2024-08-21 17:30:41 +08:00
parent a36fe88998
commit dab77c0bbc
12 changed files with 774 additions and 203 deletions

View File

@@ -1,10 +1,53 @@
'use client'
import { WARNA } from '@/module/_global';
import { useHookstate } from '@hookstate/core';
import { ActionIcon, Box, Grid, Progress, Text } from '@mantine/core';
import React from 'react';
import { useParams } from 'next/navigation';
import React, { useEffect, useState } from 'react';
import { HiMiniPresentationChartBar } from 'react-icons/hi2';
import { globalRefreshProject } from '../lib/val_project';
import toast from 'react-hot-toast';
import { funGetOneProjectById } from '../lib/api_project';
import { useShallowEffect } from '@mantine/hooks';
export default function ProgressDetailProject() {
const [valProgress, setValProgress] = useState(0)
const [valLastUpdate, setValLastUpdate] = useState('')
const param = useParams<{ id: string }>()
const refresh = useHookstate(globalRefreshProject)
async function getOneData() {
try {
const res = await funGetOneProjectById(param.id, 'progress');
console.log("data",res)
if (res.success) {
setValProgress(res.data.progress);
setValLastUpdate(res.data.lastUpdate);
} else {
toast.error(res.message);
}
} catch (error) {
console.error(error);
toast.error("Gagal mendapatkan progress proyek, coba lagi nanti");
}
}
function onRefresh() {
if (refresh.get()) {
getOneData()
refresh.set(false)
}
}
useEffect(() => {
onRefresh()
}, [refresh.get()])
useShallowEffect(() => {
getOneData();
}, [param.id])
return (
<>
<Box mt={10}>
@@ -29,7 +72,7 @@ export default function ProgressDetailProject() {
</Grid.Col>
<Grid.Col span={9}>
<Box>
<Text>Kemajuan Proyek 60%</Text>
<Text>Kemajuan Proyek {valProgress}%</Text>
<Progress
style={{
border: `1px solid ${"#BDBDBD"}`,
@@ -38,7 +81,7 @@ export default function ProgressDetailProject() {
color="#FCAA4B"
radius="md"
size="xl"
value={60}
value={valProgress}
/>
</Box>
</Grid.Col>