Skip to content

Commit

Permalink
Fix update user resolver to exclude branches as it is only changed by…
Browse files Browse the repository at this point in the history
… super admin via other resolvers
  • Loading branch information
MatoPlus committed Aug 30, 2022
1 parent d34f3c1 commit 516b7ba
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 16 deletions.
2 changes: 0 additions & 2 deletions backend/graphql/types/userType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ const userType = gql`
dateOfBirth: Date
pronouns: String!
skills: [ID!]!
branches: [ID!]!
languages: [ID!]!
}
Expand Down Expand Up @@ -160,7 +159,6 @@ const userType = gql`
emergencyContactEmail: String
dateOfBirth: Date
pronouns: String!
branches: [ID!]!
languages: [ID!]!
}
Expand Down
8 changes: 0 additions & 8 deletions backend/services/implementations/userService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -964,10 +964,6 @@ class UserService implements IUserService {
},
data: {
hireDate: volunteerUser.hireDate,
branches: {
set: [], // setting the related branches to be [] before connecting the passed in values
connect: convertToNumberIds(volunteerUser.branches),
},
skills: {
set: [], // setting the related skills to be [] before connecting the passed in values
connect: convertToNumberIds(volunteerUser.skills),
Expand Down Expand Up @@ -1452,10 +1448,6 @@ class UserService implements IUserService {
dateOfBirth: employeeUser.dateOfBirth,
},
},
branches: {
set: [],
connect: convertToNumberIds(employeeUser.branches),
},
},
include: {
branches: true,
Expand Down
10 changes: 8 additions & 2 deletions backend/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,10 @@ export type CreateVolunteerUserDTO = Omit<VolunteerUserRequestDTO, "id"> & {
token: string;
};

export type UpdateVolunteerUserDTO = Omit<VolunteerUserRequestDTO, "id">;
export type UpdateVolunteerUserDTO = Omit<
VolunteerUserRequestDTO,
"id" | "branches"
>;

export type EmployeeUserDTO = {
id: string;
Expand All @@ -99,7 +102,10 @@ export type CreateEmployeeUserDTO = Omit<EmployeeUserRequestDTO, "id"> & {
token: string;
};

export type UpdateEmployeeUserDTO = Omit<EmployeeUserRequestDTO, "id">;
export type UpdateEmployeeUserDTO = Omit<
EmployeeUserRequestDTO,
"id" | "branches"
>;

export type CreateUserDTO = Omit<UserDTO, "id" | "languages"> & {
password: string;
Expand Down
2 changes: 0 additions & 2 deletions frontend/src/components/user/AccountForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,6 @@ const AccountForm = ({
pronouns: values.pronouns,
dateOfBirth: values.dateOfBirth,
languages: values.languages.map((language) => language.id),
branches: [],
});
} else {
onVolunteerEdit({
Expand All @@ -260,7 +259,6 @@ const AccountForm = ({
dateOfBirth: moment(values.dateOfBirth).format("YYYY-MM-DD"),
skills: values.skills.map((skill) => skill.id),
languages: values.languages.map((language) => language.id),
branches: [],
});
}
}
Expand Down
10 changes: 8 additions & 2 deletions frontend/src/types/api/UserType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,10 @@ export type CreateVolunteerUserDTO = Omit<VolunteerUserRequestDTO, "id"> & {
token: string | null;
};

export type UpdateVolunteerUserDTO = Omit<VolunteerUserRequestDTO, "id">;
export type UpdateVolunteerUserDTO = Omit<
VolunteerUserRequestDTO,
"id" | "branches"
>;

export type EmployeeDTO = {
id: string;
Expand All @@ -74,7 +77,10 @@ export type CreateEmployeeUserDTO = Omit<EmployeeUserRequestDTO, "id"> & {
token: string | null;
};

export type UpdateEmployeeUserDTO = Omit<EmployeeUserRequestDTO, "id">;
export type UpdateEmployeeUserDTO = Omit<
EmployeeUserRequestDTO,
"id" | "branches"
>;

export type UserInviteResponseDTO = {
uuid: string;
Expand Down

0 comments on commit 516b7ba

Please sign in to comment.