Fix types

This commit is contained in:
dominik-zeglen 2019-12-03 17:34:21 +01:00
parent a6f425ef39
commit 0bd2d52840
3 changed files with 49 additions and 6 deletions

View file

@ -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<StaffPasswordResetDialogProps> = ({
description="dialog header"
/>
</DialogTitle>
<Form
errors={apiErrors}
initial={initialForm}
onSubmit={data => onSubmit(data.password)}
>
<Form errors={apiErrors} initial={initialForm} onSubmit={onSubmit}>
{({ change, data, errors, submit }) => (
<>
<DialogContent>

View file

@ -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);

View file

@ -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;
}