Skip to content

Commit 0e2cbd1

Browse files
committed
Fix zone director form value
The form field path name needs to match the GQL input path name. This is what the API uses when there are certain field errors. This lets us transparently show API errors on certain fields. Like for example in this case, we can show that the user does not have the required director role.
1 parent a2ce62d commit 0e2cbd1

File tree

4 files changed

+6
-9
lines changed

4 files changed

+6
-9
lines changed

src/components/FieldZone/CreateFieldZone/CreateFieldZone.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export const CreateFieldZone = (props: CreateFieldZoneProps) => {
2929
const input: CreateFieldZoneInput = {
3030
fieldZone: {
3131
name: values.fieldZone.name,
32-
directorId: values.fieldZone.director!.id,
32+
directorId: values.fieldZone.directorId!.id,
3333
},
3434
};
3535

src/components/FieldZone/EditFieldZone/EditFieldZone.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export const EditFieldZone = (
2525
fieldZone: {
2626
id: fieldZone.id,
2727
name: fieldZone.name.value,
28-
director: fieldZone.director.value ?? undefined,
28+
directorId: fieldZone.director.value ?? null,
2929
},
3030
}),
3131
[fieldZone]
@@ -41,7 +41,7 @@ export const EditFieldZone = (
4141
fieldZone: {
4242
id: values.id,
4343
name: values.name,
44-
directorId: values.director?.id ?? null,
44+
directorId: values.directorId?.id,
4545
},
4646
};
4747

src/components/FieldZone/FieldZoneForm/FieldZoneForm.graphql

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ fragment FieldZoneForm on FieldZone {
99
canEdit
1010
canRead
1111
value {
12-
id
13-
fullName
12+
...UserLookupItem
1413
}
1514
}
1615
}

src/components/FieldZone/FieldZoneForm/FieldZoneForm.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export interface FieldZoneFormValues<Mutation extends FieldZoneMutation> {
1414
fieldZone: Merge<
1515
Mutation,
1616
{
17-
director?: Pick<UserLookupItemFragment, 'id' | 'fullName'>;
17+
directorId: UserLookupItemFragment | null;
1818
}
1919
>;
2020
}
@@ -45,9 +45,7 @@ export const FieldZoneForm = <Mutation extends FieldZoneMutation, R>({
4545
)}
4646
</SecuredField>
4747
<SecuredField obj={fieldZone} name="directorId">
48-
{(props) => (
49-
<UserField {...props} name="director" label="Director" required />
50-
)}
48+
{(props) => <UserField {...props} label="Director" required />}
5149
</SecuredField>
5250
</Stack>
5351
</FieldGroup>

0 commit comments

Comments
 (0)