-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3127 from glific/enhancement/erp
ERP: Modifications in registration form
- Loading branch information
Showing
12 changed files
with
449 additions
and
139 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -144,9 +144,15 @@ test('it should submit the form', async () => { | |
|
||
const inputFieldsOrgdetails = getAllByRole('textbox'); | ||
|
||
const [registeredAddress, gstin] = inputFieldsOrgdetails; | ||
const [line1, line2, city, state, country, pincode, gstin] = inputFieldsOrgdetails; | ||
|
||
fireEvent.change(line1, { target: { value: 'line1' } }); | ||
fireEvent.change(line2, { target: { value: 'line2' } }); | ||
fireEvent.change(city, { target: { value: 'City' } }); | ||
fireEvent.change(state, { target: { value: 'State' } }); | ||
fireEvent.change(country, { target: { value: 'Country' } }); | ||
fireEvent.change(pincode, { target: { value: '123456' } }); | ||
|
||
fireEvent.change(registeredAddress, { target: { value: 'address' } }); | ||
fireEvent.click(screen.getByRole('checkbox')); | ||
fireEvent.change(gstin, { target: { value: '123456789012345' } }); | ||
|
||
|
@@ -164,12 +170,13 @@ test('it should submit the form', async () => { | |
}); | ||
|
||
const inputFieldsPaymentdetails = getAllByRole('textbox'); | ||
const [name, designation, phone, email] = inputFieldsPaymentdetails; | ||
const [firstName, lastName, designation, phone, email] = inputFieldsPaymentdetails; | ||
|
||
const radioButtons = getAllByTestId('radio-btn'); | ||
fireEvent.click(radioButtons[1]); | ||
|
||
fireEvent.change(name, { target: { value: 'Default finance poc name' } }); | ||
fireEvent.change(firstName, { target: { value: 'finance poc firstName' } }); | ||
fireEvent.change(lastName, { target: { value: 'finance poc lastName' } }); | ||
fireEvent.change(designation, { target: { value: 'finance' } }); | ||
fireEvent.change(phone, { target: { value: '09421050449' } }); | ||
fireEvent.change(email, { target: { value: '[email protected]' } }); | ||
|
@@ -189,17 +196,23 @@ test('it should submit the form', async () => { | |
|
||
const inputFieldssigningdetails = getAllByRole('textbox'); | ||
const [ | ||
submitterName, | ||
submitterFirstName, | ||
submitterLastName, | ||
submitterDesignation, | ||
submitterEmail, | ||
signingAuthorityName, | ||
signingAuthorityFirstName, | ||
signingAuthorityLastName, | ||
signingAuthorityDesignation, | ||
signingAuthorityEmail, | ||
] = inputFieldssigningdetails; | ||
|
||
fireEvent.change(submitterName, { target: { value: 'Default submitter' } }); | ||
fireEvent.change(submitterFirstName, { target: { value: 'first name' } }); | ||
fireEvent.change(submitterLastName, { target: { value: 'last name' } }); | ||
fireEvent.change(submitterDesignation, { target: { value: 'submitter' } }); | ||
fireEvent.change(submitterEmail, { target: { value: '[email protected]' } }); | ||
|
||
fireEvent.change(signingAuthorityName, { target: { value: 'Default signing' } }); | ||
fireEvent.change(signingAuthorityFirstName, { target: { value: 'Default signing firstName' } }); | ||
fireEvent.change(signingAuthorityLastName, { target: { value: 'Default signing lastName' } }); | ||
fireEvent.change(signingAuthorityDesignation, { target: { value: 'signing authority' } }); | ||
fireEvent.change(signingAuthorityEmail, { target: { value: '[email protected]' } }); | ||
|
||
|
@@ -253,9 +266,14 @@ test('it should disgree and send an email', async () => { | |
|
||
const inputFieldsOrgdetails = getAllByRole('textbox'); | ||
|
||
const [registeredAddress, gstin] = inputFieldsOrgdetails; | ||
const [line1, line2, city, state, country, pincode, gstin] = inputFieldsOrgdetails; | ||
|
||
fireEvent.change(registeredAddress, { target: { value: 'address' } }); | ||
fireEvent.change(line1, { target: { value: 'line1' } }); | ||
fireEvent.change(line2, { target: { value: 'line2' } }); | ||
fireEvent.change(city, { target: { value: 'City' } }); | ||
fireEvent.change(state, { target: { value: 'State' } }); | ||
fireEvent.change(country, { target: { value: 'Country' } }); | ||
fireEvent.change(pincode, { target: { value: '123456' } }); | ||
fireEvent.click(screen.getByRole('checkbox')); | ||
fireEvent.change(gstin, { target: { value: '123456789012345' } }); | ||
|
||
|
@@ -266,12 +284,13 @@ test('it should disgree and send an email', async () => { | |
}); | ||
|
||
const inputFieldsPaymentdetails = getAllByRole('textbox'); | ||
const [name, designation, phone, email] = inputFieldsPaymentdetails; | ||
const [firstName, lastName, designation, phone, email] = inputFieldsPaymentdetails; | ||
|
||
const radioButtons = getAllByTestId('radio-btn'); | ||
fireEvent.click(radioButtons[1]); | ||
|
||
fireEvent.change(name, { target: { value: 'Default finance poc name' } }); | ||
fireEvent.change(firstName, { target: { value: 'finance poc firstName' } }); | ||
fireEvent.change(lastName, { target: { value: 'finance poc lastName' } }); | ||
fireEvent.change(designation, { target: { value: 'finance' } }); | ||
fireEvent.change(phone, { target: { value: '09421050449' } }); | ||
fireEvent.change(email, { target: { value: '[email protected]' } }); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
src/containers/Organization/Onboarding/Steps/Address/Address.module.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
.Label { | ||
font-size: 14px; | ||
font-weight: 500; | ||
color: #111; | ||
line-height: 22px; | ||
margin: 6px 0; | ||
display: flex; | ||
column-gap: 4px; | ||
} | ||
|
||
.Heading { | ||
composes: Label; | ||
font-size: 1rem; | ||
} | ||
|
||
.InputBox { | ||
width: 100%; | ||
} | ||
|
||
.OutlinedInput { | ||
padding: 12.5px 14px; | ||
} | ||
|
||
|
||
.AddressField { | ||
display: grid; | ||
grid-template-columns: repeat(2, 1fr); | ||
grid-template-rows: repeat(3, 1fr); | ||
grid-gap: 0.5rem; | ||
|
||
} | ||
|
||
.FullRow { | ||
grid-column-start: 1; | ||
grid-column-end: 3; | ||
} | ||
|
||
.Errors { | ||
font-size: 12px; | ||
margin: 0; | ||
margin-left: 14px; | ||
line-height: 18px; | ||
font-weight: 400; | ||
color: #fb5c5c; | ||
} |
77 changes: 77 additions & 0 deletions
77
src/containers/Organization/Onboarding/Steps/Address/Address.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import { OutlinedInput, Typography } from '@mui/material'; | ||
import { formatString } from 'common/utils'; | ||
import styles from './Address.module.css'; | ||
|
||
interface RegisteredAddressProps { | ||
inputLabel: string; | ||
inputLabelSubtext: any; | ||
address: any; | ||
disabled: boolean; | ||
form: { touched: any; errors: any; setFieldValue: any }; | ||
field: { name: string; value: any }; | ||
} | ||
|
||
export const RegisteredAddress = ({ | ||
inputLabel, | ||
address, | ||
disabled, | ||
inputLabelSubtext, | ||
form, | ||
field, | ||
}: RegisteredAddressProps) => { | ||
const handleChange = (e: any, value: any) => { | ||
form.setFieldValue(field.name, { | ||
...field.value, | ||
[value]: e.target.value, | ||
}); | ||
}; | ||
|
||
const errors = form.errors[field.name]; | ||
const touched = form.touched[field.name]; | ||
|
||
return ( | ||
<div> | ||
<Typography variant="caption" className={styles.Heading} data-testid="inputLabel"> | ||
{inputLabel} | ||
{inputLabelSubtext} | ||
</Typography> | ||
|
||
<div className={styles.AddressField}> | ||
{Object.keys(address) | ||
.slice(0, 2) | ||
.map((key) => ( | ||
<div className={styles.FullRow} key={key}> | ||
<p className={styles.Label}>{formatString(key)}</p> | ||
<OutlinedInput | ||
disabled={disabled} | ||
className={styles.InputBox} | ||
classes={{ input: styles.OutlinedInput }} | ||
onChange={(e) => handleChange(e, key)} | ||
value={field.value[key]} | ||
/> | ||
<p className={styles.Errors}> | ||
{touched && errors && touched[key] && errors[key] ? errors[key] : ''} | ||
</p> | ||
</div> | ||
))} | ||
{Object.keys(address) | ||
.slice(2) | ||
.map((key) => ( | ||
<div className={styles.Row} key={key}> | ||
<p className={styles.Label}>{formatString(key)}</p> | ||
<OutlinedInput | ||
disabled={disabled} | ||
className={styles.InputBox} | ||
classes={{ input: styles.OutlinedInput }} | ||
onChange={(e) => handleChange(e, key)} | ||
value={field.value[key]} | ||
/> | ||
<p className={styles.Errors}> | ||
{touched && errors && touched[key] && errors[key] ? errors[key] : ''} | ||
</p> | ||
</div> | ||
))} | ||
</div> | ||
</div> | ||
); | ||
}; |
Oops, something went wrong.