upd : home page

Deskripsi:
- load refresh pada halaman home

No Issues
This commit is contained in:
2025-09-09 11:49:13 +08:00
parent a15724756e
commit 060f96e7b2
8 changed files with 89 additions and 37 deletions

View File

@@ -13,14 +13,14 @@ type Props = {
color: string;
}[]
export default function ChartProgresHome() {
export default function ChartProgresHome({ refreshing }: { refreshing: boolean }) {
const { decryptToken, token } = useAuthSession()
const [data, setData] = useState<Props>([])
const [loading, setLoading] = useState(true)
async function handleData() {
async function handleData(loading: boolean) {
try {
setLoading(true)
setLoading(loading)
const hasil = await decryptToken(String(token?.current))
const response = await apiGetDataHome({ cat: "progress", user: hasil })
const convertedArray = response.data.map((item: { color: any; text: any; value: any; }) => ({
@@ -37,7 +37,12 @@ export default function ChartProgresHome() {
}
useEffect(() => {
handleData()
if (refreshing)
handleData(false)
}, [refreshing]);
useEffect(() => {
handleData(true)
}, []);
return (