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

Loading…
Cancel
Save