Code cleanup
This commit is contained in:
parent
1bded89d1e
commit
01a83f8aa1
2 changed files with 13 additions and 16 deletions
|
@ -17,8 +17,8 @@ import FormSpacer from "@saleor/components/FormSpacer";
|
||||||
import useModalDialogErrors from "@saleor/hooks/useModalDialogErrors";
|
import useModalDialogErrors from "@saleor/hooks/useModalDialogErrors";
|
||||||
|
|
||||||
interface StaffPasswordResetDialogFormData {
|
interface StaffPasswordResetDialogFormData {
|
||||||
password: string;
|
newPassword: string;
|
||||||
previousPassword: string;
|
oldPassword: string;
|
||||||
}
|
}
|
||||||
export interface StaffPasswordResetDialogProps extends DialogProps {
|
export interface StaffPasswordResetDialogProps extends DialogProps {
|
||||||
confirmButtonState: ConfirmButtonTransitionState;
|
confirmButtonState: ConfirmButtonTransitionState;
|
||||||
|
@ -27,8 +27,8 @@ export interface StaffPasswordResetDialogProps extends DialogProps {
|
||||||
}
|
}
|
||||||
|
|
||||||
const initialForm: StaffPasswordResetDialogFormData = {
|
const initialForm: StaffPasswordResetDialogFormData = {
|
||||||
password: "",
|
newPassword: "",
|
||||||
previousPassword: ""
|
oldPassword: ""
|
||||||
};
|
};
|
||||||
|
|
||||||
const StaffPasswordResetDialog: React.FC<StaffPasswordResetDialogProps> = ({
|
const StaffPasswordResetDialog: React.FC<StaffPasswordResetDialogProps> = ({
|
||||||
|
@ -54,33 +54,33 @@ const StaffPasswordResetDialog: React.FC<StaffPasswordResetDialogProps> = ({
|
||||||
<>
|
<>
|
||||||
<DialogContent>
|
<DialogContent>
|
||||||
<TextField
|
<TextField
|
||||||
error={!!errors.previousPassword}
|
error={!!errors.oldPassword}
|
||||||
fullWidth
|
fullWidth
|
||||||
helperText={errors.previousPassword}
|
helperText={errors.oldPassword}
|
||||||
label={intl.formatMessage({
|
label={intl.formatMessage({
|
||||||
defaultMessage: "Previous Password",
|
defaultMessage: "Previous Password",
|
||||||
description: "input label"
|
description: "input label"
|
||||||
})}
|
})}
|
||||||
name="previousPassword"
|
name="oldPassword"
|
||||||
type="password"
|
type="password"
|
||||||
onChange={change}
|
onChange={change}
|
||||||
/>
|
/>
|
||||||
<FormSpacer />
|
<FormSpacer />
|
||||||
<TextField
|
<TextField
|
||||||
error={!!errors.password}
|
error={!!errors.newPassword}
|
||||||
fullWidth
|
fullWidth
|
||||||
helperText={
|
helperText={
|
||||||
errors.password ||
|
errors.newPassword ||
|
||||||
intl.formatMessage({
|
intl.formatMessage({
|
||||||
defaultMessage:
|
defaultMessage:
|
||||||
"New password must be at least 5 characters long"
|
"New newPassword must be at least 8 characters long"
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
label={intl.formatMessage({
|
label={intl.formatMessage({
|
||||||
defaultMessage: "New Password",
|
defaultMessage: "New Password",
|
||||||
description: "input label"
|
description: "input label"
|
||||||
})}
|
})}
|
||||||
name="password"
|
name="newPassword"
|
||||||
type="password"
|
type="password"
|
||||||
onChange={change}
|
onChange={change}
|
||||||
/>
|
/>
|
||||||
|
@ -90,7 +90,7 @@ const StaffPasswordResetDialog: React.FC<StaffPasswordResetDialogProps> = ({
|
||||||
<FormattedMessage {...buttonMessages.back} />
|
<FormattedMessage {...buttonMessages.back} />
|
||||||
</Button>
|
</Button>
|
||||||
<ConfirmButton
|
<ConfirmButton
|
||||||
disabled={data.password.length <= 4}
|
disabled={!(data.newPassword.length >= 8)}
|
||||||
transitionState={confirmButtonState}
|
transitionState={confirmButtonState}
|
||||||
color="primary"
|
color="primary"
|
||||||
variant="contained"
|
variant="contained"
|
||||||
|
|
|
@ -261,10 +261,7 @@ export const StaffDetails: React.FC<OrderListProps> = ({ id, params }) => {
|
||||||
onClose={closeModal}
|
onClose={closeModal}
|
||||||
onSubmit={data =>
|
onSubmit={data =>
|
||||||
changePassword({
|
changePassword({
|
||||||
variables: {
|
variables: data
|
||||||
newPassword: data.password,
|
|
||||||
oldPassword: data.previousPassword
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
|
|
Loading…
Reference in a new issue