fix(registratura): 5 post-3.02 fixes - QuickContact pre-fill (useEffect sync), form close on contact create (stopPropagation), Switch label 'Inchis' -> 'Status', CU moved from Avize to own category, close guard for active deadlines
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
"use client";
|
||||
|
||||
import { useState } from "react";
|
||||
import { useState, useEffect } from "react";
|
||||
import { UserPlus } from "lucide-react";
|
||||
import { Input } from "@/shared/components/ui/input";
|
||||
import { Label } from "@/shared/components/ui/label";
|
||||
@@ -35,24 +35,28 @@ export function QuickContactDialog({
|
||||
const [phone, setPhone] = useState("");
|
||||
const [email, setEmail] = useState("");
|
||||
|
||||
// Reset when dialog opens with new name
|
||||
const handleOpenChange = (o: boolean) => {
|
||||
if (o) {
|
||||
// Sync name with initialName whenever the dialog opens
|
||||
// (useState(initialName) only works on first mount; controlled open
|
||||
// bypasses onOpenChange so we need useEffect)
|
||||
useEffect(() => {
|
||||
if (open) {
|
||||
setName(initialName);
|
||||
setPhone("");
|
||||
setEmail("");
|
||||
}
|
||||
onOpenChange(o);
|
||||
};
|
||||
}, [open, initialName]);
|
||||
|
||||
const handleSubmit = (e: React.FormEvent) => {
|
||||
e.preventDefault();
|
||||
// Stop propagation so the submit doesn't bubble through the React portal
|
||||
// to the outer registry-entry-form, which would close the whole form.
|
||||
e.stopPropagation();
|
||||
if (!name.trim()) return;
|
||||
onConfirm({ name: name.trim(), phone: phone.trim(), email: email.trim() });
|
||||
};
|
||||
|
||||
return (
|
||||
<Dialog open={open} onOpenChange={handleOpenChange}>
|
||||
<Dialog open={open} onOpenChange={onOpenChange}>
|
||||
<DialogContent className="sm:max-w-md">
|
||||
<DialogHeader>
|
||||
<DialogTitle className="flex items-center gap-2">
|
||||
|
||||
Reference in New Issue
Block a user