Files
the-biergarten-app/web/frontend/app/features/account/hooks/useSectionError.ts

11 lines
400 B
TypeScript

import { useEffect } from 'react';
import { showErrorToast } from '../../../components/ui/toast/toast';
import type { ActionResult } from '../types';
export const useSectionError = (result: ActionResult | undefined, intent: ActionResult['intent']) => {
useEffect(() => {
if (!result || result.intent !== intent) return;
showErrorToast(result.error);
}, [result, intent]);
};