Improve single warehouse UX
This commit is contained in:
parent
60ed62ecd0
commit
94dad3e4d7
4 changed files with 3186 additions and 1620 deletions
|
@ -109,11 +109,37 @@ storiesOf(
|
||||||
step={ProductVariantCreatorStep.prices}
|
step={ProductVariantCreatorStep.prices}
|
||||||
/>
|
/>
|
||||||
))
|
))
|
||||||
|
.add("apply to all when one warehouse", () => (
|
||||||
|
<ProductVariantCreatorContent
|
||||||
|
{...props}
|
||||||
|
data={{
|
||||||
|
...data,
|
||||||
|
stock: {
|
||||||
|
...data.stock,
|
||||||
|
mode: "all"
|
||||||
|
},
|
||||||
|
warehouses: [data.warehouses[0]]
|
||||||
|
}}
|
||||||
|
step={ProductVariantCreatorStep.prices}
|
||||||
|
warehouses={[props.warehouses[0]]}
|
||||||
|
/>
|
||||||
|
))
|
||||||
.add("apply to attribute", () => (
|
.add("apply to attribute", () => (
|
||||||
<ProductVariantCreatorContent
|
<ProductVariantCreatorContent
|
||||||
{...props}
|
{...props}
|
||||||
step={ProductVariantCreatorStep.prices}
|
step={ProductVariantCreatorStep.prices}
|
||||||
/>
|
/>
|
||||||
|
))
|
||||||
|
.add("apply to attribute when one warehouse", () => (
|
||||||
|
<ProductVariantCreatorContent
|
||||||
|
{...props}
|
||||||
|
data={{
|
||||||
|
...data,
|
||||||
|
warehouses: [data.warehouses[0]]
|
||||||
|
}}
|
||||||
|
step={ProductVariantCreatorStep.prices}
|
||||||
|
warehouses={[props.warehouses[0]]}
|
||||||
|
/>
|
||||||
));
|
));
|
||||||
|
|
||||||
storiesOf("Views / Products / Create multiple variants / summary", module)
|
storiesOf("Views / Products / Create multiple variants / summary", module)
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import Button from "@material-ui/core/Button";
|
import Button from "@material-ui/core/Button";
|
||||||
|
import Typography from "@material-ui/core/Typography";
|
||||||
import { makeStyles } from "@material-ui/core/styles";
|
import { makeStyles } from "@material-ui/core/styles";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { FormattedMessage, useIntl, IntlShape } from "react-intl";
|
import { FormattedMessage, useIntl, IntlShape } from "react-intl";
|
||||||
|
@ -6,6 +7,7 @@ import { FormattedMessage, useIntl, IntlShape } from "react-intl";
|
||||||
import useWizard from "@saleor/hooks/useWizard";
|
import useWizard from "@saleor/hooks/useWizard";
|
||||||
import PageHeader from "@saleor/components/PageHeader";
|
import PageHeader from "@saleor/components/PageHeader";
|
||||||
import Container from "@saleor/components/Container";
|
import Container from "@saleor/components/Container";
|
||||||
|
import Hr from "@saleor/components/Hr";
|
||||||
import { ProductVariantBulkCreateInput } from "../../../types/globalTypes";
|
import { ProductVariantBulkCreateInput } from "../../../types/globalTypes";
|
||||||
import { createInitialForm, ProductVariantCreateFormData } from "./form";
|
import { createInitialForm, ProductVariantCreateFormData } from "./form";
|
||||||
import ProductVariantCreatorContent, {
|
import ProductVariantCreatorContent, {
|
||||||
|
@ -26,6 +28,12 @@ const useStyles = makeStyles(
|
||||||
overflowX: "visible",
|
overflowX: "visible",
|
||||||
overflowY: "hidden",
|
overflowY: "hidden",
|
||||||
width: 800
|
width: 800
|
||||||
|
},
|
||||||
|
description: {
|
||||||
|
marginTop: theme.spacing()
|
||||||
|
},
|
||||||
|
hr: {
|
||||||
|
margin: theme.spacing(3, 0)
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
{ name: "ProductVariantCreatePage" }
|
{ name: "ProductVariantCreatePage" }
|
||||||
|
@ -94,6 +102,29 @@ function getTitle(step: ProductVariantCreatorStep, intl: IntlShape): string {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getDescription(
|
||||||
|
step: ProductVariantCreatorStep,
|
||||||
|
intl: IntlShape
|
||||||
|
): string {
|
||||||
|
switch (step) {
|
||||||
|
case ProductVariantCreatorStep.values:
|
||||||
|
return intl.formatMessage({
|
||||||
|
defaultMessage:
|
||||||
|
"Selected values will be used to create variants for the configurable product."
|
||||||
|
});
|
||||||
|
case ProductVariantCreatorStep.prices:
|
||||||
|
return intl.formatMessage({
|
||||||
|
defaultMessage:
|
||||||
|
"Based on your selections we will create 8 products. Use this step to customize price and stocks for your new products."
|
||||||
|
});
|
||||||
|
case ProductVariantCreatorStep.summary:
|
||||||
|
return intl.formatMessage({
|
||||||
|
defaultMessage:
|
||||||
|
"Here is the summary of variants that will be created. You can change prices, stocks an SKU for each one created."
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const ProductVariantCreatePage: React.FC<ProductVariantCreatePageProps> = props => {
|
const ProductVariantCreatePage: React.FC<ProductVariantCreatePageProps> = props => {
|
||||||
const {
|
const {
|
||||||
attributes,
|
attributes,
|
||||||
|
@ -136,12 +167,21 @@ const ProductVariantCreatePage: React.FC<ProductVariantCreatePageProps> = props
|
||||||
type: ProductVariantCreateReducerActionType.reload
|
type: ProductVariantCreateReducerActionType.reload
|
||||||
});
|
});
|
||||||
|
|
||||||
React.useEffect(reloadForm, [attributes.length]);
|
React.useEffect(reloadForm, [attributes.length, warehouses.length]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Container>
|
<Container>
|
||||||
<ProductVariantCreateTabs step={step} onStepClick={setStep} />
|
<ProductVariantCreateTabs step={step} onStepClick={setStep} />
|
||||||
<PageHeader title={getTitle(step, intl)}>
|
<PageHeader
|
||||||
|
title={
|
||||||
|
<>
|
||||||
|
{getTitle(step, intl)}
|
||||||
|
<Typography className={classes.description} variant="body2">
|
||||||
|
{getDescription(step, intl)}
|
||||||
|
</Typography>
|
||||||
|
</>
|
||||||
|
}
|
||||||
|
>
|
||||||
{step !== ProductVariantCreatorStep.values && (
|
{step !== ProductVariantCreatorStep.values && (
|
||||||
<Button className={classes.button} color="primary" onClick={prevStep}>
|
<Button className={classes.button} color="primary" onClick={prevStep}>
|
||||||
<FormattedMessage
|
<FormattedMessage
|
||||||
|
@ -175,6 +215,7 @@ const ProductVariantCreatePage: React.FC<ProductVariantCreatePageProps> = props
|
||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
</PageHeader>
|
</PageHeader>
|
||||||
|
<Hr className={classes.hr} />
|
||||||
<ProductVariantCreatorContent
|
<ProductVariantCreatorContent
|
||||||
{...contentProps}
|
{...contentProps}
|
||||||
attributes={attributes}
|
attributes={attributes}
|
||||||
|
|
|
@ -54,6 +54,7 @@ const useStyles = makeStyles(
|
||||||
columnGap: theme.spacing(3) + "px",
|
columnGap: theme.spacing(3) + "px",
|
||||||
display: "grid",
|
display: "grid",
|
||||||
gridTemplateColumns: "repeat(3, 288px)",
|
gridTemplateColumns: "repeat(3, 288px)",
|
||||||
|
marginTop: theme.spacing(2),
|
||||||
rowGap: theme.spacing(2) + "px"
|
rowGap: theme.spacing(2) + "px"
|
||||||
},
|
},
|
||||||
stockHeader: {
|
stockHeader: {
|
||||||
|
@ -293,6 +294,12 @@ const ProductVariantCreatorStock: React.FC<ProductVariantCreatorStockProps> = pr
|
||||||
)}
|
)}
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
{data.stock.mode === "attribute" && !!data.stock.attribute && (
|
||||||
|
<>
|
||||||
|
<FormSpacer />
|
||||||
|
<Hr />
|
||||||
|
</>
|
||||||
|
)}
|
||||||
<FormSpacer />
|
<FormSpacer />
|
||||||
<FormControlLabel
|
<FormControlLabel
|
||||||
value="skip"
|
value="skip"
|
||||||
|
|
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue