mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-04-23 17:18:32 +02:00
A bunch of changes, including moving prompt/confirm out of context
This commit is contained in:
25
src-web/lib/confirm.ts
Normal file
25
src-web/lib/confirm.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import type { ConfirmProps } from '../components/core/Confirm';
|
||||
import { Confirm } from '../components/core/Confirm';
|
||||
import type { DialogProps } from '../components/core/Dialog';
|
||||
import { showDialog } from './dialog';
|
||||
|
||||
interface ConfirmArgs {
|
||||
id: string;
|
||||
title: DialogProps['title'];
|
||||
description?: DialogProps['description'];
|
||||
variant?: ConfirmProps['variant'];
|
||||
confirmText?: ConfirmProps['confirmText'];
|
||||
}
|
||||
|
||||
export async function showConfirm({ id, title, description, variant, confirmText }: ConfirmArgs) {
|
||||
return new Promise((onResult: ConfirmProps['onResult']) => {
|
||||
showDialog({
|
||||
id,
|
||||
title,
|
||||
description,
|
||||
hideX: true,
|
||||
size: 'sm',
|
||||
render: ({ hide }) => Confirm({ onHide: hide, variant, onResult, confirmText }),
|
||||
});
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user