Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export const useGetLists = () => {
const [, dispatch] = useContainer(ListContainer);
const {
api: {
list: { useGet },
},
} = usePluginContainer();
const [state, request] = useGet();
// Fetch Lists
useEffect(() => {
const fn = async () => {
const resp = await request();
if (resp.ok) {
dispatch(actions.getLists(resp.data));
}
export const useGlobalStatus = (loading: boolean, error?: Error) => {
const id = useRef(uuid());
const [, dispatch] = useContainer(StatusContainer);
useEffect(() => {
if (error) {
dispatch(actions.pushError(error));
}
dispatch(actions.setLoading(id.current, loading));
}, [dispatch, error, loading]);
};
const useRemoveSingleEntry = (entryId?: number) => {
const [{ listId }] = useContainer(ListContainer);
const [, dispatch] = useContainer(EntryContainer);
const {
api: {
entry: { useRemove },
},
} = usePluginContainer();
const [state, request] = useRemove(listId, entryId);
const removeEntry = useCallback(async () => {
const resp = await request();
if (resp.ok && entryId) {
dispatch(actions.removeEntry(entryId));
}
return resp;
}, [dispatch, entryId, request]);