mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-04-24 09:38:29 +02:00
Refactor desktop app into separate client and proxy apps
This commit is contained in:
35
apps/yaak-client/lib/confirm.ts
Normal file
35
apps/yaak-client/lib/confirm.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
import type { ConfirmProps } from '../components/core/Confirm';
|
||||
import { Confirm } from '../components/core/Confirm';
|
||||
import type { DialogProps } from '../components/core/Dialog';
|
||||
import { showDialog } from './dialog';
|
||||
|
||||
type ConfirmArgs = {
|
||||
id: string;
|
||||
} & Pick<DialogProps, 'title' | 'description' | 'size'> &
|
||||
Pick<ConfirmProps, 'color' | 'confirmText' | 'requireTyping'>;
|
||||
|
||||
export async function showConfirm({
|
||||
color,
|
||||
confirmText,
|
||||
requireTyping,
|
||||
size = 'sm',
|
||||
...extraProps
|
||||
}: ConfirmArgs) {
|
||||
return new Promise((onResult: ConfirmProps['onResult']) => {
|
||||
showDialog({
|
||||
...extraProps,
|
||||
hideX: true,
|
||||
size,
|
||||
disableBackdropClose: true, // Prevent accidental dismisses
|
||||
render: ({ hide }) => Confirm({ onHide: hide, color, onResult, confirmText, requireTyping }),
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
export async function showConfirmDelete({ confirmText, color, ...extraProps }: ConfirmArgs) {
|
||||
return showConfirm({
|
||||
color: color ?? 'danger',
|
||||
confirmText: confirmText ?? 'Delete',
|
||||
...extraProps,
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user