mirror of
https://github.com/SamyRai/turash.git
synced 2025-12-26 23:01:33 +00:00
- 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.
54 lines
1.0 KiB
TypeScript
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,
|
|
};
|
|
}
|