mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-25 15:55:48 +00:00
refactor(FE): Refactor fetchChecklistDetail with useCallback
This commit is contained in:
+11
-11
@@ -1,6 +1,6 @@
|
|||||||
'use client';
|
'use client';
|
||||||
|
|
||||||
import { useState, useEffect } from 'react';
|
import { useState, useEffect, useCallback } from 'react';
|
||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import { ArrowLeft, CheckCircle, XCircle, AlertCircle } from 'lucide-react';
|
import { ArrowLeft, CheckCircle, XCircle, AlertCircle } from 'lucide-react';
|
||||||
import { Card, CardContent } from '@/figma-make/components/base/card';
|
import { Card, CardContent } from '@/figma-make/components/base/card';
|
||||||
@@ -137,15 +137,7 @@ export function DetailDailyChecklistContent() {
|
|||||||
const [rejectReason, setRejectReason] = useState('');
|
const [rejectReason, setRejectReason] = useState('');
|
||||||
const [actionLoading, setActionLoading] = useState(false);
|
const [actionLoading, setActionLoading] = useState(false);
|
||||||
|
|
||||||
useEffect(() => {
|
const fetchChecklistDetail = useCallback(async () => {
|
||||||
if (checklistId) {
|
|
||||||
fetchChecklistDetail();
|
|
||||||
} else {
|
|
||||||
router.push('/404');
|
|
||||||
}
|
|
||||||
}, [checklistId]);
|
|
||||||
|
|
||||||
const fetchChecklistDetail = async () => {
|
|
||||||
if (!checklistId) {
|
if (!checklistId) {
|
||||||
console.warn('checklistId missing');
|
console.warn('checklistId missing');
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
@@ -320,7 +312,15 @@ export function DetailDailyChecklistContent() {
|
|||||||
} finally {
|
} finally {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
}
|
}
|
||||||
};
|
}, [checklistId, router]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (checklistId) {
|
||||||
|
fetchChecklistDetail();
|
||||||
|
} else {
|
||||||
|
router.push('/404');
|
||||||
|
}
|
||||||
|
}, [checklistId, fetchChecklistDetail, router]);
|
||||||
|
|
||||||
const groupDetailData = (rows: ChecklistDetailRow[]) => {
|
const groupDetailData = (rows: ChecklistDetailRow[]) => {
|
||||||
// Group by phase_id
|
// Group by phase_id
|
||||||
|
|||||||
Reference in New Issue
Block a user