From 4ab886a7ca5f1275f0c9a5ab454407d405811839 Mon Sep 17 00:00:00 2001 From: dominik-zeglen Date: Tue, 12 Nov 2019 13:21:37 +0100 Subject: [PATCH 01/11] Update customer note design --- src/components/CardTitle/CardTitle.tsx | 1 + src/components/ControlledCheckbox.tsx | 5 +- .../CustomerDetails/CustomerDetails.tsx | 80 +++-------- .../CustomerDetailsPage.tsx | 17 ++- .../components/CustomerInfo/CustomerInfo.tsx | 128 ++++++++++++++++++ .../components/CustomerInfo/index.ts | 2 + src/theme.ts | 4 +- 7 files changed, 171 insertions(+), 66 deletions(-) create mode 100644 src/customers/components/CustomerInfo/CustomerInfo.tsx create mode 100644 src/customers/components/CustomerInfo/index.ts diff --git a/src/components/CardTitle/CardTitle.tsx b/src/components/CardTitle/CardTitle.tsx index eb565e834..ec72d2f55 100644 --- a/src/components/CardTitle/CardTitle.tsx +++ b/src/components/CardTitle/CardTitle.tsx @@ -23,6 +23,7 @@ const useStyles = makeStyles(theme => ({ }), title: { flex: 1, + fontWeight: 500, lineHeight: 1 }, toolbar: { diff --git a/src/components/ControlledCheckbox.tsx b/src/components/ControlledCheckbox.tsx index 7ed45d330..4a79d9085 100644 --- a/src/components/ControlledCheckbox.tsx +++ b/src/components/ControlledCheckbox.tsx @@ -4,6 +4,7 @@ import React from "react"; import Checkbox from "./Checkbox"; interface ControlledCheckboxProps { + className?: string; name: string; label?: React.ReactNode; checked: boolean; @@ -16,7 +17,8 @@ export const ControlledCheckbox: React.FC = ({ disabled, name, label, - onChange + onChange, + ...props }) => ( = ({ /> } label={label} + {...props} /> ); ControlledCheckbox.displayName = "ControlledCheckbox"; diff --git a/src/customers/components/CustomerDetails/CustomerDetails.tsx b/src/customers/components/CustomerDetails/CustomerDetails.tsx index 5496ed387..1db8cf109 100644 --- a/src/customers/components/CustomerDetails/CustomerDetails.tsx +++ b/src/customers/components/CustomerDetails/CustomerDetails.tsx @@ -9,39 +9,34 @@ import { FormattedMessage, useIntl } from "react-intl"; import CardTitle from "@saleor/components/CardTitle"; import { ControlledCheckbox } from "@saleor/components/ControlledCheckbox"; -import { FormSpacer } from "@saleor/components/FormSpacer"; import Skeleton from "@saleor/components/Skeleton"; -import { commonMessages } from "@saleor/intl"; +import { maybe } from "@saleor/misc"; +import { FormErrors } from "@saleor/types"; import { CustomerDetails_user } from "../../types/CustomerDetails"; const useStyles = makeStyles(theme => ({ cardTitle: { - height: 64 + height: 72 }, - root: { - display: "grid" as "grid", - gridColumnGap: theme.spacing(2), - gridRowGap: theme.spacing(3), - gridTemplateColumns: "1fr 1fr" + checkbox: { + marginBottom: theme.spacing() + }, + content: { + paddingTop: theme.spacing() + }, + subtitle: { + marginTop: theme.spacing() } })); export interface CustomerDetailsProps { 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; - }; + errors: FormErrors<"isActive" | "note">; onChange: (event: React.ChangeEvent) => void; } @@ -57,11 +52,15 @@ const CustomerDetails: React.FC = props => { className={classes.cardTitle} title={ <> - + {maybe(() => customer.email, )} {customer && customer.dateJoined ? ( - + = props => { } /> - + = props => { name="isActive" onChange={onChange} /> - -
- - -
- - - = ({ onChange={change} /> + + customer.orders.edges.map(edge => edge.node) diff --git a/src/customers/components/CustomerInfo/CustomerInfo.tsx b/src/customers/components/CustomerInfo/CustomerInfo.tsx new file mode 100644 index 000000000..ca158a994 --- /dev/null +++ b/src/customers/components/CustomerInfo/CustomerInfo.tsx @@ -0,0 +1,128 @@ +import Card from "@material-ui/core/Card"; +import CardContent from "@material-ui/core/CardContent"; +import { makeStyles } from "@material-ui/core/styles"; +import TextField from "@material-ui/core/TextField"; +import Typography from "@material-ui/core/Typography"; +import moment from "moment-timezone"; +import React from "react"; +import { FormattedMessage, useIntl } from "react-intl"; + +import CardTitle from "@saleor/components/CardTitle"; +import Grid from "@saleor/components/Grid"; +import Hr from "@saleor/components/Hr"; +import Skeleton from "@saleor/components/Skeleton"; +import { commonMessages } from "@saleor/intl"; +import { CustomerDetails_user } from "../../types/CustomerDetails"; + +const useStyles = makeStyles(theme => ({ + cardTitle: { + height: 64 + }, + content: { + paddingTop: theme.spacing(2) + }, + hr: { + margin: theme.spacing(3, 0) + }, + sectionHeader: { + marginBottom: theme.spacing() + } +})); + +export interface CustomerDetailsProps { + customer: CustomerDetails_user; + data: { + firstName: string; + lastName: string; + email: string; + }; + disabled: boolean; + errors: { + firstName?: string; + lastName?: string; + email?: string; + }; + onChange: (event: React.ChangeEvent) => void; +} + +const CustomerDetails: React.FC = props => { + const { customer, data, disabled, errors, onChange } = props; + const classes = useStyles(props); + + const intl = useIntl(); + + return ( + + + + {customer && customer.dateJoined ? ( + + + + ) : ( + + )} + + } + /> + + + + + + + + +
+ + + + +
+
+ ); +}; +CustomerDetails.displayName = "CustomerDetails"; +export default CustomerDetails; diff --git a/src/customers/components/CustomerInfo/index.ts b/src/customers/components/CustomerInfo/index.ts new file mode 100644 index 000000000..5add7b0f4 --- /dev/null +++ b/src/customers/components/CustomerInfo/index.ts @@ -0,0 +1,2 @@ +export { default } from "./CustomerInfo"; +export * from "./CustomerInfo"; diff --git a/src/theme.ts b/src/theme.ts index 3b41cc746..52a60e9c1 100644 --- a/src/theme.ts +++ b/src/theme.ts @@ -397,12 +397,12 @@ export default (colors: IThemeColors): Theme => }, MuiTableCell: { body: { - fontSize: ".875rem", + fontSize: "1rem", paddingBottom: 8, paddingTop: 8 }, head: { - fontSize: ".875rem" + fontSize: "1rem" }, paddingCheckbox: { "&:first-child": { From 0dfe0de548ce9697065bf14aea9cfd2f92f6fb84 Mon Sep 17 00:00:00 2001 From: dominik-zeglen Date: Tue, 12 Nov 2019 13:27:40 +0100 Subject: [PATCH 02/11] Fix header --- .../components/CustomerInfo/CustomerInfo.tsx | 38 +++++-------------- 1 file changed, 9 insertions(+), 29 deletions(-) diff --git a/src/customers/components/CustomerInfo/CustomerInfo.tsx b/src/customers/components/CustomerInfo/CustomerInfo.tsx index ca158a994..26c6893a9 100644 --- a/src/customers/components/CustomerInfo/CustomerInfo.tsx +++ b/src/customers/components/CustomerInfo/CustomerInfo.tsx @@ -3,21 +3,15 @@ import CardContent from "@material-ui/core/CardContent"; import { makeStyles } from "@material-ui/core/styles"; import TextField from "@material-ui/core/TextField"; import Typography from "@material-ui/core/Typography"; -import moment from "moment-timezone"; import React from "react"; import { FormattedMessage, useIntl } from "react-intl"; import CardTitle from "@saleor/components/CardTitle"; import Grid from "@saleor/components/Grid"; import Hr from "@saleor/components/Hr"; -import Skeleton from "@saleor/components/Skeleton"; import { commonMessages } from "@saleor/intl"; -import { CustomerDetails_user } from "../../types/CustomerDetails"; const useStyles = makeStyles(theme => ({ - cardTitle: { - height: 64 - }, content: { paddingTop: theme.spacing(2) }, @@ -29,8 +23,7 @@ const useStyles = makeStyles(theme => ({ } })); -export interface CustomerDetailsProps { - customer: CustomerDetails_user; +export interface CustomerInfoProps { data: { firstName: string; lastName: string; @@ -45,8 +38,8 @@ export interface CustomerDetailsProps { onChange: (event: React.ChangeEvent) => void; } -const CustomerDetails: React.FC = props => { - const { customer, data, disabled, errors, onChange } = props; +const CustomerInfo: React.FC = props => { + const { data, disabled, errors, onChange } = props; const classes = useStyles(props); const intl = useIntl(); @@ -54,24 +47,11 @@ const CustomerDetails: React.FC = props => { return ( - - {customer && customer.dateJoined ? ( - - - - ) : ( - - )} - + } /> @@ -124,5 +104,5 @@ const CustomerDetails: React.FC = props => { ); }; -CustomerDetails.displayName = "CustomerDetails"; -export default CustomerDetails; +CustomerInfo.displayName = "CustomerInfo"; +export default CustomerInfo; From eb58db95a5b02c8ac9a13194bda507e3e8ed561b Mon Sep 17 00:00:00 2001 From: dominik-zeglen Date: Tue, 12 Nov 2019 13:31:05 +0100 Subject: [PATCH 03/11] Fix notification font size --- src/theme.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/theme.ts b/src/theme.ts index 52a60e9c1..d57ce19d0 100644 --- a/src/theme.ts +++ b/src/theme.ts @@ -342,6 +342,9 @@ export default (colors: IThemeColors): Theme => } } }, + message: { + fontSize: 16 + }, root: { backgroundColor: colors.background.paper, boxShadow: From b597f03c706b1731ae5ec4cd92784566d3107d36 Mon Sep 17 00:00:00 2001 From: dominik-zeglen Date: Tue, 12 Nov 2019 13:33:54 +0100 Subject: [PATCH 04/11] Remove unused prop --- .../components/CustomerDetailsPage/CustomerDetailsPage.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/customers/components/CustomerDetailsPage/CustomerDetailsPage.tsx b/src/customers/components/CustomerDetailsPage/CustomerDetailsPage.tsx index df9d557e4..1b65f202e 100644 --- a/src/customers/components/CustomerDetailsPage/CustomerDetailsPage.tsx +++ b/src/customers/components/CustomerDetailsPage/CustomerDetailsPage.tsx @@ -84,7 +84,6 @@ const CustomerDetailsPage: React.FC = ({ /> Date: Tue, 12 Nov 2019 13:36:07 +0100 Subject: [PATCH 05/11] Update stories --- .../__snapshots__/Stories.test.ts.snap | 1271 ++++++++++------- 1 file changed, 786 insertions(+), 485 deletions(-) diff --git a/src/storybook/__snapshots__/Stories.test.ts.snap b/src/storybook/__snapshots__/Stories.test.ts.snap index 9b17eea50..108699494 100644 --- a/src/storybook/__snapshots__/Stories.test.ts.snap +++ b/src/storybook/__snapshots__/Stories.test.ts.snap @@ -31787,11 +31787,11 @@ exports[`Storyshots Views / Customers / Customer details default 1`] = ` - General Informations + elizabeth.vaughn@example.com
- Customer since: May 2017 + Active member since May 2017