feat: remove contact_type from DetailContact component

This commit is contained in:
2025-12-03 10:49:16 +07:00
parent c82d6d39c1
commit 0694497f8d

View File

@@ -14,7 +14,6 @@ const DetailContact = memo(function DetailContact(props) {
name: '',
phone: '',
is_active: true,
contact_type: '',
};
const [formData, setFormData] = useState(defaultData);
@@ -37,13 +36,7 @@ const DetailContact = memo(function DetailContact(props) {
}
};
const handleContactTypeChange = (value) => {
setFormData((prev) => ({
...prev,
contact_type: value,
}));
};
const handleStatusToggle = (checked) => {
setFormData({
...formData,
@@ -58,7 +51,6 @@ const DetailContact = memo(function DetailContact(props) {
const validationRules = [
{ field: 'name', label: 'Contact Name', required: true },
{ field: 'phone', label: 'Phone', required: true },
{ field: 'contact_type', label: 'Contact Type', required: true },
];
if (
@@ -97,7 +89,6 @@ const DetailContact = memo(function DetailContact(props) {
contact_name: formData.name,
contact_phone: formData.phone.replace(/[\s\-\(\)]/g, ''), // Clean phone number
is_active: formData.is_active,
contact_type: formData.contact_type,
};
let response;
@@ -145,18 +136,16 @@ const DetailContact = memo(function DetailContact(props) {
phone: props.selectedData.contact_phone || props.selectedData.phone,
is_active:
props.selectedData.is_active || props.selectedData.status === 'active',
contact_type: props.selectedData.contact_type || props.contactType || '',
});
} else if (props.actionMode === 'add') {
setFormData({
name: '',
phone: '',
is_active: true,
contact_type: props.contactType === 'all' ? '' : props.contactType || '',
});
}
}
}, [props.showModal, props.actionMode, props.selectedData, props.contactType]);
}, [props.showModal, props.actionMode, props.selectedData]);
return (
<Modal