diff --git a/src/staff/components/StaffPasswordResetDialog/StaffPasswordResetDialog.tsx b/src/staff/components/StaffPasswordResetDialog/StaffPasswordResetDialog.tsx index 500d9fa9e..018980b25 100644 --- a/src/staff/components/StaffPasswordResetDialog/StaffPasswordResetDialog.tsx +++ b/src/staff/components/StaffPasswordResetDialog/StaffPasswordResetDialog.tsx @@ -22,7 +22,7 @@ interface StaffPasswordResetDialogFormData { export interface StaffPasswordResetDialogProps extends DialogProps { confirmButtonState: ConfirmButtonTransitionState; errors: UserError[]; - onSubmit: (password: string) => void; + onSubmit: (data: StaffPasswordResetDialogFormData) => void; } const initialForm: StaffPasswordResetDialogFormData = { @@ -47,11 +47,7 @@ const StaffPasswordResetDialog: React.FC = ({ description="dialog header" /> -
onSubmit(data.password)} - > + {({ change, data, errors, submit }) => ( <> diff --git a/src/staff/mutations.ts b/src/staff/mutations.ts index a3939ecc3..ee1dde297 100644 --- a/src/staff/mutations.ts +++ b/src/staff/mutations.ts @@ -1,5 +1,6 @@ import gql from "graphql-tag"; +import makeMutation from "@saleor/hooks/makeMutation"; import { TypedMutation } from "../mutations"; import { staffMemberDetailsFragment } from "./queries"; import { StaffAvatarDelete } from "./types/StaffAvatarDelete"; @@ -19,6 +20,10 @@ import { StaffMemberUpdate, StaffMemberUpdateVariables } from "./types/StaffMemberUpdate"; +import { + ChangeStaffPassword, + ChangeStaffPasswordVariables +} from "./types/ChangeStaffPassword"; const staffMemberAddMutation = gql` ${staffMemberDetailsFragment} @@ -114,3 +119,18 @@ export const TypedStaffAvatarDeleteMutation = TypedMutation< StaffAvatarDelete, StaffMemberDeleteVariables >(staffAvatarDeleteMutation); + +const changeStaffPassword = gql` + mutation ChangeStaffPassword($newPassword: String!, $oldPassword: String!) { + passwordChange(newPassword: $newPassword, oldPassword: $oldPassword) { + errors { + field + message + } + } + } +`; +export const useChangeStaffPassword = makeMutation< + ChangeStaffPassword, + ChangeStaffPasswordVariables +>(changeStaffPassword); diff --git a/src/staff/types/ChangeStaffPassword.ts b/src/staff/types/ChangeStaffPassword.ts new file mode 100644 index 000000000..18c15db12 --- /dev/null +++ b/src/staff/types/ChangeStaffPassword.ts @@ -0,0 +1,27 @@ +/* tslint:disable */ +/* eslint-disable */ +// This file was automatically generated and should not be edited. + +// ==================================================== +// GraphQL mutation operation: ChangeStaffPassword +// ==================================================== + +export interface ChangeStaffPassword_passwordChange_errors { + __typename: "Error"; + field: string | null; + message: string | null; +} + +export interface ChangeStaffPassword_passwordChange { + __typename: "PasswordChange"; + errors: ChangeStaffPassword_passwordChange_errors[] | null; +} + +export interface ChangeStaffPassword { + passwordChange: ChangeStaffPassword_passwordChange | null; +} + +export interface ChangeStaffPasswordVariables { + newPassword: string; + oldPassword: string; +}