Files
yaak/src-web/hooks/useAlert.ts
Gregory Schier fb11aff03f Track dialogs
2024-01-28 16:33:36 -08:00

25 lines
537 B
TypeScript

import type { DialogProps } from '../components/core/Dialog';
import { useDialog } from '../components/DialogContext';
import type { AlertProps } from './Alert';
import { Alert } from './Alert';
export function useAlert() {
const dialog = useDialog();
return ({
id,
title,
body,
}: {
id: string;
title: DialogProps['title'];
body: AlertProps['body'];
}) =>
dialog.show({
id,
title,
hideX: true,
size: 'sm',
render: ({ hide }) => Alert({ onHide: hide, body }),
});
}