fix(striker-ui): remove excess entries fetcher in CRUD list

main
Tsu-ba-me 11 months ago
parent 1fb67c974a
commit 78820bd95a
  1. 31
      striker-ui/components/CrudList.tsx

@ -56,21 +56,12 @@ const CrudList = <
const [edit, setEdit] = useState<boolean>(false);
const [entry, setEntry] = useState<Detail | undefined>();
const [entries, setEntries] = useState<OverviewList | undefined>();
const { loading: loadingEntriesPeriodic } = useFetch<OverviewList>(
entriesUrl,
{
onSuccess: (data) => setEntries(data),
refreshInterval,
},
);
const { fetch: getEntries, loading: loadingEntriesActive } =
useActiveFetch<OverviewList>({
onData: (data) => setEntries(data),
url: entriesUrl,
});
const {
data: entries,
mutate: refreshEntries,
loading: loadingEntries,
} = useFetch<OverviewList>(entriesUrl, { refreshInterval });
const { fetch: getEntry, loading: loadingEntry } = useActiveFetch<Detail>({
onData: (data) => setEntry(data),
@ -110,11 +101,6 @@ const CrudList = <
],
);
const loadingEntries = useMemo<boolean>(
() => loadingEntriesPeriodic || loadingEntriesActive,
[loadingEntriesActive, loadingEntriesPeriodic],
);
const {
buildDeleteDialogProps,
checks,
@ -164,15 +150,16 @@ const CrudList = <
.then(() => {
finishConfirm('Success', getDeleteSuccessMessage());
getEntries();
refreshEntries();
})
.catch((error) => {
const emsg = handleAPIError(error);
finishConfirm('Error', getDeleteErrorMessage(emsg));
})
.finally(() => {
resetChecks();
});
resetChecks();
},
getConfirmDialogTitle: getDeleteHeader,
renderEntry: (...args) => renderDeleteItem(entries, ...args),

Loading…
Cancel
Save