mirror of
https://github.com/jambonz/jambonz-webapp.git
synced 2026-10-25 04:44:24 +00:00
* some S3 compatible storage systems have a region parameter * wip * wip * replace current toastMethod by new toastProvider * wip * fix failing testcase * wip
22 lines
533 B
TypeScript
22 lines
533 B
TypeScript
import { useEffect } from "react";
|
|
import { useNavigate } from "react-router-dom";
|
|
import { useToast } from "src/components/toast/toast-provider";
|
|
|
|
import type { IMessage } from "src/store/types";
|
|
|
|
export const useRedirect = <Type>(
|
|
collection: Type[] | undefined,
|
|
redirect: string,
|
|
message: IMessage,
|
|
) => {
|
|
const navigate = useNavigate();
|
|
const { toastError } = useToast();
|
|
|
|
useEffect(() => {
|
|
if (collection && !collection.length) {
|
|
toastError(message);
|
|
navigate(redirect);
|
|
}
|
|
}, [collection]);
|
|
};
|