Skip to content

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

Update stories

dominik-zeglen96f501144bf5
diff --git a/saleor/static/dashboard-next/customers/components/CustomerCreateDetails/CustomerCreateDetails.tsx b/saleor/static/dashboard-next/customers/components/CustomerCreateDetails/CustomerCreateDetails.tsx
index 2481453e3e..319bad4082 100644
--- a/saleor/static/dashboard-next/customers/components/CustomerCreateDetails/CustomerCreateDetails.tsx
+++ b/saleor/static/dashboard-next/customers/components/CustomerCreateDetails/CustomerCreateDetails.tsx
@@ -26,16 +26,18 @@ const decorate = withStyles(theme => ({
}
}));
const CustomerCreateDetails = decorate<CustomerCreateDetailsProps>(
- ({ classes, data, disabled, onChange }) => (
+ ({ classes, data, disabled, errors, onChange }) => (
<Card>
<CardTitle title={i18n.t("Customer overview")} />
<CardContent>
<div className={classes.root}>
<TextField
disabled={disabled}
+ error={!!errors.email}
fullWidth
name="email"
label={i18n.t("E-mail")}
+ helperText={errors.email}
type="email"
value={data.email}
onChange={onChange}
diff --git a/saleor/static/dashboard-next/customers/components/CustomerCreateNote/CustomerCreateNote.tsx b/saleor/static/dashboard-next/customers/components/CustomerCreateNote/CustomerCreateNote.tsx
index cab3691547..1d21330154 100644
--- a/saleor/static/dashboard-next/customers/components/CustomerCreateNote/CustomerCreateNote.tsx
+++ b/saleor/static/dashboard-next/customers/components/CustomerCreateNote/CustomerCreateNote.tsx
@@ -22,6 +22,7 @@ export interface CustomerCreateNoteProps {
const CustomerCreateNote: React.StatelessComponent<CustomerCreateNoteProps> = ({
data,
disabled,
+ errors,
onChange
}) => (
<Card>
@@ -33,9 +34,11 @@ const CustomerCreateNote: React.StatelessComponent<CustomerCreateNoteProps> = ({
<FormSpacer />
<TextField
disabled={disabled}
+ error={!!errors.note}
fullWidth
multiline
name="note"
+ helperText={errors.note}
label={i18n.t("Note")}
value={data.note}
onChange={onChange}
diff --git a/saleor/static/dashboard-next/customers/mutations.ts b/saleor/static/dashboard-next/customers/mutations.ts
index d8904c2dfa..8640a280fb 100644
--- a/saleor/static/dashboard-next/customers/mutations.ts
+++ b/saleor/static/dashboard-next/customers/mutations.ts
@@ -47,3 +47,9 @@ export const TypedCreateCustomerMutation = TypedMutation<
CreateCustomer,
CreateCustomerVariables
>(createCustomer);
+
+// const removeCustomer = gql`
+// mutation RemoveCustomer($id: ID!) {
+// customerRemove
+// }
+// `
diff --git a/saleor/static/dashboard-next/storybook/stories/customers/CustomerCreatePage.tsx b/saleor/static/dashboard-next/storybook/stories/customers/CustomerCreatePage.tsx
index 47bcccf719..4dfceb93b1 100644
--- a/saleor/static/dashboard-next/storybook/stories/customers/CustomerCreatePage.tsx
+++ b/saleor/static/dashboard-next/storybook/stories/customers/CustomerCreatePage.tsx
@@ -2,9 +2,11 @@ import { storiesOf } from "@storybook/react";
import * as React from "react";
import CustomerCreatePage, {
+ CustomerCreatePageFormData,
CustomerCreatePageProps
} from "../../../customers/components/CustomerCreatePage";
import Decorator from "../../Decorator";
+import { formError } from "../../misc";
const props: CustomerCreatePageProps = {
countries: [
@@ -12,10 +14,34 @@ const props: CustomerCreatePageProps = {
{ __typename: "CountryDisplay", code: "PL", country: "Poland" }
],
disabled: false,
- onBack: () => undefined
+ errors: [],
+ onBack: () => undefined,
+ onSubmit: () => undefined
};
storiesOf("Views / Customers / Create customer", module)
.addDecorator(Decorator)
.add("default", () => <CustomerCreatePage {...props} />)
- .add("loading", () => <CustomerCreatePage {...props} disabled={true} />);
+ .add("loading", () => <CustomerCreatePage {...props} disabled={true} />)
+ .add("form errors", () => (
+ <CustomerCreatePage
+ {...props}
+ errors={([
+ "city",
+ "cityArea",
+ "companyName",
+ "country",
+ "countryArea",
+ "email",
+ "firstName",
+ "lastName",
+ "note",
+ "phone",
+ "postalCode",
+ "streetAddress1",
+ "streetAddress2"
+ ] as Array<keyof CustomerCreatePageFormData>).map(field =>
+ formError(field)
+ )}
+ />
+ ));