fixes of broken fucntions

This commit is contained in:
Desktop
2025-11-16 04:56:48 +05:00
parent 5eb2464d2d
commit 5908115686
8 changed files with 141 additions and 46 deletions

View File

@@ -134,12 +134,13 @@ export function usePersistentToggle(
try {
const endpoint = getEndpoint.replace('{id}', resourceId);
// fetchAPI extracts data from unified format {success: true, data: {...}}
// So result IS the data object, not wrapped
const result = await fetchAPI(endpoint);
if (result.success && result.data) {
const apiData = result.data;
setData(apiData);
const newEnabled = extractEnabled(apiData);
if (result && typeof result === 'object') {
setData(result);
const newEnabled = extractEnabled(result);
setEnabled(newEnabled);
} else {
// No data yet - use initial state