diff --git a/src/app/dashboard/profile-sections/[id]/page.tsx b/src/app/dashboard/profile-sections/[id]/page.tsx index cb13adc..88823a9 100644 --- a/src/app/dashboard/profile-sections/[id]/page.tsx +++ b/src/app/dashboard/profile-sections/[id]/page.tsx @@ -76,8 +76,8 @@ export default function SectionDetailPage() { isRequired: false, }); - const fetchData = useCallback(async () => { - setIsLoading(true); + const fetchData = useCallback(async (silent = false) => { + if (!silent) setIsLoading(true); setError(''); try { const [sectionData, fieldsData, agentTypesData] = await Promise.all([ @@ -171,7 +171,7 @@ export default function SectionDetailPage() { try { await profileFieldsService.create(fieldForm); closeFieldModal(); - fetchData(); + fetchData(true); } catch (err) { setModalError(getErrorMessage(err)); } finally { @@ -192,7 +192,7 @@ export default function SectionDetailPage() { } await profileFieldsService.update(selectedField.id, updatePayload); closeFieldModal(); - fetchData(); + fetchData(true); } catch (err) { setModalError(getErrorMessage(err)); } finally { @@ -207,7 +207,7 @@ export default function SectionDetailPage() { try { await profileFieldsService.delete(selectedField.id); closeFieldModal(); - fetchData(); + fetchData(true); } catch (err) { setModalError(getErrorMessage(err)); } finally { @@ -274,7 +274,7 @@ export default function SectionDetailPage() { const toggleFieldStatus = async (field: ProfileField) => { try { await profileFieldsService.update(field.id, { isActive: !field.isActive }); - fetchData(); + fetchData(true); } catch (err) { setError(getErrorMessage(err)); } @@ -316,7 +316,7 @@ export default function SectionDetailPage() { isRequired: assignForm.isRequired, }); closeAssignModal(); - fetchData(); + fetchData(true); } catch (err) { setModalError(getErrorMessage(err)); } finally { @@ -331,7 +331,7 @@ export default function SectionDetailPage() { try { await profileSectionsService.assignToAgentType(sectionId, assignForm); closeAssignModal(); - fetchData(); + fetchData(true); } catch (err) { setModalError(getErrorMessage(err)); } finally { @@ -343,7 +343,7 @@ export default function SectionDetailPage() { if (!confirm('Remove this section from the agent type?')) return; try { await profileSectionsService.removeFromAgentType(sectionId, agentTypeId); - fetchData(); + fetchData(true); } catch (err) { setError(getErrorMessage(err)); } @@ -352,7 +352,7 @@ export default function SectionDetailPage() { const handleToggleGlobal = async (newIsGlobal: boolean) => { try { await profileSectionsService.update(sectionId, { isGlobal: newIsGlobal }); - fetchData(); + fetchData(true); } catch (err) { setError(getErrorMessage(err)); }