Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Add first and last name to detail component
Lukasz Szewczykca9dfaeb05ac
diff --git a/saleor/static/dashboard-next/customers/components/CustomerCreateDetails/CustomerCreateDetails.tsx b/saleor/static/dashboard-next/customers/components/CustomerCreateDetails/CustomerCreateDetails.tsxindex 4393c2246a..6d742d9879 100644--- a/saleor/static/dashboard-next/customers/components/CustomerCreateDetails/CustomerCreateDetails.tsx+++ b/saleor/static/dashboard-next/customers/components/CustomerCreateDetails/CustomerCreateDetails.tsx@@ -58,7 +58,7 @@ const CustomerCreateDetails = withStyles(styles, {name="firstName"label={i18n.t("First Name")}helperText={errors.firstName}- type="firstName"+ type="text"value={data.email}onChange={onChange}/>@@ -69,7 +69,7 @@ const CustomerCreateDetails = withStyles(styles, {name="lastName"label={i18n.t("Last Name")}helperText={errors.lastName}- type="lastName"+ type="text"value={data.lastName}onChange={onChange}/>diff --git a/saleor/static/dashboard-next/customers/components/CustomerDetails/CustomerDetails.tsx b/saleor/static/dashboard-next/customers/components/CustomerDetails/CustomerDetails.tsxindex 9618385491..bc7afa58df 100644--- a/saleor/static/dashboard-next/customers/components/CustomerDetails/CustomerDetails.tsx+++ b/saleor/static/dashboard-next/customers/components/CustomerDetails/CustomerDetails.tsx@@ -1,6 +1,11 @@import Card from "@material-ui/core/Card";import CardContent from "@material-ui/core/CardContent";-import { createStyles, withStyles, WithStyles } from "@material-ui/core/styles";+import {+ createStyles,+ Theme,+ withStyles,+ WithStyles+} from "@material-ui/core/styles";import TextField from "@material-ui/core/TextField";import Typography from "@material-ui/core/Typography";import * as moment from "moment-timezone";@@ -13,21 +18,32 @@ import Skeleton from "../../../components/Skeleton";import i18n from "../../../i18n";import { CustomerDetails_user } from "../../types/CustomerDetails";-const styles = createStyles({- cardTitle: {- height: 64- }-});+const styles = (theme: Theme) =>+ createStyles({+ cardTitle: {+ height: 64+ },+ root: {+ display: "grid" as "grid",+ gridColumnGap: theme.spacing.unit * 2 + "px",+ gridRowGap: theme.spacing.unit * 3 + "px",+ gridTemplateColumns: "1fr 1fr"+ }+ });export interface CustomerDetailsProps extends WithStyles<typeof styles> {customer: CustomerDetails_user;data: {+ firstName: string;+ lastName: string;email: string;isActive: boolean;note: string;};disabled: boolean;errors: {+ firstName?: string;+ lastName?: string;email?: string;note?: string;};@@ -73,6 +89,31 @@ const CustomerDetails = withStyles(styles, { name: "CustomerDetails" })(onChange={onChange}/><FormSpacer />+ <div className={classes.root}>+ <TextField+ disabled={disabled}+ error={!!errors.firstName}+ fullWidth+ helperText={errors.firstName}+ name="firstName"+ type="text"+ label={i18n.t("First Name")}+ value={data.firstName}+ onChange={onChange}+ />+ <TextField+ disabled={disabled}+ error={!!errors.lastName}+ fullWidth+ helperText={errors.lastName}+ name="lastName"+ type="text"+ label={i18n.t("Last Name")}+ value={data.lastName}+ onChange={onChange}+ />+ </div>+ <FormSpacer /><TextFielddisabled={disabled}error={!!errors.email}diff --git a/saleor/static/dashboard-next/customers/components/CustomerDetailsPage/CustomerDetailsPage.tsx b/saleor/static/dashboard-next/customers/components/CustomerDetailsPage/CustomerDetailsPage.tsxindex 1641f69689..b06dfdf98b 100644--- a/saleor/static/dashboard-next/customers/components/CustomerDetailsPage/CustomerDetailsPage.tsx+++ b/saleor/static/dashboard-next/customers/components/CustomerDetailsPage/CustomerDetailsPage.tsx@@ -21,6 +21,8 @@ import CustomerOrders from "../CustomerOrders/CustomerOrders";import CustomerStats from "../CustomerStats/CustomerStats";export interface CustomerDetailsPageFormData {+ firstName: string;+ lastName: string;email: string;isActive: boolean;note: string;@@ -66,7 +68,9 @@ const CustomerDetailsPage = withStyles(styles, { name: "CustomerDetailsPage" })(errors={errors}initial={{email: maybe(() => customer.email),+ firstName: maybe(() => customer.firstName),isActive: maybe(() => customer.isActive, false),+ lastName: maybe(() => customer.lastName),note: maybe(() => customer.note)}}onSubmit={onSubmit}@@ -74,7 +78,10 @@ const CustomerDetailsPage = withStyles(styles, { name: "CustomerDetailsPage" })(>{({ change, data, errors: formErrors, hasChanged, submit }) => (<Container width="md">- <PageHeader onBack={onBack} title={maybe(() => customer.email)} />+ <PageHeader+ onBack={onBack}+ title={maybe(() => `${customer.firstName} ${customer.lastName}`)}+ /><div className={classes.root}><div><CustomerDetailsdiff --git a/saleor/static/dashboard-next/customers/fixtures.ts b/saleor/static/dashboard-next/customers/fixtures.tsindex 1fb9fb7f34..d3f33bb74a 100644--- a/saleor/static/dashboard-next/customers/fixtures.ts+++ b/saleor/static/dashboard-next/customers/fixtures.ts@@ -946,6 +946,8 @@ export const customerList: ListCustomers_customers_edges_node[] = [export const customer: CustomerDetails_user = {__typename: "User",dateJoined: "2017-05-07T09:37:30.124154+00:00",+ firstName: "Tom",+defaultBillingAddress: {__typename: "Address",city: "Port Danielshire",@@ -988,6 +990,7 @@ export const customer: CustomerDetails_user = {id: "VXNlcjoy",isActive: true,lastLogin: "2018-05-07T09:37:30.124154+00:00",+ lastName: "Cooper",lastPlacedOrder: {__typename: "OrderCountableConnection",edges: [diff --git a/saleor/static/dashboard-next/customers/types/CustomerDetails.ts b/saleor/static/dashboard-next/customers/types/CustomerDetails.tsindex 329bdd62ae..0bf1777ecf 100644--- a/saleor/static/dashboard-next/customers/types/CustomerDetails.ts+++ b/saleor/static/dashboard-next/customers/types/CustomerDetails.ts@@ -99,6 +99,8 @@ export interface CustomerDetails_user_lastPlacedOrder {export interface CustomerDetails_user {__typename: "User";+ firstName: string;+ lastName: string;id: string;email: string;dateJoined: any;diff --git a/saleor/static/dashboard-next/storybook/stories/customers/CustomerDetailsPage.tsx b/saleor/static/dashboard-next/storybook/stories/customers/CustomerDetailsPage.tsxindex 598ea4e824..9dac66871c 100644--- a/saleor/static/dashboard-next/storybook/stories/customers/CustomerDetailsPage.tsx+++ b/saleor/static/dashboard-next/storybook/stories/customers/CustomerDetailsPage.tsx@@ -22,6 +22,13 @@ const props: Omit<CustomerDetailsPageProps, "classes"> = {saveButtonBar: "default"};+interface CustomerDetailsPageErrors {+ firstName: string;+ email: string;+ lastName: string;+ note: string;+}+storiesOf("Views / Customers / Customer details", module).addDecorator(Decorator).add("default", () => <CustomerDetailsPage {...props} />)@@ -31,7 +38,9 @@ storiesOf("Views / Customers / Customer details", module).add("form errors", () => (<CustomerDetailsPage{...props}- errors={[formError("email"), formError("note")]}+ errors={(["email", "firstName", "lastName"] as Array<+ keyof CustomerDetailsPageErrors+ >).map(field => formError(field))}/>)).add("different addresses", () => (