Skip to content

Commit fdb19dc

Browse files
d-koppenhagenfmalcher
authored andcommitted
refactor: simplify updateSalutationAndPronoun logic
1 parent bf54615 commit fdb19dc

2 files changed

Lines changed: 6 additions & 10 deletions

File tree

src/app/identity-form/identity-form.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<select
44
name="gender-identity"
55
[field]="identity().gender"
6-
(change)="maybeUpdateSalutationAndPronoun()"
6+
(change)="updateSalutationAndPronoun()"
77
>
88
<option value="" selected>Please select</option>
99
<option value="male">Male</option>

src/app/identity-form/identity-form.ts

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,10 @@ export const identitySchema = schema<GenderIdentity>((path) => {
4242
export class IdentityForm {
4343
readonly identity = input.required<FieldTree<GenderIdentity>>();
4444

45-
protected maybeUpdateSalutationAndPronoun() {
46-
const gender = this.identity().gender().value();
47-
if (gender !== 'diverse') {
48-
this.identity().salutation().value.set('');
49-
this.identity().pronoun().value.set('');
50-
} else {
51-
this.identity().salutation().reset();
52-
this.identity().pronoun().reset();
53-
}
45+
protected updateSalutationAndPronoun() {
46+
this.identity().salutation().value.set('');
47+
this.identity().salutation().reset();
48+
this.identity().pronoun().value.set('');
49+
this.identity().pronoun().reset();
5450
}
5551
}

0 commit comments

Comments
 (0)