Fix type errors
This commit is contained in:
parent
d0e082dc21
commit
8b5b3c81d5
18 changed files with 103 additions and 77 deletions
|
@ -165,12 +165,7 @@ export const ProductCreatePage: React.FC<ProductCreatePageProps> = ({
|
||||||
MultiAutocompleteChoiceType[]
|
MultiAutocompleteChoiceType[]
|
||||||
>([]);
|
>([]);
|
||||||
|
|
||||||
const [productType, setProductType] = React.useState<ProductType>({
|
const [productType, setProductType] = React.useState<ProductType>(null);
|
||||||
hasVariants: false,
|
|
||||||
id: "",
|
|
||||||
name: "",
|
|
||||||
productAttributes: []
|
|
||||||
});
|
|
||||||
|
|
||||||
const categories = getChoices(categoryChoiceList);
|
const categories = getChoices(categoryChoiceList);
|
||||||
const collections = getChoices(collectionChoiceList);
|
const collections = getChoices(collectionChoiceList);
|
||||||
|
@ -253,7 +248,7 @@ export const ProductCreatePage: React.FC<ProductCreatePageProps> = ({
|
||||||
onChange={change}
|
onChange={change}
|
||||||
/>
|
/>
|
||||||
<CardSpacer />
|
<CardSpacer />
|
||||||
{!productType.hasVariants && (
|
{!!productType && !productType.hasVariants && (
|
||||||
<>
|
<>
|
||||||
<ProductStocks
|
<ProductStocks
|
||||||
data={data}
|
data={data}
|
||||||
|
@ -296,7 +291,7 @@ export const ProductCreatePage: React.FC<ProductCreatePageProps> = ({
|
||||||
fetchMoreProductTypes={fetchMoreProductTypes}
|
fetchMoreProductTypes={fetchMoreProductTypes}
|
||||||
fetchProductTypes={fetchProductTypes}
|
fetchProductTypes={fetchProductTypes}
|
||||||
productType={productType}
|
productType={productType}
|
||||||
productTypeInputDisplayValue={productType.name}
|
productTypeInputDisplayValue={productType?.name || ""}
|
||||||
productTypes={productTypes}
|
productTypes={productTypes}
|
||||||
onCategoryChange={handleCategorySelect}
|
onCategoryChange={handleCategorySelect}
|
||||||
onCollectionChange={handleCollectionSelect}
|
onCollectionChange={handleCollectionSelect}
|
||||||
|
|
|
@ -175,7 +175,7 @@ const ProductStocks: React.FC<ProductStocksProps> = ({
|
||||||
{renderCollection(
|
{renderCollection(
|
||||||
stocks,
|
stocks,
|
||||||
stock => (
|
stock => (
|
||||||
<TableRow>
|
<TableRow key={stock.id}>
|
||||||
<TableCell className={classes.colName}>{stock.label}</TableCell>
|
<TableCell className={classes.colName}>{stock.label}</TableCell>
|
||||||
<TableCell className={classes.colQuantity}>
|
<TableCell className={classes.colQuantity}>
|
||||||
<TextField
|
<TextField
|
||||||
|
|
|
@ -45,7 +45,6 @@ interface ProductVariantCreatePageProps {
|
||||||
disabled: boolean;
|
disabled: boolean;
|
||||||
errors: ProductErrorFragment[];
|
errors: ProductErrorFragment[];
|
||||||
header: string;
|
header: string;
|
||||||
loading: boolean;
|
|
||||||
product: ProductVariantCreateData_product;
|
product: ProductVariantCreateData_product;
|
||||||
saveButtonBarState: ConfirmButtonTransitionState;
|
saveButtonBarState: ConfirmButtonTransitionState;
|
||||||
warehouses: SearchWarehouses_search_edges_node[];
|
warehouses: SearchWarehouses_search_edges_node[];
|
||||||
|
@ -59,7 +58,6 @@ const ProductVariantCreatePage: React.FC<ProductVariantCreatePageProps> = ({
|
||||||
currencySymbol,
|
currencySymbol,
|
||||||
disabled,
|
disabled,
|
||||||
errors,
|
errors,
|
||||||
loading,
|
|
||||||
header,
|
header,
|
||||||
product,
|
product,
|
||||||
saveButtonBarState,
|
saveButtonBarState,
|
||||||
|
@ -133,7 +131,7 @@ const ProductVariantCreatePage: React.FC<ProductVariantCreatePageProps> = ({
|
||||||
<div>
|
<div>
|
||||||
<ProductVariantAttributes
|
<ProductVariantAttributes
|
||||||
attributes={attributes}
|
attributes={attributes}
|
||||||
disabled={loading}
|
disabled={disabled}
|
||||||
errors={errors}
|
errors={errors}
|
||||||
onChange={handleAttributeChange}
|
onChange={handleAttributeChange}
|
||||||
/>
|
/>
|
||||||
|
@ -143,7 +141,7 @@ const ProductVariantCreatePage: React.FC<ProductVariantCreatePageProps> = ({
|
||||||
priceOverride={data.priceOverride}
|
priceOverride={data.priceOverride}
|
||||||
currencySymbol={currencySymbol}
|
currencySymbol={currencySymbol}
|
||||||
costPrice={data.costPrice}
|
costPrice={data.costPrice}
|
||||||
loading={loading}
|
loading={disabled}
|
||||||
onChange={change}
|
onChange={change}
|
||||||
/>
|
/>
|
||||||
<CardSpacer />
|
<CardSpacer />
|
||||||
|
@ -159,7 +157,7 @@ const ProductVariantCreatePage: React.FC<ProductVariantCreatePageProps> = ({
|
||||||
</div>
|
</div>
|
||||||
</Grid>
|
</Grid>
|
||||||
<SaveButtonBar
|
<SaveButtonBar
|
||||||
disabled={loading || !onSubmit || !hasChanged}
|
disabled={disabled || !onSubmit || !hasChanged}
|
||||||
labels={{
|
labels={{
|
||||||
delete: intl.formatMessage({
|
delete: intl.formatMessage({
|
||||||
defaultMessage: "Delete Variant",
|
defaultMessage: "Delete Variant",
|
||||||
|
|
|
@ -3,7 +3,7 @@ import React from "react";
|
||||||
|
|
||||||
import Decorator from "@saleor/storybook//Decorator";
|
import Decorator from "@saleor/storybook//Decorator";
|
||||||
import { warehouseList } from "@saleor/warehouses/fixtures";
|
import { warehouseList } from "@saleor/warehouses/fixtures";
|
||||||
import { formError } from "@saleor/storybook/misc";
|
import { StockErrorCode } from "@saleor/types/globalTypes";
|
||||||
import ProductWarehousesDialog, {
|
import ProductWarehousesDialog, {
|
||||||
ProductWarehousesDialogProps
|
ProductWarehousesDialogProps
|
||||||
} from "./ProductWarehousesDialog";
|
} from "./ProductWarehousesDialog";
|
||||||
|
@ -15,21 +15,8 @@ const props: ProductWarehousesDialogProps = {
|
||||||
onClose: () => undefined,
|
onClose: () => undefined,
|
||||||
onConfirm: () => undefined,
|
onConfirm: () => undefined,
|
||||||
open: true,
|
open: true,
|
||||||
stocks: [
|
warehouses: warehouseList,
|
||||||
{
|
warehousesWithStocks: [warehouseList[0].id, warehouseList[2].id]
|
||||||
__typename: "Stock",
|
|
||||||
id: "5123",
|
|
||||||
quantity: 2,
|
|
||||||
warehouse: warehouseList[0]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
__typename: "Stock",
|
|
||||||
id: "5223",
|
|
||||||
quantity: 4,
|
|
||||||
warehouse: warehouseList[2]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
warehouses: warehouseList
|
|
||||||
};
|
};
|
||||||
|
|
||||||
storiesOf("Views / Products / Edit warehouses", module)
|
storiesOf("Views / Products / Edit warehouses", module)
|
||||||
|
@ -46,5 +33,14 @@ storiesOf("Views / Products / Edit warehouses", module)
|
||||||
/>
|
/>
|
||||||
))
|
))
|
||||||
.add("with error", () => (
|
.add("with error", () => (
|
||||||
<ProductWarehousesDialog {...props} errors={[formError(null)]} />
|
<ProductWarehousesDialog
|
||||||
|
{...props}
|
||||||
|
errors={[
|
||||||
|
{
|
||||||
|
__typename: "StockError",
|
||||||
|
code: StockErrorCode.INVALID,
|
||||||
|
field: null
|
||||||
|
}
|
||||||
|
]}
|
||||||
|
/>
|
||||||
));
|
));
|
||||||
|
|
|
@ -60,7 +60,7 @@ function getErrorMessage(
|
||||||
case "BulkStockError":
|
case "BulkStockError":
|
||||||
return getBulkStockErrorMessage(err, intl);
|
return getBulkStockErrorMessage(err, intl);
|
||||||
default:
|
default:
|
||||||
getStockErrorMessage(err, intl);
|
return getStockErrorMessage(err, intl);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1247,21 +1247,30 @@ export const variant = (placeholderImage: string): ProductVariant => ({
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
quantity: 19,
|
|
||||||
quantityAllocated: 12,
|
|
||||||
sku: "1230959124123",
|
sku: "1230959124123",
|
||||||
stock: [
|
stocks: [
|
||||||
{
|
{
|
||||||
__typename: "Stock",
|
__typename: "Stock",
|
||||||
id: "1",
|
id: "1",
|
||||||
quantity: 1
|
quantity: 1,
|
||||||
|
warehouse: {
|
||||||
|
__typename: "Warehouse",
|
||||||
|
id: "123",
|
||||||
|
name: "Warehouse 1"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
__typename: "Stock",
|
__typename: "Stock",
|
||||||
id: "2",
|
id: "2",
|
||||||
quantity: 4
|
quantity: 4,
|
||||||
|
warehouse: {
|
||||||
|
__typename: "Warehouse",
|
||||||
|
id: "1234",
|
||||||
|
name: "Warehouse 2"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
]
|
],
|
||||||
|
trackInventory: true
|
||||||
});
|
});
|
||||||
export const variantImages = (placeholderImage: string) =>
|
export const variantImages = (placeholderImage: string) =>
|
||||||
variant(placeholderImage).images;
|
variant(placeholderImage).images;
|
||||||
|
|
|
@ -59,11 +59,7 @@ export const ProductCreateView: React.FC<ProductCreateViewProps> = ({
|
||||||
} = useProductTypeSearch({
|
} = useProductTypeSearch({
|
||||||
variables: DEFAULT_INITIAL_SEARCH_DATA
|
variables: DEFAULT_INITIAL_SEARCH_DATA
|
||||||
});
|
});
|
||||||
const {
|
const { result: searchWarehousesOpts } = useWarehouseSearch({
|
||||||
loadMore: loadMoreWarehouses,
|
|
||||||
search: searchWarehouses,
|
|
||||||
result: searchWarehousesOpts
|
|
||||||
} = useWarehouseSearch({
|
|
||||||
variables: {
|
variables: {
|
||||||
...DEFAULT_INITIAL_SEARCH_DATA,
|
...DEFAULT_INITIAL_SEARCH_DATA,
|
||||||
first: 20
|
first: 20
|
||||||
|
|
|
@ -74,11 +74,7 @@ export const ProductUpdate: React.FC<ProductUpdateProps> = ({ id, params }) => {
|
||||||
} = useCollectionSearch({
|
} = useCollectionSearch({
|
||||||
variables: DEFAULT_INITIAL_SEARCH_DATA
|
variables: DEFAULT_INITIAL_SEARCH_DATA
|
||||||
});
|
});
|
||||||
const {
|
const { result: searchWarehousesOpts } = useWarehouseSearch({
|
||||||
loadMore: loadMoreWarehouses,
|
|
||||||
search: searchWarehouses,
|
|
||||||
result: searchWarehousesOpts
|
|
||||||
} = useWarehouseSearch({
|
|
||||||
variables: {
|
variables: {
|
||||||
...DEFAULT_INITIAL_SEARCH_DATA,
|
...DEFAULT_INITIAL_SEARCH_DATA,
|
||||||
first: 20
|
first: 20
|
||||||
|
|
|
@ -52,11 +52,7 @@ export const ProductVariant: React.FC<ProductUpdateProps> = ({
|
||||||
setErrors([]);
|
setErrors([]);
|
||||||
}, [variantId]);
|
}, [variantId]);
|
||||||
|
|
||||||
const {
|
const { result: searchWarehousesOpts } = useWarehouseSearch({
|
||||||
loadMore: loadMoreWarehouses,
|
|
||||||
search: searchWarehouses,
|
|
||||||
result: searchWarehousesOpts
|
|
||||||
} = useWarehouseSearch({
|
|
||||||
variables: {
|
variables: {
|
||||||
...DEFAULT_INITIAL_SEARCH_DATA,
|
...DEFAULT_INITIAL_SEARCH_DATA,
|
||||||
first: 20
|
first: 20
|
||||||
|
|
|
@ -41,11 +41,7 @@ export const ProductVariant: React.FC<ProductVariantCreateProps> = ({
|
||||||
const notify = useNotifier();
|
const notify = useNotifier();
|
||||||
const shop = useShop();
|
const shop = useShop();
|
||||||
const intl = useIntl();
|
const intl = useIntl();
|
||||||
const {
|
const { result: searchWarehousesOpts } = useWarehouseSearch({
|
||||||
loadMore: loadMoreWarehouses,
|
|
||||||
search: searchWarehouses,
|
|
||||||
result: searchWarehousesOpts
|
|
||||||
} = useWarehouseSearch({
|
|
||||||
variables: {
|
variables: {
|
||||||
...DEFAULT_INITIAL_SEARCH_DATA,
|
...DEFAULT_INITIAL_SEARCH_DATA,
|
||||||
first: 20
|
first: 20
|
||||||
|
@ -127,7 +123,7 @@ export const ProductVariant: React.FC<ProductVariantCreateProps> = ({
|
||||||
/>
|
/>
|
||||||
<ProductVariantCreatePage
|
<ProductVariantCreatePage
|
||||||
currencySymbol={shop?.defaultCurrency}
|
currencySymbol={shop?.defaultCurrency}
|
||||||
disabled={productLoading}
|
disabled={disableForm}
|
||||||
errors={
|
errors={
|
||||||
variantCreateResult.data?.productVariantCreate.errors ||
|
variantCreateResult.data?.productVariantCreate.errors ||
|
||||||
[]
|
[]
|
||||||
|
@ -136,7 +132,6 @@ export const ProductVariant: React.FC<ProductVariantCreateProps> = ({
|
||||||
defaultMessage: "Create Variant",
|
defaultMessage: "Create Variant",
|
||||||
description: "header"
|
description: "header"
|
||||||
})}
|
})}
|
||||||
loading={disableForm}
|
|
||||||
product={data?.product}
|
product={data?.product}
|
||||||
onBack={handleBack}
|
onBack={handleBack}
|
||||||
onSubmit={handleSubmit}
|
onSubmit={handleSubmit}
|
||||||
|
|
|
@ -11,7 +11,7 @@ import makeStyles from "@material-ui/core/styles/makeStyles";
|
||||||
import ConfirmButton, {
|
import ConfirmButton, {
|
||||||
ConfirmButtonTransitionState
|
ConfirmButtonTransitionState
|
||||||
} from "@saleor/components/ConfirmButton";
|
} from "@saleor/components/ConfirmButton";
|
||||||
import { DialogProps, UserError } from "@saleor/types";
|
import { DialogProps } from "@saleor/types";
|
||||||
import { AddressTypeInput } from "@saleor/customers/types";
|
import { AddressTypeInput } from "@saleor/customers/types";
|
||||||
import useModalDialogOpen from "@saleor/hooks/useModalDialogOpen";
|
import useModalDialogOpen from "@saleor/hooks/useModalDialogOpen";
|
||||||
import useModalDialogErrors from "@saleor/hooks/useModalDialogErrors";
|
import useModalDialogErrors from "@saleor/hooks/useModalDialogErrors";
|
||||||
|
@ -24,6 +24,7 @@ import useStateFromProps from "@saleor/hooks/useStateFromProps";
|
||||||
import { ShopInfo_shop_countries } from "@saleor/components/Shop/types/ShopInfo";
|
import { ShopInfo_shop_countries } from "@saleor/components/Shop/types/ShopInfo";
|
||||||
import createSingleAutocompleteSelectHandler from "@saleor/utils/handlers/singleAutocompleteSelectChangeHandler";
|
import createSingleAutocompleteSelectHandler from "@saleor/utils/handlers/singleAutocompleteSelectChangeHandler";
|
||||||
import FormSpacer from "@saleor/components/FormSpacer";
|
import FormSpacer from "@saleor/components/FormSpacer";
|
||||||
|
import { WarehouseErrorFragment } from "@saleor/warehouses/types/WarehouseErrorFragment";
|
||||||
|
|
||||||
export interface ShippingZoneAddWarehouseDialogSubmitData
|
export interface ShippingZoneAddWarehouseDialogSubmitData
|
||||||
extends AddressTypeInput {
|
extends AddressTypeInput {
|
||||||
|
@ -33,7 +34,7 @@ export interface ShippingZoneAddWarehouseDialogProps extends DialogProps {
|
||||||
confirmButtonState: ConfirmButtonTransitionState;
|
confirmButtonState: ConfirmButtonTransitionState;
|
||||||
countries: ShopInfo_shop_countries[];
|
countries: ShopInfo_shop_countries[];
|
||||||
disabled: boolean;
|
disabled: boolean;
|
||||||
errors: UserError[];
|
errors: WarehouseErrorFragment[];
|
||||||
onSubmit: (data: ShippingZoneAddWarehouseDialogSubmitData) => void;
|
onSubmit: (data: ShippingZoneAddWarehouseDialogSubmitData) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -176,7 +176,7 @@ const ShippingZoneDetails: React.FC<ShippingZoneDetailsProps> = ({
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new Error(`Updating failed: ${updateErrors[0].message}`);
|
throw new Error(`Updating failed: ${updateErrors[0].code}`);
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
notify({
|
notify({
|
||||||
|
|
|
@ -3,6 +3,7 @@ import React from "react";
|
||||||
|
|
||||||
import { fetchMoreProps } from "@saleor/fixtures";
|
import { fetchMoreProps } from "@saleor/fixtures";
|
||||||
import { ProductErrorCode } from "@saleor/types/globalTypes";
|
import { ProductErrorCode } from "@saleor/types/globalTypes";
|
||||||
|
import { warehouseList } from "@saleor/warehouses/fixtures";
|
||||||
import ProductCreatePage, {
|
import ProductCreatePage, {
|
||||||
ProductCreatePageSubmitData
|
ProductCreatePageSubmitData
|
||||||
} from "../../../products/components/ProductCreatePage";
|
} from "../../../products/components/ProductCreatePage";
|
||||||
|
@ -32,6 +33,8 @@ storiesOf("Views / Products / Create product", module)
|
||||||
onBack={() => undefined}
|
onBack={() => undefined}
|
||||||
onSubmit={() => undefined}
|
onSubmit={() => undefined}
|
||||||
saveButtonBarState="default"
|
saveButtonBarState="default"
|
||||||
|
onWarehouseEdit={() => undefined}
|
||||||
|
warehouses={warehouseList}
|
||||||
/>
|
/>
|
||||||
))
|
))
|
||||||
.add("When loading", () => (
|
.add("When loading", () => (
|
||||||
|
@ -52,6 +55,8 @@ storiesOf("Views / Products / Create product", module)
|
||||||
onBack={() => undefined}
|
onBack={() => undefined}
|
||||||
onSubmit={() => undefined}
|
onSubmit={() => undefined}
|
||||||
saveButtonBarState="default"
|
saveButtonBarState="default"
|
||||||
|
onWarehouseEdit={() => undefined}
|
||||||
|
warehouses={undefined}
|
||||||
/>
|
/>
|
||||||
))
|
))
|
||||||
.add("form errors", () => (
|
.add("form errors", () => (
|
||||||
|
@ -78,5 +83,7 @@ storiesOf("Views / Products / Create product", module)
|
||||||
onBack={() => undefined}
|
onBack={() => undefined}
|
||||||
onSubmit={() => undefined}
|
onSubmit={() => undefined}
|
||||||
saveButtonBarState="default"
|
saveButtonBarState="default"
|
||||||
|
onWarehouseEdit={() => undefined}
|
||||||
|
warehouses={warehouseList}
|
||||||
/>
|
/>
|
||||||
));
|
));
|
||||||
|
|
|
@ -30,11 +30,11 @@ const props: ProductUpdatePageProps = {
|
||||||
onDelete: () => undefined,
|
onDelete: () => undefined,
|
||||||
onImageDelete: () => undefined,
|
onImageDelete: () => undefined,
|
||||||
onImageUpload: () => undefined,
|
onImageUpload: () => undefined,
|
||||||
onProductShow: () => undefined,
|
|
||||||
onSubmit: () => undefined,
|
onSubmit: () => undefined,
|
||||||
onVariantAdd: () => undefined,
|
onVariantAdd: () => undefined,
|
||||||
onVariantShow: () => undefined,
|
onVariantShow: () => undefined,
|
||||||
onVariantsAdd: () => undefined,
|
onVariantsAdd: () => undefined,
|
||||||
|
onWarehousesEdit: () => undefined,
|
||||||
placeholderImage,
|
placeholderImage,
|
||||||
product,
|
product,
|
||||||
saveButtonBarState: "default",
|
saveButtonBarState: "default",
|
||||||
|
@ -73,7 +73,28 @@ storiesOf("Views / Products / Product edit", module)
|
||||||
{...props}
|
{...props}
|
||||||
product={{
|
product={{
|
||||||
...props.product,
|
...props.product,
|
||||||
variants: []
|
productType: {
|
||||||
|
...product.productType,
|
||||||
|
hasVariants: false
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
))
|
||||||
|
.add("no stock and no variants", () => (
|
||||||
|
<ProductUpdatePage
|
||||||
|
{...props}
|
||||||
|
product={{
|
||||||
|
...product,
|
||||||
|
productType: {
|
||||||
|
...product.productType,
|
||||||
|
hasVariants: false
|
||||||
|
},
|
||||||
|
variants: [
|
||||||
|
{
|
||||||
|
...product.variants[0],
|
||||||
|
stocks: []
|
||||||
|
}
|
||||||
|
]
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
))
|
))
|
||||||
|
|
|
@ -3,6 +3,7 @@ import React from "react";
|
||||||
|
|
||||||
import placeholderImage from "@assets/images/placeholder255x255.png";
|
import placeholderImage from "@assets/images/placeholder255x255.png";
|
||||||
import { ProductErrorCode } from "@saleor/types/globalTypes";
|
import { ProductErrorCode } from "@saleor/types/globalTypes";
|
||||||
|
import { warehouseList } from "@saleor/warehouses/fixtures";
|
||||||
import ProductVariantCreatePage from "../../../products/components/ProductVariantCreatePage";
|
import ProductVariantCreatePage from "../../../products/components/ProductVariantCreatePage";
|
||||||
import { product as productFixture } from "../../../products/fixtures";
|
import { product as productFixture } from "../../../products/fixtures";
|
||||||
import Decorator from "../../Decorator";
|
import Decorator from "../../Decorator";
|
||||||
|
@ -14,19 +15,22 @@ storiesOf("Views / Products / Create product variant", module)
|
||||||
.add("default", () => (
|
.add("default", () => (
|
||||||
<ProductVariantCreatePage
|
<ProductVariantCreatePage
|
||||||
currencySymbol="USD"
|
currencySymbol="USD"
|
||||||
|
disabled={false}
|
||||||
errors={[]}
|
errors={[]}
|
||||||
header="Add variant"
|
header="Add variant"
|
||||||
loading={false}
|
|
||||||
product={product}
|
product={product}
|
||||||
onBack={() => undefined}
|
onBack={() => undefined}
|
||||||
onSubmit={() => undefined}
|
onSubmit={() => undefined}
|
||||||
onVariantClick={undefined}
|
onVariantClick={undefined}
|
||||||
saveButtonBarState="default"
|
saveButtonBarState="default"
|
||||||
|
warehouses={warehouseList}
|
||||||
|
onWarehouseEdit={() => undefined}
|
||||||
/>
|
/>
|
||||||
))
|
))
|
||||||
.add("with errors", () => (
|
.add("with errors", () => (
|
||||||
<ProductVariantCreatePage
|
<ProductVariantCreatePage
|
||||||
currencySymbol="USD"
|
currencySymbol="USD"
|
||||||
|
disabled={false}
|
||||||
errors={[
|
errors={[
|
||||||
{
|
{
|
||||||
code: ProductErrorCode.REQUIRED,
|
code: ProductErrorCode.REQUIRED,
|
||||||
|
@ -45,33 +49,36 @@ storiesOf("Views / Products / Create product variant", module)
|
||||||
...error
|
...error
|
||||||
}))}
|
}))}
|
||||||
header="Add variant"
|
header="Add variant"
|
||||||
loading={false}
|
|
||||||
product={product}
|
product={product}
|
||||||
onBack={() => undefined}
|
onBack={() => undefined}
|
||||||
onSubmit={() => undefined}
|
onSubmit={() => undefined}
|
||||||
onVariantClick={undefined}
|
onVariantClick={undefined}
|
||||||
saveButtonBarState="default"
|
saveButtonBarState="default"
|
||||||
|
warehouses={warehouseList}
|
||||||
|
onWarehouseEdit={() => undefined}
|
||||||
/>
|
/>
|
||||||
))
|
))
|
||||||
.add("when loading data", () => (
|
.add("when loading data", () => (
|
||||||
<ProductVariantCreatePage
|
<ProductVariantCreatePage
|
||||||
currencySymbol="USD"
|
currencySymbol="USD"
|
||||||
|
disabled={true}
|
||||||
errors={[]}
|
errors={[]}
|
||||||
header="Add variant"
|
header="Add variant"
|
||||||
loading={true}
|
|
||||||
product={undefined}
|
product={undefined}
|
||||||
onBack={() => undefined}
|
onBack={() => undefined}
|
||||||
onSubmit={() => undefined}
|
onSubmit={() => undefined}
|
||||||
onVariantClick={undefined}
|
onVariantClick={undefined}
|
||||||
saveButtonBarState="default"
|
saveButtonBarState="default"
|
||||||
|
warehouses={warehouseList}
|
||||||
|
onWarehouseEdit={() => undefined}
|
||||||
/>
|
/>
|
||||||
))
|
))
|
||||||
.add("add first variant", () => (
|
.add("add first variant", () => (
|
||||||
<ProductVariantCreatePage
|
<ProductVariantCreatePage
|
||||||
currencySymbol="USD"
|
currencySymbol="USD"
|
||||||
|
disabled={false}
|
||||||
errors={[]}
|
errors={[]}
|
||||||
header="Add variant"
|
header="Add variant"
|
||||||
loading={false}
|
|
||||||
product={{
|
product={{
|
||||||
...product,
|
...product,
|
||||||
variants: []
|
variants: []
|
||||||
|
@ -80,5 +87,7 @@ storiesOf("Views / Products / Create product variant", module)
|
||||||
onSubmit={() => undefined}
|
onSubmit={() => undefined}
|
||||||
onVariantClick={undefined}
|
onVariantClick={undefined}
|
||||||
saveButtonBarState="default"
|
saveButtonBarState="default"
|
||||||
|
warehouses={warehouseList}
|
||||||
|
onWarehouseEdit={() => undefined}
|
||||||
/>
|
/>
|
||||||
));
|
));
|
||||||
|
|
|
@ -23,6 +23,7 @@ storiesOf("Views / Products / Product variant details", module)
|
||||||
onSubmit={() => undefined}
|
onSubmit={() => undefined}
|
||||||
onVariantClick={() => undefined}
|
onVariantClick={() => undefined}
|
||||||
saveButtonBarState="default"
|
saveButtonBarState="default"
|
||||||
|
onWarehousesEdit={() => undefined}
|
||||||
/>
|
/>
|
||||||
))
|
))
|
||||||
.add("when loading data", () => (
|
.add("when loading data", () => (
|
||||||
|
@ -38,6 +39,7 @@ storiesOf("Views / Products / Product variant details", module)
|
||||||
onSubmit={() => undefined}
|
onSubmit={() => undefined}
|
||||||
onVariantClick={() => undefined}
|
onVariantClick={() => undefined}
|
||||||
saveButtonBarState="default"
|
saveButtonBarState="default"
|
||||||
|
onWarehousesEdit={() => undefined}
|
||||||
/>
|
/>
|
||||||
))
|
))
|
||||||
.add("attribute errors", () => (
|
.add("attribute errors", () => (
|
||||||
|
@ -69,5 +71,6 @@ storiesOf("Views / Products / Product variant details", module)
|
||||||
message: "Generic form error",
|
message: "Generic form error",
|
||||||
...error
|
...error
|
||||||
}))}
|
}))}
|
||||||
|
onWarehousesEdit={() => undefined}
|
||||||
/>
|
/>
|
||||||
));
|
));
|
||||||
|
|
|
@ -2,8 +2,8 @@ import { storiesOf } from "@storybook/react";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
|
|
||||||
import Decorator from "@saleor/storybook/Decorator";
|
import Decorator from "@saleor/storybook/Decorator";
|
||||||
import { formError } from "@saleor/storybook/misc";
|
|
||||||
import { countries } from "@saleor/fixtures";
|
import { countries } from "@saleor/fixtures";
|
||||||
|
import { WarehouseErrorCode } from "@saleor/types/globalTypes";
|
||||||
import WarehouseCreatePage, {
|
import WarehouseCreatePage, {
|
||||||
WarehouseCreatePageProps,
|
WarehouseCreatePageProps,
|
||||||
WarehouseCreatePageFormData
|
WarehouseCreatePageFormData
|
||||||
|
@ -39,8 +39,10 @@ storiesOf("Views / Warehouses / Create warehouse", module)
|
||||||
"postalCode",
|
"postalCode",
|
||||||
"streetAddress1",
|
"streetAddress1",
|
||||||
"streetAddress2"
|
"streetAddress2"
|
||||||
] as Array<keyof WarehouseCreatePageFormData>).map(field =>
|
] as Array<keyof WarehouseCreatePageFormData>).map(field => ({
|
||||||
formError(field)
|
__typename: "WarehouseError",
|
||||||
)}
|
code: WarehouseErrorCode.INVALID,
|
||||||
|
field
|
||||||
|
}))}
|
||||||
/>
|
/>
|
||||||
));
|
));
|
||||||
|
|
|
@ -3,7 +3,7 @@ import React from "react";
|
||||||
|
|
||||||
import { address, countries } from "@saleor/fixtures";
|
import { address, countries } from "@saleor/fixtures";
|
||||||
import Decorator from "@saleor/storybook/Decorator";
|
import Decorator from "@saleor/storybook/Decorator";
|
||||||
import { formError } from "@saleor/storybook/misc";
|
import { WarehouseErrorCode } from "@saleor/types/globalTypes";
|
||||||
import { warehouseList } from "../../fixtures";
|
import { warehouseList } from "../../fixtures";
|
||||||
import WarehouseDetailsPage, {
|
import WarehouseDetailsPage, {
|
||||||
WarehouseDetailsPageProps,
|
WarehouseDetailsPageProps,
|
||||||
|
@ -48,8 +48,10 @@ storiesOf("Views / Warehouses / Warehouse details", module)
|
||||||
"postalCode",
|
"postalCode",
|
||||||
"streetAddress1",
|
"streetAddress1",
|
||||||
"streetAddress2"
|
"streetAddress2"
|
||||||
] as Array<keyof WarehouseDetailsPageFormData>).map(field =>
|
] as Array<keyof WarehouseDetailsPageFormData>).map(field => ({
|
||||||
formError(field)
|
__typename: "WarehouseError",
|
||||||
)}
|
code: WarehouseErrorCode.INVALID,
|
||||||
|
field
|
||||||
|
}))}
|
||||||
/>
|
/>
|
||||||
));
|
));
|
||||||
|
|
Loading…
Reference in a new issue