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) {
);
return {
company: {
member: {
id: existingCompanyContact?.id || '',
firstName: existingCompanyContact?.first_name || '',
lastName: existingCompanyContact?.last_name || '',
......@@ -315,7 +315,7 @@ export async function executeSendDataByStep(step, formData, formId, userId) {
formId,
end_point.contacts,
matchContactFieldsToBackend(
formData.representative.company,
formData.representative.member,
contact_type.COMPANY,
formId
)
......
......@@ -41,27 +41,27 @@ const Contacts = ({ formik }) => {
useEffect(() => {
if (isMarketingSameAsCompany) {
const newValues = {
...formik.values.representative.company,
...formik.values.representative.member,
id: formik.values.representative.marketing.id || '',
sameAsCompany: formik.values.representative.marketing.sameAsCompany,
};
formik.setFieldValue('representative.marketing', newValues);
}
// 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
useEffect(() => {
if (isAccountingSameAsCompany) {
const newValues = {
...formik.values.representative.company,
...formik.values.representative.member,
id: formik.values.representative.accounting.id || '',
sameAsCompany: formik.values.representative.accounting.sameAsCompany,
};
formik.setFieldValue('representative.accounting', newValues);
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [isAccountingSameAsCompany, formik.values.representative.company]);
}, [isAccountingSameAsCompany, formik.values.representative.member]);
const generateContacts = (
representativeFields,
......@@ -114,7 +114,7 @@ const Contacts = ({ formik }) => {
the Member Representative.
</p>
<div className="row">
{generateContacts(companyRep, 'company-rep', 'company', false)}
{generateContacts(companyRep, 'company-rep', 'member', false)}
</div>
<h4 className="fw-600" id="marketing-rep">
......
......@@ -69,25 +69,25 @@ const Review = ({ values, submitForm }) => {
<div className="col-md-6">
<label>First Name</label>
<div className="preview-field">
{values.representative.company.firstName}
{values.representative.member.firstName}
</div>
</div>
<div className="col-md-6">
<label>Last Name</label>
<div className="preview-field">
{values.representative.company.lastName}
{values.representative.member.lastName}
</div>
</div>
<div className="col-md-6">
<label>Job Title</label>
<div className="preview-field">
{values.representative.company.jobtitle}
{values.representative.member.jobtitle}
</div>
</div>
<div className="col-md-6">
<label>Email</label>
<div className="preview-field">
{values.representative.company.email}
{values.representative.member.email}
</div>
</div>
</div>
......
......@@ -35,7 +35,7 @@ export const initialValues = {
// Step1: Representatives
representative: {
company: {
member: {
id: '',
firstName: '',
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