Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(postal code) - disable submitted postal codes #3670

Merged
merged 2 commits into from
Nov 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ interface AddressInputsProps {
address: Address;
handleInputChange: (field: string, value: string) => void;
isAlbertaAddress?: boolean;
readOnly?: boolean;
// eslint-disable-next-line
errors?: any;
handleOnBlur: (field: string) => void;
Expand All @@ -17,6 +18,7 @@ export const AddressInputs: React.FC<AddressInputsProps> = ({
address,
handleInputChange,
isAlbertaAddress,
readOnly,
errors,
handleOnBlur,
requiredFields,
Expand All @@ -43,6 +45,8 @@ export const AddressInputs: React.FC<AddressInputsProps> = ({
<GoAInput
name="addressLine2"
testId="address-form-address2"
disabled={readOnly}
readonly={readOnly}
ariaLabel={'address-form-address2'}
placeholder="Unit number, suite, apartment"
value={address?.addressLine2 || ''}
Expand All @@ -61,6 +65,8 @@ export const AddressInputs: React.FC<AddressInputsProps> = ({
name="municipality"
testId="address-form-city"
ariaLabel={'address-form-city'}
disabled={readOnly}
readonly={readOnly}
value={address?.municipality || ''}
onChange={(name, value) => handleInputChange(name, value)}
onBlur={(name, value) => handleOnBlur(name)}
Expand All @@ -76,6 +82,8 @@ export const AddressInputs: React.FC<AddressInputsProps> = ({
name="postalCode"
testId="address-form-postal-code"
ariaLabel={'address-form-postal-code'}
disabled={readOnly}
readonly={readOnly}
placeholder="A0A 0A0"
value={address?.postalCode || ''}
onChange={(name, value) => handleInputChange(name, value)}
Expand All @@ -91,7 +99,7 @@ export const AddressInputs: React.FC<AddressInputsProps> = ({
{isAlbertaAddress && <LabelDiv data-testid="address-form-province">Alberta</LabelDiv>}
{!isAlbertaAddress && (
<GoADropdown
name="province"
name="subdivisionCode"
testId="address-form-province-dropdown"
ariaLabel={'address-form-province'}
value={address?.subdivisionCode || ''}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ type AddressLookUpProps = ControlProps;
const ADDRESS_PATH = 'api/gateway/v1/address/v1/find';

export const AddressLookUpControl = (props: AddressLookUpProps): JSX.Element => {
const { data, path, schema, handleChange, uischema } = props;
const { data, path, schema, enabled, handleChange, uischema, rootSchema } = props;

const isAlbertaAddress = schema?.properties?.subdivisionCode?.const === 'AB';
const formCtx = useContext(JsonFormContext);
Expand Down Expand Up @@ -121,15 +121,18 @@ export const AddressLookUpControl = (props: AddressLookUpProps): JSX.Element =>
delete errors[name];
}
};
const readOnly = uischema?.options?.componentProps?.readOnly ?? false;
return (
<div>
{renderHelp()}
<GoAFormItem label={label} error={errors?.['addressLine1'] ?? ''} data-testId="form-address-line1">
<SearchBox>
<GoAInput
leadingIcon={autocompletion ? 'search' : undefined}
leadingIcon={autocompletion && enabled ? 'search' : undefined}
name="addressLine1"
testId="address-form-address1"
readonly={readOnly}
disabled={!enabled}
ariaLabel={'address-form-address1'}
placeholder="Start typing the first line of your address, required."
value={address?.addressLine1 || ''}
Expand All @@ -156,6 +159,7 @@ export const AddressLookUpControl = (props: AddressLookUpProps): JSX.Element =>
<AddressInputs
address={address}
errors={errors}
readOnly={readOnly}
handleInputChange={handleInputChange}
isAlbertaAddress={isAlbertaAddress}
handleOnBlur={handleRequiredFieldBlur}
Expand Down