turash/bugulma/frontend/hooks/useConfirmation.ts
Damir Mukimov 6347f42e20
Consolidate repositories: Remove nested frontend .git and merge into main repository
- Remove nested git repository from bugulma/frontend/.git
- Add all frontend files to main repository tracking
- Convert from separate frontend/backend repos to unified monorepo
- Preserve all frontend code and development history as tracked files
- Eliminate nested repository complexity for simpler development workflow

This creates a proper monorepo structure with frontend and backend
coexisting in the same repository for easier development and deployment.
2025-11-25 06:02:57 +01:00

54 lines
1.0 KiB
TypeScript

import { useCallback, useState } from 'react';
interface ConfirmationOptions {
title: string;
message: string;
confirmText?: string;
cancelText?: string;
variant?: 'danger' | 'warning' | 'info';
}
interface ConfirmationState extends ConfirmationOptions {
isOpen: boolean;
onConfirm: () => void;
onCancel: () => void;
}
/**
* Hook for managing confirmation dialogs with consistent UX
*/
export function useConfirmation() {
const [state, setState] = useState<ConfirmationState | null>(null);
const confirm = useCallback((options: ConfirmationOptions): Promise<boolean> => {
return new Promise((resolve) => {
const onConfirm = () => {
setState(null);
resolve(true);
};
const onCancel = () => {
setState(null);
resolve(false);
};
setState({
...options,
isOpen: true,
onConfirm,
onCancel,
});
});
}, []);
const close = useCallback(() => {
setState(null);
}, []);
return {
confirm,
close,
state,
};
}