Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Enable staff member editing
dominik-zeglenfb22627f20b8
diff --git a/saleor/static/dashboard-next/misc.ts b/saleor/static/dashboard-next/misc.tsindex 3bfca1251d..cb39bbc034 100644--- a/saleor/static/dashboard-next/misc.ts+++ b/saleor/static/dashboard-next/misc.ts@@ -190,7 +190,7 @@ export function getUserName(user?: User, returnEmail?: boolean) {export function getUserInitials(user?: User) {return user && (user.email || (user.firstName && user.lastName))? (user.firstName && user.lastName- ? user.firstName + user.lastName+ ? user.firstName[0] + user.lastName[0]: user.email.slice(0, 2)).toUpperCase(): null;diff --git a/saleor/static/dashboard-next/staff/components/StaffDetailsPage/StaffDetailsPage.tsx b/saleor/static/dashboard-next/staff/components/StaffDetailsPage/StaffDetailsPage.tsxindex 594ff1d8d2..f946b284a5 100644--- a/saleor/static/dashboard-next/staff/components/StaffDetailsPage/StaffDetailsPage.tsx+++ b/saleor/static/dashboard-next/staff/components/StaffDetailsPage/StaffDetailsPage.tsx@@ -25,6 +25,9 @@ interface FormData {hasFullAccess: boolean;isActive: boolean;permissions: PermissionEnum[];+ firstName: string;+ lastName: string;+ email: string;}const styles = (theme: Theme) =>@@ -61,6 +64,8 @@ const StaffDetailsPage = withStyles(styles, { name: "StaffDetailsPage" })(onSubmit}: StaffDetailsPageProps) => {const initialForm: FormData = {+ email: maybe(() => staffMember.email),+ firstName: maybe(() => staffMember.firstName),hasFullAccess: maybe(() =>permissions.filter(@@ -72,6 +77,7 @@ const StaffDetailsPage = withStyles(styles, { name: "StaffDetailsPage" })(false),isActive: maybe(() => staffMember.isActive, false),+ lastName: maybe(() => staffMember.lastName),permissions: maybe(() => staffMember.permissions, []).map(perm => perm.code)@@ -85,7 +91,10 @@ const StaffDetailsPage = withStyles(styles, { name: "StaffDetailsPage" })(<div><StaffPropertiesclassName={classes.card}+ data={data}+ disabled={disabled}staffMember={staffMember}+ onChange={change}/></div><div>diff --git a/saleor/static/dashboard-next/staff/components/StaffProperties/StaffProperties.tsx b/saleor/static/dashboard-next/staff/components/StaffProperties/StaffProperties.tsxindex 9bcb60bb4a..31310d86f0 100644--- a/saleor/static/dashboard-next/staff/components/StaffProperties/StaffProperties.tsx+++ b/saleor/static/dashboard-next/staff/components/StaffProperties/StaffProperties.tsx@@ -6,6 +6,7 @@ import {withStyles,WithStyles} from "@material-ui/core/styles";+import TextField from "@material-ui/core/TextField";import Typography from "@material-ui/core/Typography";import * as React from "react";@@ -37,6 +38,7 @@ const styles = (theme: Theme) =>propGrid: {display: "grid",gridColumnGap: theme.spacing.unit * 2 + "px",+ gridRowGap: theme.spacing.unit + "px",gridTemplateColumns: "1fr 1fr",[theme.breakpoints.down("xs")]: {gridTemplateColumns: "1fr"@@ -51,11 +53,24 @@ const styles = (theme: Theme) =>interface StaffPropertiesProps extends WithStyles<typeof styles> {className?: string;+ data: {+ email: string;+ firstName: string;+ lastName: string;+ };+ disabled: boolean;staffMember: StaffMemberDetails_user;+ onChange: (event: React.ChangeEvent<any>) => void;}const StaffProperties = withStyles(styles, { name: "StaffProperties" })(- ({ classes, className, staffMember }: StaffPropertiesProps) => (+ ({+ classes,+ className,+ data,+ staffMember,+ onChange+ }: StaffPropertiesProps) => (<Card className={className}><CardTitle title={i18n.t("Staff Member Information")} /><CardContent>@@ -70,40 +85,31 @@ const StaffProperties = withStyles(styles, { name: "StaffProperties" })(<div><div className={classes.propGrid}><div className={classes.prop}>- <Typography variant="body2">{i18n.t("First Name")}</Typography>- {maybe<React.ReactNode>(- () =>- staffMember.firstName ? (- <Typography>{staffMember.firstName}</Typography>- ) : (- <Typography color="textSecondary">- {i18n.t("No info")}- </Typography>- ),- <Skeleton />- )}+ <TextField+ label={i18n.t("First Name")}+ value={data.firstName}+ name="firstName"+ onChange={onChange}+ fullWidth+ /></div><div className={classes.prop}>- <Typography variant="body2">{i18n.t("Last Name")}</Typography>- {maybe<React.ReactNode>(- () =>- staffMember.lastName ? (- <Typography>{staffMember.lastName}</Typography>- ) : (- <Typography color="textSecondary">- {i18n.t("No info")}- </Typography>- ),- <Skeleton />- )}+ <TextField+ label={i18n.t("Last Name")}+ value={data.lastName}+ name="lastName"+ onChange={onChange}+ fullWidth+ /></div><div className={classes.prop}>- <Typography variant="body2">{i18n.t("E-mail")}</Typography>- {maybe(() => staffMember.email) === undefined ? (- <Skeleton />- ) : (- <Typography>{staffMember.email}</Typography>- )}+ <TextField+ label={i18n.t("E-mail")}+ value={data.email}+ name="email"+ onChange={onChange}+ fullWidth+ /></div></div></div>diff --git a/saleor/static/dashboard-next/staff/views/StaffDetails.tsx b/saleor/static/dashboard-next/staff/views/StaffDetails.tsxindex 402a5dac88..71485e1758 100644--- a/saleor/static/dashboard-next/staff/views/StaffDetails.tsx+++ b/saleor/static/dashboard-next/staff/views/StaffDetails.tsx@@ -85,7 +85,10 @@ export const StaffDetails: React.StatelessComponent<OrderListProps> = ({variables: {id,input: {+ email: variables.email,+ firstName: variables.firstName,isActive: variables.isActive,+ lastName: variables.lastName,permissions: variables.permissions}}