Skip to content

Commit

Permalink
refactor: minor refactors to address codefactor feedback
Browse files Browse the repository at this point in the history
- removes unnecessary `true &&...` expression
- refactors onClick handler for currency selector in TreeDonations
  • Loading branch information
mohitb35 committed Dec 3, 2024
1 parent 71554b5 commit f2574c1
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 24 deletions.
44 changes: 21 additions & 23 deletions src/Donations/Components/ContactsForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -401,29 +401,27 @@ function ContactsForm(): ReactElement {
</div>
<div style={{ width: "20px" }} />
<div className={"form-field mt-30 flex-1"}>
{true && (
<Controller
name="zipCode"
control={control}
rules={{
required: t("zipCodeRequired"),
pattern: {
value: postalRegex as RegExp,
message: t("zipCodeInvalid"),
},
}}
render={({ field: { onChange, value, onBlur } }) => (
<MaterialTextField
onChange={onChange}
onBlur={onBlur}
value={value}
label={t("zipCode")}
variant="outlined"
data-test-id="test-zipCode"
/>
)}
/>
)}
<Controller
name="zipCode"
control={control}
rules={{
required: t("zipCodeRequired"),
pattern: {
value: postalRegex as RegExp,
message: t("zipCodeInvalid"),
},
}}
render={({ field: { onChange, value, onBlur } }) => (
<MaterialTextField
onChange={onChange}
onBlur={onBlur}
value={value}
label={t("zipCode")}
variant="outlined"
data-test-id="test-zipCode"
/>
)}
/>
{errors.zipCode !== undefined && (
<div className={"form-errors"}>{errors.zipCode.message}</div>
)}
Expand Down
2 changes: 1 addition & 1 deletion src/Donations/Micros/DonationTypes/TreeDonation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ function TreeDonation({ setopenCurrencyModal }: Props): ReactElement {
<button
onClick={() => {
// Lock the currency/country change if planetCash is active
!isPlanetCashActive && setopenCurrencyModal(true);
if (!isPlanetCashActive) setopenCurrencyModal(true);
}}
className="text-bold text-primary"
style={{
Expand Down

0 comments on commit f2574c1

Please sign in to comment.