Unverified Commit 350c5539 authored by Zhou (Link)  Fang's avatar Zhou (Link) Fang Committed by GitHub
Browse files

fixed auto-fill issue for company member contact (#102)

parent ddf56c8e
...@@ -120,7 +120,7 @@ export function matchContactFields(existingContactData) { ...@@ -120,7 +120,7 @@ export function matchContactFields(existingContactData) {
); );
return { return {
company: { member: {
id: existingCompanyContact?.id || '', id: existingCompanyContact?.id || '',
firstName: existingCompanyContact?.first_name || '', firstName: existingCompanyContact?.first_name || '',
lastName: existingCompanyContact?.last_name || '', lastName: existingCompanyContact?.last_name || '',
...@@ -315,7 +315,7 @@ export async function executeSendDataByStep(step, formData, formId, userId) { ...@@ -315,7 +315,7 @@ export async function executeSendDataByStep(step, formData, formId, userId) {
formId, formId,
end_point.contacts, end_point.contacts,
matchContactFieldsToBackend( matchContactFieldsToBackend(
formData.representative.company, formData.representative.member,
contact_type.COMPANY, contact_type.COMPANY,
formId formId
) )
......
...@@ -41,27 +41,27 @@ const Contacts = ({ formik }) => { ...@@ -41,27 +41,27 @@ const Contacts = ({ formik }) => {
useEffect(() => { useEffect(() => {
if (isMarketingSameAsCompany) { if (isMarketingSameAsCompany) {
const newValues = { const newValues = {
...formik.values.representative.company, ...formik.values.representative.member,
id: formik.values.representative.marketing.id || '', id: formik.values.representative.marketing.id || '',
sameAsCompany: formik.values.representative.marketing.sameAsCompany, sameAsCompany: formik.values.representative.marketing.sameAsCompany,
}; };
formik.setFieldValue('representative.marketing', newValues); formik.setFieldValue('representative.marketing', newValues);
} }
// eslint-disable-next-line react-hooks/exhaustive-deps // eslint-disable-next-line react-hooks/exhaustive-deps
}, [isMarketingSameAsCompany, formik.values.representative.company]); }, [isMarketingSameAsCompany, formik.values.representative.member]);
// update representative.accounting values based on related checkbox // update representative.accounting values based on related checkbox
useEffect(() => { useEffect(() => {
if (isAccountingSameAsCompany) { if (isAccountingSameAsCompany) {
const newValues = { const newValues = {
...formik.values.representative.company, ...formik.values.representative.member,
id: formik.values.representative.accounting.id || '', id: formik.values.representative.accounting.id || '',
sameAsCompany: formik.values.representative.accounting.sameAsCompany, sameAsCompany: formik.values.representative.accounting.sameAsCompany,
}; };
formik.setFieldValue('representative.accounting', newValues); formik.setFieldValue('representative.accounting', newValues);
} }
// eslint-disable-next-line react-hooks/exhaustive-deps // eslint-disable-next-line react-hooks/exhaustive-deps
}, [isAccountingSameAsCompany, formik.values.representative.company]); }, [isAccountingSameAsCompany, formik.values.representative.member]);
const generateContacts = ( const generateContacts = (
representativeFields, representativeFields,
...@@ -114,7 +114,7 @@ const Contacts = ({ formik }) => { ...@@ -114,7 +114,7 @@ const Contacts = ({ formik }) => {
the Member Representative. the Member Representative.
</p> </p>
<div className="row"> <div className="row">
{generateContacts(companyRep, 'company-rep', 'company', false)} {generateContacts(companyRep, 'company-rep', 'member', false)}
</div> </div>
<h4 className="fw-600" id="marketing-rep"> <h4 className="fw-600" id="marketing-rep">
......
...@@ -69,25 +69,25 @@ const Review = ({ values, submitForm }) => { ...@@ -69,25 +69,25 @@ const Review = ({ values, submitForm }) => {
<div className="col-md-6"> <div className="col-md-6">
<label>First Name</label> <label>First Name</label>
<div className="preview-field"> <div className="preview-field">
{values.representative.company.firstName} {values.representative.member.firstName}
</div> </div>
</div> </div>
<div className="col-md-6"> <div className="col-md-6">
<label>Last Name</label> <label>Last Name</label>
<div className="preview-field"> <div className="preview-field">
{values.representative.company.lastName} {values.representative.member.lastName}
</div> </div>
</div> </div>
<div className="col-md-6"> <div className="col-md-6">
<label>Job Title</label> <label>Job Title</label>
<div className="preview-field"> <div className="preview-field">
{values.representative.company.jobtitle} {values.representative.member.jobtitle}
</div> </div>
</div> </div>
<div className="col-md-6"> <div className="col-md-6">
<label>Email</label> <label>Email</label>
<div className="preview-field"> <div className="preview-field">
{values.representative.company.email} {values.representative.member.email}
</div> </div>
</div> </div>
</div> </div>
......
...@@ -35,7 +35,7 @@ export const initialValues = { ...@@ -35,7 +35,7 @@ export const initialValues = {
// Step1: Representatives // Step1: Representatives
representative: { representative: {
company: { member: {
id: '', id: '',
firstName: '', firstName: '',
lastName: '', lastName: '',
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment