* Change to using arrow functions Co-authored-by: v1b3m <vibenjamin6@gmail.com> Co-authored-by: Matheus <matheus_benini@hotmail.com> * Add lint rule --------- Co-authored-by: v1b3m <vibenjamin6@gmail.com> Co-authored-by: Matheus <matheus_benini@hotmail.com> Co-authored-by: Charles Bochet <charles@twenty.com>
25 lines
511 B
TypeScript
25 lines
511 B
TypeScript
import { useSetRecoilState } from 'recoil';
|
|
import { v4 as uuidv4 } from 'uuid';
|
|
|
|
import {
|
|
SnackBarOptions,
|
|
snackBarSetQueueState,
|
|
} from '../states/snackBarState';
|
|
|
|
export const useSnackBar = () => {
|
|
const setSnackBarQueue = useSetRecoilState(snackBarSetQueueState);
|
|
|
|
const enqueueSnackBar = (
|
|
message: string,
|
|
options?: Omit<SnackBarOptions, 'message' | 'id'>,
|
|
) => {
|
|
setSnackBarQueue({
|
|
id: uuidv4(),
|
|
message,
|
|
...options,
|
|
});
|
|
};
|
|
|
|
return { enqueueSnackBar };
|
|
};
|