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); return () => document.removeEventListener("keydown", handleKey);
}, [isOpen, onClose]); }, [isOpen, onClose]);
const closeDialog = () => {
if (onClose) {
onClose();
}
};
if (!isOpen) return null; if (!isOpen) return null;
return ( return (
<div <div
className="fixed inset-0 z-50 flex items-center justify-center p-4 sm:p-6 overflow-auto" 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 className="fixed top-0 left-0 w-full h-full bg-black/50" />
<div <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", "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 className
)} )}
onClick={(e) => e.stopPropagation()}
> >
{showCloseButton && ( {showCloseButton && (
<button <button
onClick={onClose} onClick={(e) => {
e.stopPropagation();
closeDialog();
}}
className="absolute top-4 right-4 p-1 text-gray-500 hover:text-black" className="absolute top-4 right-4 p-1 text-gray-500 hover:text-black"
> >
<XIcon /> <XIcon />

View File

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