fixed update and creation for contacts
This commit is contained in:
parent
1a04dd51fc
commit
717264c9f9
@ -35,7 +35,7 @@ export const ContactSchema = z.object({
|
||||
tags: z
|
||||
.array(
|
||||
z.object({
|
||||
id: z.string().nullable(),
|
||||
id: z.string().nullable().optional(),
|
||||
name: z.string(),
|
||||
})
|
||||
)
|
||||
|
@ -87,6 +87,7 @@ const ManageContact = ({ contactId, closeModal }) => {
|
||||
: [{ label: "Office", phoneNumber: "" }],
|
||||
|
||||
contactCategoryId: contactData.contactCategory?.id || "",
|
||||
address: contactData?.address || "",
|
||||
projectIds: contactData.projects?.map((p) => p.id) || [],
|
||||
bucketIds: contactData.buckets?.map((b) => b.id) || [],
|
||||
tags: contactData.tags || [],
|
||||
@ -177,7 +178,6 @@ const ManageContact = ({ contactId, closeModal }) => {
|
||||
};
|
||||
|
||||
const isPending = updating || creating;
|
||||
|
||||
return (
|
||||
<FormProvider {...methods}>
|
||||
<form className="p-2 p-sm-0" onSubmit={handleSubmit(onSubmit)}>
|
||||
@ -205,12 +205,13 @@ const ManageContact = ({ contactId, closeModal }) => {
|
||||
<Label htmlFor={"organization"} required>
|
||||
Organization
|
||||
</Label>
|
||||
<InputSuggestions
|
||||
organizationList={organizationList}
|
||||
value={getValues("organization") || ""}
|
||||
onChange={(val) => setValue("organization", val)}
|
||||
error={errors.organization?.message}
|
||||
/>
|
||||
<InputSuggestions
|
||||
organizationList={organizationList}
|
||||
value={watch("organization") || ""}
|
||||
onChange={(val) => setValue("organization", val, { shouldValidate: true })}
|
||||
error={errors.organization?.message}
|
||||
/>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -471,13 +472,14 @@ const ManageContact = ({ contactId, closeModal }) => {
|
||||
|
||||
{/* Actions */}
|
||||
<div className="d-flex justify-content-end gap-3 py-2">
|
||||
<button className="btn btn-sm btn-primary" type="submit">
|
||||
<button className="btn btn-sm btn-primary" type="submit" disabled={isPending}>
|
||||
{isPending ? "Please Wait..." : "Submit"}
|
||||
</button>
|
||||
<button
|
||||
className="btn btn-sm btn-secondary"
|
||||
type="button"
|
||||
onClick={handleClosed}
|
||||
disabled={isPending}
|
||||
>
|
||||
Cancel
|
||||
</button>
|
||||
|
@ -8,7 +8,6 @@ const InputSuggestions = ({
|
||||
}) => {
|
||||
const [filteredList, setFilteredList] = useState([]);
|
||||
const [showSuggestions, setShowSuggestions] = useState(false);
|
||||
|
||||
const handleInputChange = (e) => {
|
||||
const val = e.target.value;
|
||||
onChange(val);
|
||||
|
Loading…
x
Reference in New Issue
Block a user