This commit is contained in:
MehrdadAdabi 2025-11-26 19:12:57 +03:30
parent 70959e878f
commit 43e2957c22
2 changed files with 15 additions and 4 deletions

View File

@ -27,12 +27,18 @@ export const Dialog: FC<DialogProps> = ({
return () => document.removeEventListener("keydown", handleKey);
}, [isOpen, onClose]);
const closeDialog = () => {
if (onClose) {
onClose();
}
};
if (!isOpen) return null;
return (
<div
className="fixed inset-0 z-50 flex items-center justify-center p-4 sm:p-6 overflow-auto"
onClick={onClose}
onClick={closeDialog}
>
<div className="fixed top-0 left-0 w-full h-full bg-black/50" />
<div
@ -40,11 +46,13 @@ export const Dialog: FC<DialogProps> = ({
"relative z-10 w-full max-w-md sm:max-w-lg bg-white rounded-lg shadow-lg p-6 sm:p-8 overflow-auto",
className
)}
onClick={(e) => e.stopPropagation()}
>
{showCloseButton && (
<button
onClick={onClose}
onClick={(e) => {
e.stopPropagation();
closeDialog();
}}
className="absolute top-4 right-4 p-1 text-gray-500 hover:text-black"
>
<XIcon />

View File

@ -109,6 +109,7 @@ export function LoginPage() {
const handleCancel = () => {
setPhoneNumber("");
setError("");
setIsDialogOpen(false);
};
const handleOtpSubmit = () => {
@ -190,7 +191,9 @@ export function LoginPage() {
isOpen={otpDialog}
otpValue={otp}
onChange={setOtp}
onClose={() => setIsDialogOpen(false)}
onClose={() => {
setIsDialogOpen(false);
}}
onSubmit={handleOtpSubmit}
submitLoading={submitLoading}
/>