2023-06-21 09:28:00 +00:00
|
|
|
// @ts-strict-ignore
|
2023-01-16 09:45:12 +00:00
|
|
|
import { AccountErrorCode } from "@dashboard/graphql";
|
2019-08-09 10:26:22 +00:00
|
|
|
import React from "react";
|
2019-06-19 14:40:52 +00:00
|
|
|
|
2023-05-12 11:06:27 +00:00
|
|
|
import { MockedUserProvider } from "../../../../.storybook/helpers";
|
2023-01-05 12:34:34 +00:00
|
|
|
import { customer } from "../../fixtures";
|
2022-03-01 08:38:23 +00:00
|
|
|
import CustomerDetailsPageComponent, {
|
2022-06-21 09:36:55 +00:00
|
|
|
CustomerDetailsPageProps,
|
2023-01-05 12:34:34 +00:00
|
|
|
} from "./CustomerDetailsPage";
|
2019-06-19 14:40:52 +00:00
|
|
|
|
|
|
|
const props: Omit<CustomerDetailsPageProps, "classes"> = {
|
2022-05-06 08:59:55 +00:00
|
|
|
customerId: "123",
|
2019-06-19 14:40:52 +00:00
|
|
|
customer,
|
|
|
|
disabled: false,
|
|
|
|
errors: [],
|
|
|
|
onDelete: () => undefined,
|
|
|
|
onSubmit: () => undefined,
|
2022-06-21 09:36:55 +00:00
|
|
|
saveButtonBar: "default",
|
2019-06-19 14:40:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
interface CustomerDetailsPageErrors {
|
|
|
|
firstName: string;
|
|
|
|
email: string;
|
|
|
|
lastName: string;
|
|
|
|
note: string;
|
|
|
|
}
|
|
|
|
|
2022-03-01 08:38:23 +00:00
|
|
|
const CustomerDetailsPage = props => (
|
|
|
|
<MockedUserProvider>
|
|
|
|
<CustomerDetailsPageComponent {...props} />
|
|
|
|
</MockedUserProvider>
|
|
|
|
);
|
|
|
|
|
2023-05-12 11:06:27 +00:00
|
|
|
export default {
|
|
|
|
title: "Customers / Customer details",
|
|
|
|
};
|
|
|
|
|
|
|
|
export const Default = () => <CustomerDetailsPage {...props} />;
|
|
|
|
|
|
|
|
export const Loading = () => (
|
|
|
|
<CustomerDetailsPage {...props} customer={undefined} disabled={true} />
|
|
|
|
);
|
|
|
|
|
|
|
|
export const FormErrors = () => (
|
|
|
|
<CustomerDetailsPage
|
|
|
|
{...props}
|
|
|
|
errors={(
|
|
|
|
["email", "firstName", "lastName"] as Array<
|
2019-06-19 14:40:52 +00:00
|
|
|
keyof CustomerDetailsPageErrors
|
2023-05-12 11:06:27 +00:00
|
|
|
>
|
|
|
|
).map(field => ({
|
|
|
|
__typename: "AccountError",
|
|
|
|
code: AccountErrorCode.INVALID,
|
|
|
|
field,
|
|
|
|
addressType: null,
|
|
|
|
message: "Account invalid",
|
|
|
|
}))}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
|
|
|
|
export const DifferentAddresses = () => (
|
|
|
|
<CustomerDetailsPage
|
|
|
|
{...props}
|
|
|
|
customer={{
|
|
|
|
...customer,
|
|
|
|
defaultBillingAddress: {
|
|
|
|
...customer.defaultBillingAddress,
|
|
|
|
id: "AvSduf72=",
|
|
|
|
},
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
|
|
|
|
export const NeverLogged = () => (
|
|
|
|
<CustomerDetailsPage
|
|
|
|
{...props}
|
|
|
|
customer={{
|
|
|
|
...customer,
|
|
|
|
lastLogin: null,
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
|
|
|
|
export const NeverPlacedOrder = () => (
|
|
|
|
<CustomerDetailsPage
|
|
|
|
{...props}
|
|
|
|
customer={{
|
|
|
|
...customer,
|
|
|
|
lastPlacedOrder: {
|
|
|
|
...customer.lastPlacedOrder,
|
|
|
|
edges: [],
|
|
|
|
},
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
|
|
|
|
export const NoDefaultBillingAddress = () => (
|
|
|
|
<CustomerDetailsPage
|
|
|
|
{...props}
|
|
|
|
customer={{
|
|
|
|
...customer,
|
|
|
|
defaultBillingAddress: null,
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
|
|
|
|
export const NoDefaultShippingAddress = () => (
|
|
|
|
<CustomerDetailsPage
|
|
|
|
{...props}
|
|
|
|
customer={{
|
|
|
|
...customer,
|
|
|
|
defaultShippingAddress: null,
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
|
|
|
|
export const NoAddressAtAll = () => (
|
|
|
|
<CustomerDetailsPage
|
|
|
|
{...props}
|
|
|
|
customer={{
|
|
|
|
...customer,
|
|
|
|
defaultBillingAddress: null,
|
|
|
|
defaultShippingAddress: null,
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
);
|