From d93cd4a95865297c7de5d930326f117e063f24ba Mon Sep 17 00:00:00 2001 From: dougfabris Date: Wed, 16 Oct 2024 10:37:26 -0300 Subject: [PATCH] chore: remove unnecessary `id` from `EditContactInfo` --- .../views/omnichannel/contactInfo/EditContactInfo.tsx | 7 +++---- .../omnichannel/contactInfo/EditContactInfoWithData.tsx | 2 +- .../views/omnichannel/directory/ContactContextualBar.tsx | 2 +- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/apps/meteor/client/views/omnichannel/contactInfo/EditContactInfo.tsx b/apps/meteor/client/views/omnichannel/contactInfo/EditContactInfo.tsx index f77cee014c784..ddfcfa4973e92 100644 --- a/apps/meteor/client/views/omnichannel/contactInfo/EditContactInfo.tsx +++ b/apps/meteor/client/views/omnichannel/contactInfo/EditContactInfo.tsx @@ -25,7 +25,6 @@ import { useCustomFieldsMetadata } from '../directory/hooks/useCustomFieldsMetad import { useContactRoute } from '../hooks/useContactRoute'; type ContactNewEditProps = { - id: string; contactData?: Serialized | null; onClose: () => void; onCancel: () => void; @@ -63,7 +62,7 @@ const getInitialValues = (data: ContactNewEditProps['contactData']): ContactForm }; }; -const EditContactInfo = ({ id, contactData, onClose, onCancel }: ContactNewEditProps): ReactElement => { +const EditContactInfo = ({ contactData, onClose, onCancel }: ContactNewEditProps): ReactElement => { const t = useTranslation(); const dispatchToastMessage = useToastMessageDispatch(); const queryClient = useQueryClient(); @@ -122,7 +121,7 @@ const EditContactInfo = ({ id, contactData, onClose, onCancel }: ContactNewEditP } const { contact } = await getContact({ email: emailValue }); - return (!contact || contact._id === id) && !isDuplicated ? true : t('Email_already_exists'); + return (!contact || contact._id === contactData?._id) && !isDuplicated ? true : t('Email_already_exists'); }; const validatePhone = async (phoneValue: string) => { @@ -130,7 +129,7 @@ const EditContactInfo = ({ id, contactData, onClose, onCancel }: ContactNewEditP const isDuplicated = currentPhones.filter((phone) => phone === phoneValue).length > 1; const { contact } = await getContact({ phone: phoneValue }); - return (!contact || contact._id === id) && !isDuplicated ? true : t('Phone_already_exists'); + return (!contact || contact._id === contactData?._id) && !isDuplicated ? true : t('Phone_already_exists'); }; const validateName = (v: string): string | boolean => (!v.trim() ? t('Required_field', { field: t('Name') }) : true); diff --git a/apps/meteor/client/views/omnichannel/contactInfo/EditContactInfoWithData.tsx b/apps/meteor/client/views/omnichannel/contactInfo/EditContactInfoWithData.tsx index bd0105d6da9b8..68137b02e75e5 100644 --- a/apps/meteor/client/views/omnichannel/contactInfo/EditContactInfoWithData.tsx +++ b/apps/meteor/client/views/omnichannel/contactInfo/EditContactInfoWithData.tsx @@ -30,7 +30,7 @@ const EditContactInfoWithData = ({ id, onClose, onCancel }: EditContactInfoWithD return {t('Contact_not_found')}; } - return ; + return ; }; export default EditContactInfoWithData; diff --git a/apps/meteor/client/views/omnichannel/directory/ContactContextualBar.tsx b/apps/meteor/client/views/omnichannel/directory/ContactContextualBar.tsx index ac3d45edb8eda..48f26d3173979 100644 --- a/apps/meteor/client/views/omnichannel/directory/ContactContextualBar.tsx +++ b/apps/meteor/client/views/omnichannel/directory/ContactContextualBar.tsx @@ -19,7 +19,7 @@ const ContactContextualBar = () => { }; if (context === 'new') { - return ; + return ; } if (context === 'edit') {