generated from bcgov/quickstart-openshift
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ORV2-2577: FE: Staff Accept Cash, Cheque, PoS and GA Payment Methods (#…
…1521) Co-authored-by: GlenAOT <[email protected]>
- Loading branch information
Showing
20 changed files
with
808 additions
and
219 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,4 +3,8 @@ | |
padding-bottom: 1.5rem; | ||
font-size: 1.5rem; | ||
} | ||
|
||
& &__options { | ||
gap: 1.5rem; | ||
} | ||
} |
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 |
---|---|---|
|
@@ -5,7 +5,6 @@ | |
border-radius: 0.25rem; | ||
|
||
& &__pay { | ||
max-width: 33rem; | ||
display: flex; | ||
flex-direction: column; | ||
|
||
|
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
22 changes: 22 additions & 0 deletions
22
...src/features/permits/pages/Application/components/pay/paymentOptions/GAPaymentOption.scss
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,22 @@ | ||
@use "./PaymentOptionStyles"; | ||
@import "../../../../../../../themes/orbcStyles"; | ||
|
||
@include PaymentOptionStyles.payment-option-style(".payment-option"); | ||
|
||
.payment-option { | ||
.label-text { | ||
font-size: 1.25rem; | ||
font-weight: bold; | ||
letter-spacing: -0.4px; | ||
} | ||
|
||
&--service-bc { | ||
.payment-details { | ||
display: block; | ||
|
||
&__info { | ||
width: 100%; | ||
} | ||
} | ||
} | ||
} |
111 changes: 111 additions & 0 deletions
111
.../src/features/permits/pages/Application/components/pay/paymentOptions/GAPaymentOption.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,111 @@ | ||
import { | ||
FormControl, | ||
FormControlLabel, | ||
FormHelperText, | ||
FormLabel, | ||
OutlinedInput, | ||
Radio, | ||
} from "@mui/material"; | ||
import { | ||
PAYMENT_METHOD_TYPE_CODE, | ||
PaymentMethodTypeCode, | ||
} from "../../../../../../../common/types/paymentMethods"; | ||
import { PaymentMethodData } from "../types/PaymentMethodData"; | ||
import { Controller, useFormContext } from "react-hook-form"; | ||
import { Nullable } from "../../../../../../../common/types/common"; | ||
import { requiredMessage } from "../../../../../../../common/helpers/validationMessages"; | ||
import { getErrorMessage } from "../../../../../../../common/components/form/CustomFormComponents"; | ||
import "./GAPaymentOption.scss"; | ||
|
||
const paymentMethod = PAYMENT_METHOD_TYPE_CODE.GA; | ||
|
||
const serviceBCOfficeIDRules = { | ||
validate: { | ||
requiredWhenSelected: ( | ||
value: Nullable<string>, | ||
formValues: PaymentMethodData, | ||
) => { | ||
return ( | ||
formValues.paymentMethod !== paymentMethod || | ||
(value != null && value.trim() !== "") || | ||
requiredMessage() | ||
); | ||
}, | ||
}, | ||
}; | ||
|
||
export const GAPaymentOption = ({ | ||
isSelected, | ||
handlePaymentMethodChange, | ||
}: { | ||
isSelected: boolean; | ||
handlePaymentMethodChange: ( | ||
selectedPaymentMethod: PaymentMethodTypeCode, | ||
) => void; | ||
}) => { | ||
const { | ||
control, | ||
register, | ||
formState: { errors }, | ||
} = useFormContext<PaymentMethodData>(); | ||
|
||
return ( | ||
<div | ||
role="radio" | ||
onClick={() => handlePaymentMethodChange(paymentMethod)} | ||
onKeyDown={() => true} | ||
className={ | ||
isSelected ? "payment-option payment-option--active" : "payment-option" | ||
} | ||
> | ||
<FormControlLabel | ||
className="label" | ||
componentsProps={{ | ||
typography: { | ||
className: "label__container", | ||
}, | ||
}} | ||
label={ | ||
<div className="label__text"> | ||
In-person at a Service BC Office (GA) | ||
</div> | ||
} | ||
value={paymentMethod} | ||
control={<Radio key="pay-by-ga" />} | ||
/> | ||
<div className="payment-details"> | ||
<Controller | ||
name="additionalPaymentData.serviceBCOfficeId" | ||
control={control} | ||
rules={serviceBCOfficeIDRules} | ||
render={({ field: { value }, fieldState: { invalid } }) => ( | ||
<FormControl className="payment-details__info" error={invalid}> | ||
<FormLabel className="payment-details__label"> | ||
Service BC Office ID Number | ||
</FormLabel> | ||
<OutlinedInput | ||
className={`payment-details__input payment-details__input ${ | ||
invalid ? "payment-details__input--err" : "" | ||
}`} | ||
defaultValue={value} | ||
{...register( | ||
"additionalPaymentData.serviceBCOfficeId", | ||
serviceBCOfficeIDRules, | ||
)} | ||
onChange={() => handlePaymentMethodChange(paymentMethod)} | ||
/> | ||
{invalid ? ( | ||
<FormHelperText className="payment-details__err" error> | ||
{getErrorMessage( | ||
errors, | ||
"additionalPaymentData.serviceBCOfficeId", | ||
)} | ||
</FormHelperText> | ||
) : null} | ||
</FormControl> | ||
)} | ||
/> | ||
</div> | ||
</div> | ||
); | ||
}; |
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
Oops, something went wrong.