Files
new-phone-who-dis/phone/src/ui/hooks/useSnackbar.ts
T
J Francisco Rader 107dc43624 Improve messages error handling (#181)
* Improve messages error handling

* Add types to getPlayerFromIdentifier function

* Add phone validation regex to message group form

* Add correct alert types to enum

* Improve locale

* Improve error message for unregistered numbers
2021-03-29 18:55:27 -04:00

19 lines
453 B
TypeScript

import { useContext } from 'react';
import { SnackbarContext } from '../providers/SnackbarProvider';
export interface IAlert {
message: string;
type: AlertType;
}
export type AlertType = 'success' | 'error' | 'info' | 'warning';
interface ISnackBar {
addAlert: ({ message, type }: IAlert) => void;
alert: IAlert | null;
isOpen: boolean;
handleClose: () => void;
}
export const useSnackbar = (): ISnackBar => useContext(SnackbarContext);