Files
yaak/src-web/hooks/useAlert.ts
2023-11-09 20:00:19 -08:00

16 lines
481 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 ({ title, body }: { title: DialogProps['title']; body: AlertProps['body'] }) =>
dialog.show({
title,
hideX: true,
size: 'sm',
render: ({ hide }) => Alert({ onHide: hide, body }),
});
}