Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Add user specific stories

dominik-zeglene09cc0270bc1
diff --git a/saleor/static/dashboard-next/customers/components/CustomerAddresses/CustomerAddresses.tsx b/saleor/static/dashboard-next/customers/components/CustomerAddresses/CustomerAddresses.tsx
index e22484edda..31bc02c43a 100644
--- a/saleor/static/dashboard-next/customers/components/CustomerAddresses/CustomerAddresses.tsx
+++ b/saleor/static/dashboard-next/customers/components/CustomerAddresses/CustomerAddresses.tsx
@@ -50,7 +50,7 @@ const CustomerAddresses = decorate<CustomerAddressesProps>(
<>
<CardContent>
<Typography className={classes.label}>
- {i18n.t("Default shipping address")}
+ {i18n.t("Default billing address")}
</Typography>
<AddressFormatter
address={maybe(() => customer.defaultBillingAddress)}
diff --git a/saleor/static/dashboard-next/customers/components/CustomerDetailsPage/CustomerDetailsPage.tsx b/saleor/static/dashboard-next/customers/components/CustomerDetailsPage/CustomerDetailsPage.tsx
index 79642d3ea1..b1574df326 100644
--- a/saleor/static/dashboard-next/customers/components/CustomerDetailsPage/CustomerDetailsPage.tsx
+++ b/saleor/static/dashboard-next/customers/components/CustomerDetailsPage/CustomerDetailsPage.tsx
@@ -1,6 +1,7 @@
import { withStyles } from "@material-ui/core/styles";
import * as React from "react";
+import { UserError } from "../../..";
import { CardSpacer } from "../../../components/CardSpacer";
import Container from "../../../components/Container";
import Form from "../../../components/Form";
@@ -22,8 +23,9 @@ export interface CustomerDetailsPageFormData {
export interface CustomerDetailsPageProps {
customer: CustomerDetails_user;
disabled: boolean;
+ errors: UserError[];
onBack: () => void;
- onSubmit: (data: CustomerDetails_user) => void;
+ onSubmit: (data: CustomerDetailsPageFormData) => void;
onViewAllOrdersClick: () => void;
onRowClick: (id: string) => void;
onAddressManageClick: () => void;
@@ -42,6 +44,7 @@ const CustomerDetailsPage = decorate<CustomerDetailsPageProps>(
classes,
customer,
disabled,
+ errors,
onBack,
onSubmit,
onViewAllOrdersClick,
@@ -50,6 +53,7 @@ const CustomerDetailsPage = decorate<CustomerDetailsPageProps>(
onDelete
}) => (
<Form
+ errors={errors}
initial={{
email: maybe(() => customer.email),
isActive: maybe(() => customer.isActive),
diff --git a/saleor/static/dashboard-next/customers/components/CustomerStats/CustomerStats.tsx b/saleor/static/dashboard-next/customers/components/CustomerStats/CustomerStats.tsx
index 978eddcc77..67f083b180 100644
--- a/saleor/static/dashboard-next/customers/components/CustomerStats/CustomerStats.tsx
+++ b/saleor/static/dashboard-next/customers/components/CustomerStats/CustomerStats.tsx
@@ -29,7 +29,11 @@ const CustomerStats = decorate<CustomerStatsProps>(({ classes, customer }) => (
{maybe(
() => (
<Typography variant="title" className={classes.value}>
- <DateFormatter date={customer.lastLogin} />
+ {customer.lastLogin === null ? (
+ i18n.t("Never")
+ ) : (
+ <DateFormatter date={customer.lastLogin} />
+ )}
</Typography>
),
<Skeleton />
@@ -41,9 +45,13 @@ const CustomerStats = decorate<CustomerStatsProps>(({ classes, customer }) => (
{maybe(
() => (
<Typography variant="title" className={classes.value}>
- <DateFormatter
- date={customer.lastPlacedOrder.edges[0].node.created}
- />
+ {customer.lastPlacedOrder.edges.length === 0 ? (
+ i18n.t("No orders yet")
+ ) : (
+ <DateFormatter
+ date={customer.lastPlacedOrder.edges[0].node.created}
+ />
+ )}
</Typography>
),
<Skeleton />
diff --git a/saleor/static/dashboard-next/storybook/stories/customers/CustomerDetailsPage.tsx b/saleor/static/dashboard-next/storybook/stories/customers/CustomerDetailsPage.tsx
index 6a7e293032..6e30672711 100644
--- a/saleor/static/dashboard-next/storybook/stories/customers/CustomerDetailsPage.tsx
+++ b/saleor/static/dashboard-next/storybook/stories/customers/CustomerDetailsPage.tsx
@@ -6,10 +6,12 @@ import CustomerDetailsPage, {
} from "../../../customers/components/CustomerDetailsPage";
import { customer } from "../../../customers/fixtures";
import Decorator from "../../Decorator";
+import { formError } from "../../misc";
const props: CustomerDetailsPageProps = {
customer,
disabled: false,
+ errors: [],
onAddressManageClick: () => undefined,
onBack: () => undefined,
onDelete: () => undefined,
@@ -23,4 +25,43 @@ storiesOf("Views / Customers / Customer details", module)
.add("default", () => <CustomerDetailsPage {...props} />)
.add("loading", () => (
<CustomerDetailsPage {...props} customer={undefined} disabled={true} />
+ ))
+ .add("form errors", () => (
+ <CustomerDetailsPage
+ {...props}
+ errors={[formError("email"), formError("note")]}
+ />
+ ))
+ .add("different addresses", () => (
+ <CustomerDetailsPage
+ {...props}
+ customer={{
+ ...customer,
+ defaultBillingAddress: {
+ ...customer.defaultBillingAddress,
+ id: "AvSduf72="
+ }
+ }}
+ />
+ ))
+ .add("never logged", () => (
+ <CustomerDetailsPage
+ {...props}
+ customer={{
+ ...customer,
+ lastLogin: null
+ }}
+ />
+ ))
+ .add("never placed order", () => (
+ <CustomerDetailsPage
+ {...props}
+ customer={{
+ ...customer,
+ lastPlacedOrder: {
+ ...customer.lastPlacedOrder,
+ edges: []
+ }
+ }}
+ />
));