diff --git a/src/staff/components/StaffPasswordResetDialog/StaffPasswordResetDialog.tsx b/src/staff/components/StaffPasswordResetDialog/StaffPasswordResetDialog.tsx new file mode 100644 index 000000000..500d9fa9e --- /dev/null +++ b/src/staff/components/StaffPasswordResetDialog/StaffPasswordResetDialog.tsx @@ -0,0 +1,113 @@ +import React from "react"; +import Button from "@material-ui/core/Button"; +import Dialog from "@material-ui/core/Dialog"; +import DialogActions from "@material-ui/core/DialogActions"; +import DialogContent from "@material-ui/core/DialogContent"; +import TextField from "@material-ui/core/TextField"; +import DialogTitle from "@material-ui/core/DialogTitle"; +import { FormattedMessage, useIntl } from "react-intl"; + +import { DialogProps, UserError } from "@saleor/types"; +import { buttonMessages } from "@saleor/intl"; +import Form from "@saleor/components/Form"; +import ConfirmButton, { + ConfirmButtonTransitionState +} from "@saleor/components/ConfirmButton"; +import FormSpacer from "@saleor/components/FormSpacer"; + +interface StaffPasswordResetDialogFormData { + password: string; + previousPassword: string; +} +export interface StaffPasswordResetDialogProps extends DialogProps { + confirmButtonState: ConfirmButtonTransitionState; + errors: UserError[]; + onSubmit: (password: string) => void; +} + +const initialForm: StaffPasswordResetDialogFormData = { + password: "", + previousPassword: "" +}; + +const StaffPasswordResetDialog: React.FC = ({ + confirmButtonState, + errors: apiErrors, + open, + onClose, + onSubmit +}) => { + const intl = useIntl(); + + return ( + + + + +
onSubmit(data.password)} + > + {({ change, data, errors, submit }) => ( + <> + + + + + + + + + + + + + )} +
+
+ ); +}; + +StaffPasswordResetDialog.displayName = "StaffPasswordResetDialog"; +export default StaffPasswordResetDialog; diff --git a/src/staff/components/StaffPasswordResetDialog/index.ts b/src/staff/components/StaffPasswordResetDialog/index.ts new file mode 100644 index 000000000..4bffd3362 --- /dev/null +++ b/src/staff/components/StaffPasswordResetDialog/index.ts @@ -0,0 +1,2 @@ +export { default } from "./StaffPasswordResetDialog"; +export * from "./StaffPasswordResetDialog"; diff --git a/src/staff/views/StaffDetails.tsx b/src/staff/views/StaffDetails.tsx index 7d54e099c..c2a165069 100644 --- a/src/staff/views/StaffDetails.tsx +++ b/src/staff/views/StaffDetails.tsx @@ -27,6 +27,7 @@ import { staffMemberDetailsUrl, StaffMemberDetailsUrlQueryParams } from "../urls"; +import StaffPasswordResetDialog from "../components/StaffPasswordResetDialog"; interface OrderListProps { id: string; @@ -40,6 +41,14 @@ export const StaffDetails: React.FC = ({ id, params }) => { const intl = useIntl(); const shop = useShop(); + const closeModal = () => + navigate( + staffMemberDetailsUrl(id, { + ...params, + action: undefined + }) + ); + return ( = ({ id, params }) => { })} confirmButtonState={deleteTransitionState} variant="delete" - onClose={() => - navigate(staffMemberDetailsUrl(id)) - } + onClose={closeModal} onConfirm={deleteStaffMember} > @@ -204,9 +211,7 @@ export const StaffDetails: React.FC = ({ id, params }) => { })} confirmButtonState={deleteAvatarTransitionState} variant="delete" - onClose={() => - navigate(staffMemberDetailsUrl(id)) - } + onClose={closeModal} onConfirm={deleteStaffAvatar} > @@ -222,6 +227,13 @@ export const StaffDetails: React.FC = ({ id, params }) => { /> + undefined} + /> ); }}