Merge pull request #607 from mirumee/ref/add-2.10.1
Apply fixes from 2.10.1
This commit is contained in:
commit
38e790a4dd
51 changed files with 2369 additions and 126 deletions
|
@ -12,6 +12,11 @@ All notable, unreleased changes to this project will be documented in this file.
|
|||
- Move fragments to separate directory to avoid circular imports - #592 by @dominik-zeglen
|
||||
- Add order invoices management - #570 by @orzechdev
|
||||
|
||||
## 2.10.1
|
||||
|
||||
- Add weight field and fix warehouse country selection - #597 by @dominik-zeglen
|
||||
- Fix weight based rate update - #604 by @dominik-zeglen
|
||||
|
||||
## 2.10.0
|
||||
|
||||
- Fix minor bugs - #244 by @dominik-zeglen
|
||||
|
|
|
@ -40,7 +40,7 @@ $ cd saleor-dashboard
|
|||
To use the official stable release, checkout to a release tag:
|
||||
|
||||
```
|
||||
$ git checkout 2.10.0
|
||||
$ git checkout 2.10.1
|
||||
```
|
||||
|
||||
See the list of all releases here: https://github.com/mirumee/saleor-dashboard/releases/
|
||||
|
|
|
@ -3704,6 +3704,14 @@
|
|||
"src_dot_products_dot_components_dot_ProductPricing_dot_3015886868": {
|
||||
"string": "Charge taxes for this item"
|
||||
},
|
||||
"src_dot_products_dot_components_dot_ProductShipping_dot_1325966144": {
|
||||
"context": "product shipping",
|
||||
"string": "Shipping"
|
||||
},
|
||||
"src_dot_products_dot_components_dot_ProductShipping_dot_746695941": {
|
||||
"context": "product weight",
|
||||
"string": "Weight"
|
||||
},
|
||||
"src_dot_products_dot_components_dot_ProductStocks_dot_2585918415": {
|
||||
"string": "SKU (Stock Keeping Unit)"
|
||||
},
|
||||
|
@ -3741,14 +3749,6 @@
|
|||
"src_dot_products_dot_components_dot_ProductUpdatePage_dot_2706108815": {
|
||||
"string": "Add search engine title and description to make this product easier to find"
|
||||
},
|
||||
"src_dot_products_dot_components_dot_ProductVariantAttributes_dot_1536841622": {
|
||||
"context": "product attribute error",
|
||||
"string": "All attributes should have value"
|
||||
},
|
||||
"src_dot_products_dot_components_dot_ProductVariantAttributes_dot_258966189": {
|
||||
"context": "product attribute error",
|
||||
"string": "This variant already exists"
|
||||
},
|
||||
"src_dot_products_dot_components_dot_ProductVariantCreatePage_dot_2853608829": {
|
||||
"context": "button",
|
||||
"string": "Save variant"
|
||||
|
@ -5134,6 +5134,10 @@
|
|||
"src_dot_utils_dot_errors_dot_attributeCannotBeAssigned": {
|
||||
"string": "This attribute cannot be assigned to this product type"
|
||||
},
|
||||
"src_dot_utils_dot_errors_dot_attributeRequired": {
|
||||
"context": "product attribute error",
|
||||
"string": "All attributes should have value"
|
||||
},
|
||||
"src_dot_utils_dot_errors_dot_attributeVariantsDisabled": {
|
||||
"string": "Variants are disabled in this product type"
|
||||
},
|
||||
|
@ -5262,6 +5266,10 @@
|
|||
"src_dot_utils_dot_errors_dot_variantNoDigitalContent": {
|
||||
"string": "This variant does not have any digital content"
|
||||
},
|
||||
"src_dot_utils_dot_errors_dot_variantUnique": {
|
||||
"context": "product attribute error",
|
||||
"string": "This variant already exists"
|
||||
},
|
||||
"src_dot_vouchers": {
|
||||
"context": "vouchers section name",
|
||||
"string": "Vouchers"
|
||||
|
|
2
package-lock.json
generated
2
package-lock.json
generated
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "saleor-dashboard",
|
||||
"version": "2.10.0",
|
||||
"version": "2.10.1",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "saleor-dashboard",
|
||||
"version": "2.10.0",
|
||||
"version": "2.10.1",
|
||||
"main": "src/index.tsx",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
|
|
@ -79,14 +79,16 @@ export const TimelineNote: React.FC<TimelineNoteProps> = props => {
|
|||
|
||||
return (
|
||||
<div className={classes.root}>
|
||||
<Avatar
|
||||
className={classes.avatar}
|
||||
style={{ background: palette[CRC.str(user.email) % palette.length] }}
|
||||
>
|
||||
<PersonIcon />
|
||||
</Avatar>
|
||||
{user && (
|
||||
<Avatar
|
||||
className={classes.avatar}
|
||||
style={{ background: palette[CRC.str(user.email) % palette.length] }}
|
||||
>
|
||||
<PersonIcon />
|
||||
</Avatar>
|
||||
)}
|
||||
<div className={classes.title}>
|
||||
<Typography>{user.email}</Typography>
|
||||
<Typography>{user?.email}</Typography>
|
||||
<Typography>
|
||||
<DateTime date={date} />
|
||||
</Typography>
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
import gql from "graphql-tag";
|
||||
|
||||
import { weightFragment } from "./weight";
|
||||
|
||||
export const stockFragment = gql`
|
||||
fragment StockFragment on Stock {
|
||||
id
|
||||
|
@ -102,6 +104,7 @@ export const productFragmentDetails = gql`
|
|||
${fragmentMoney}
|
||||
${productVariantAttributesFragment}
|
||||
${stockFragment}
|
||||
${weightFragment}
|
||||
fragment Product on Product {
|
||||
...ProductVariantAttributesFragment
|
||||
name
|
||||
|
@ -167,6 +170,9 @@ export const productFragmentDetails = gql`
|
|||
name
|
||||
hasVariants
|
||||
}
|
||||
weight {
|
||||
...WeightFragment
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
|
@ -174,6 +180,7 @@ export const fragmentVariant = gql`
|
|||
${fragmentMoney}
|
||||
${fragmentProductImage}
|
||||
${stockFragment}
|
||||
${weightFragment}
|
||||
fragment ProductVariant on ProductVariant {
|
||||
id
|
||||
attributes {
|
||||
|
@ -229,5 +236,8 @@ export const fragmentVariant = gql`
|
|||
...StockFragment
|
||||
}
|
||||
trackInventory
|
||||
weight {
|
||||
...WeightFragment
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
|
|
@ -168,6 +168,12 @@ export interface Product_variants {
|
|||
trackInventory: boolean;
|
||||
}
|
||||
|
||||
export interface Product_weight {
|
||||
__typename: "Weight";
|
||||
unit: string;
|
||||
value: number;
|
||||
}
|
||||
|
||||
export interface Product {
|
||||
__typename: "Product";
|
||||
id: string;
|
||||
|
@ -188,4 +194,5 @@ export interface Product {
|
|||
publicationDate: any | null;
|
||||
images: (Product_images | null)[] | null;
|
||||
variants: (Product_variants | null)[] | null;
|
||||
weight: Product_weight | null;
|
||||
}
|
||||
|
|
|
@ -103,6 +103,12 @@ export interface ProductVariant_stocks {
|
|||
warehouse: ProductVariant_stocks_warehouse;
|
||||
}
|
||||
|
||||
export interface ProductVariant_weight {
|
||||
__typename: "Weight";
|
||||
unit: string;
|
||||
value: number;
|
||||
}
|
||||
|
||||
export interface ProductVariant {
|
||||
__typename: "ProductVariant";
|
||||
id: string;
|
||||
|
@ -115,4 +121,5 @@ export interface ProductVariant {
|
|||
sku: string;
|
||||
stocks: (ProductVariant_stocks | null)[] | null;
|
||||
trackInventory: boolean;
|
||||
weight: ProductVariant_weight | null;
|
||||
}
|
||||
|
|
13
src/fragments/types/WeightFragment.ts
Normal file
13
src/fragments/types/WeightFragment.ts
Normal file
|
@ -0,0 +1,13 @@
|
|||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
// This file was automatically generated and should not be edited.
|
||||
|
||||
// ====================================================
|
||||
// GraphQL fragment: WeightFragment
|
||||
// ====================================================
|
||||
|
||||
export interface WeightFragment {
|
||||
__typename: "Weight";
|
||||
unit: string;
|
||||
value: number;
|
||||
}
|
8
src/fragments/weight.ts
Normal file
8
src/fragments/weight.ts
Normal file
|
@ -0,0 +1,8 @@
|
|||
import gql from "graphql-tag";
|
||||
|
||||
export const weightFragment = gql`
|
||||
fragment WeightFragment on Weight {
|
||||
unit
|
||||
value
|
||||
}
|
||||
`;
|
|
@ -59,6 +59,10 @@ export function decimal(value: string | number) {
|
|||
return value;
|
||||
}
|
||||
|
||||
export function weight(value: string) {
|
||||
return value === "" ? null : parseFloat(value);
|
||||
}
|
||||
|
||||
export const removeDoubleSlashes = (url: string) =>
|
||||
url.replace(/([^:]\/)\/+/g, "$1");
|
||||
|
||||
|
|
|
@ -820,8 +820,8 @@ export const order = (placeholder: string): OrderDetails_order => ({
|
|||
date: "2018-09-17T13:22:24.376193+00:00",
|
||||
email: null,
|
||||
emailType: null,
|
||||
invoiceNumber: "23/07/2020",
|
||||
id: "T3JkZXJFdmVudDoyMQ==",
|
||||
invoiceNumber: "23/07/2020",
|
||||
message: null,
|
||||
quantity: 1,
|
||||
type: OrderEventsEnum.FULFILLMENT_FULFILLED_ITEMS,
|
||||
|
@ -830,6 +830,32 @@ export const order = (placeholder: string): OrderDetails_order => ({
|
|||
email: "admin@example.com",
|
||||
id: "QWRkcmVzczoxNQ=="
|
||||
}
|
||||
},
|
||||
{
|
||||
__typename: "OrderEvent",
|
||||
amount: null,
|
||||
date: "2019-09-17T13:22:24.376193+00:00",
|
||||
email: null,
|
||||
emailType: null,
|
||||
id: "T3JkZXJFdmVudDo0",
|
||||
invoiceNumber: "23/07/2020",
|
||||
message: "This is note",
|
||||
quantity: null,
|
||||
type: OrderEventsEnum.NOTE_ADDED,
|
||||
user: null
|
||||
},
|
||||
{
|
||||
__typename: "OrderEvent",
|
||||
amount: null,
|
||||
date: "2019-09-17T13:22:24.376193+00:00",
|
||||
email: null,
|
||||
emailType: null,
|
||||
id: "T3JkZXJFdmVudDo1",
|
||||
invoiceNumber: "24/07/2020",
|
||||
message: "This is note",
|
||||
quantity: null,
|
||||
type: OrderEventsEnum.NOTE_ADDED,
|
||||
user: null
|
||||
}
|
||||
],
|
||||
fulfillments: [
|
||||
|
|
|
@ -105,7 +105,7 @@ const ProductTypeCreatePage: React.FC<ProductTypeCreatePageProps> = ({
|
|||
<ProductTypeShipping
|
||||
disabled={disabled}
|
||||
data={data}
|
||||
defaultWeightUnit={defaultWeightUnit}
|
||||
weightUnit={defaultWeightUnit}
|
||||
onChange={change}
|
||||
/>
|
||||
</div>
|
||||
|
|
|
@ -199,7 +199,7 @@ const ProductTypeDetailsPage: React.FC<ProductTypeDetailsPageProps> = ({
|
|||
<ProductTypeShipping
|
||||
disabled={disabled}
|
||||
data={data}
|
||||
defaultWeightUnit={defaultWeightUnit}
|
||||
weightUnit={productType?.weight?.unit || defaultWeightUnit}
|
||||
onChange={change}
|
||||
/>
|
||||
</div>
|
||||
|
|
|
@ -6,21 +6,19 @@ import { ControlledCheckbox } from "@saleor/components/ControlledCheckbox";
|
|||
import React from "react";
|
||||
import { useIntl } from "react-intl";
|
||||
|
||||
import { WeightUnitsEnum } from "../../../types/globalTypes";
|
||||
|
||||
interface ProductTypeShippingProps {
|
||||
data: {
|
||||
isShippingRequired: boolean;
|
||||
weight: number | null;
|
||||
};
|
||||
defaultWeightUnit: WeightUnitsEnum;
|
||||
weightUnit: string;
|
||||
disabled: boolean;
|
||||
onChange: (event: React.ChangeEvent<any>) => void;
|
||||
}
|
||||
|
||||
const ProductTypeShipping: React.FC<ProductTypeShippingProps> = ({
|
||||
data,
|
||||
defaultWeightUnit,
|
||||
weightUnit,
|
||||
disabled,
|
||||
onChange
|
||||
}) => {
|
||||
|
@ -48,7 +46,7 @@ const ProductTypeShipping: React.FC<ProductTypeShippingProps> = ({
|
|||
{data.isShippingRequired && (
|
||||
<TextField
|
||||
disabled={disabled}
|
||||
InputProps={{ endAdornment: defaultWeightUnit }}
|
||||
InputProps={{ endAdornment: weightUnit }}
|
||||
label={intl.formatMessage({
|
||||
defaultMessage: "Weight"
|
||||
})}
|
||||
|
|
|
@ -42,6 +42,7 @@ import ProductAttributes, {
|
|||
import ProductDetailsForm from "../ProductDetailsForm";
|
||||
import ProductOrganization from "../ProductOrganization";
|
||||
import ProductPricing from "../ProductPricing";
|
||||
import ProductShipping from "../ProductShipping/ProductShipping";
|
||||
import ProductStocks, { ProductStockInput } from "../ProductStocks";
|
||||
|
||||
interface FormData {
|
||||
|
@ -59,6 +60,7 @@ interface FormData {
|
|||
sku: string;
|
||||
stockQuantity: number;
|
||||
trackInventory: boolean;
|
||||
weight: string;
|
||||
}
|
||||
export interface ProductCreatePageSubmitData extends FormData {
|
||||
attributes: ProductAttributeInput[];
|
||||
|
@ -82,6 +84,7 @@ interface ProductCreatePageProps {
|
|||
}>;
|
||||
header: string;
|
||||
saveButtonBarState: ConfirmButtonTransitionState;
|
||||
weightUnit: string;
|
||||
warehouses: SearchWarehouses_search_edges_node[];
|
||||
fetchCategories: (data: string) => void;
|
||||
fetchCollections: (data: string) => void;
|
||||
|
@ -107,6 +110,7 @@ export const ProductCreatePage: React.FC<ProductCreatePageProps> = ({
|
|||
warehouses,
|
||||
onBack,
|
||||
fetchProductTypes,
|
||||
weightUnit,
|
||||
onSubmit
|
||||
}: ProductCreatePageProps) => {
|
||||
const intl = useIntl();
|
||||
|
@ -143,7 +147,8 @@ export const ProductCreatePage: React.FC<ProductCreatePageProps> = ({
|
|||
seoTitle: "",
|
||||
sku: null,
|
||||
stockQuantity: null,
|
||||
trackInventory: false
|
||||
trackInventory: false,
|
||||
weight: ""
|
||||
};
|
||||
|
||||
// Display values
|
||||
|
@ -234,6 +239,13 @@ export const ProductCreatePage: React.FC<ProductCreatePageProps> = ({
|
|||
<CardSpacer />
|
||||
{!!productType && !productType.hasVariants && (
|
||||
<>
|
||||
<ProductShipping
|
||||
data={data}
|
||||
disabled={disabled}
|
||||
errors={errors}
|
||||
weightUnit={weightUnit}
|
||||
onChange={change}
|
||||
/>
|
||||
<ProductPricing
|
||||
currency={currency}
|
||||
data={data}
|
||||
|
|
65
src/products/components/ProductShipping/ProductShipping.tsx
Normal file
65
src/products/components/ProductShipping/ProductShipping.tsx
Normal file
|
@ -0,0 +1,65 @@
|
|||
import Card from "@material-ui/core/Card";
|
||||
import CardContent from "@material-ui/core/CardContent";
|
||||
import InputAdornment from "@material-ui/core/InputAdornment";
|
||||
import TextField from "@material-ui/core/TextField";
|
||||
import CardTitle from "@saleor/components/CardTitle";
|
||||
import Grid from "@saleor/components/Grid";
|
||||
import { ProductErrorFragment } from "@saleor/fragments/types/ProductErrorFragment";
|
||||
import { getFormErrors, getProductErrorMessage } from "@saleor/utils/errors";
|
||||
import React from "react";
|
||||
import { useIntl } from "react-intl";
|
||||
|
||||
interface ProductShippingProps {
|
||||
data: {
|
||||
weight: string;
|
||||
};
|
||||
disabled: boolean;
|
||||
errors: ProductErrorFragment[];
|
||||
weightUnit: string;
|
||||
onChange: (event: React.ChangeEvent<any>) => void;
|
||||
}
|
||||
|
||||
const ProductShipping: React.FC<ProductShippingProps> = props => {
|
||||
const { data, disabled, errors, weightUnit, onChange } = props;
|
||||
|
||||
const intl = useIntl();
|
||||
|
||||
const formErrors = getFormErrors(["weight"], errors);
|
||||
|
||||
return (
|
||||
<Card>
|
||||
<CardTitle
|
||||
title={intl.formatMessage({
|
||||
defaultMessage: "Shipping",
|
||||
description: "product shipping"
|
||||
})}
|
||||
/>
|
||||
<CardContent>
|
||||
<Grid variant="uniform">
|
||||
<TextField
|
||||
disabled={disabled}
|
||||
label={intl.formatMessage({
|
||||
defaultMessage: "Weight",
|
||||
description: "product weight"
|
||||
})}
|
||||
error={!!formErrors.weight}
|
||||
helperText={getProductErrorMessage(formErrors.weight, intl)}
|
||||
name="weight"
|
||||
value={data.weight}
|
||||
onChange={onChange}
|
||||
InputProps={{
|
||||
endAdornment: (
|
||||
<InputAdornment position="end">{weightUnit}</InputAdornment>
|
||||
),
|
||||
inputProps: {
|
||||
min: 0
|
||||
}
|
||||
}}
|
||||
/>
|
||||
</Grid>
|
||||
</CardContent>
|
||||
</Card>
|
||||
);
|
||||
};
|
||||
ProductShipping.displayName = "ProductShipping";
|
||||
export default ProductShipping;
|
0
src/products/components/ProductShipping/index.ts
Normal file
0
src/products/components/ProductShipping/index.ts
Normal file
|
@ -48,10 +48,12 @@ import ProductDetailsForm from "../ProductDetailsForm";
|
|||
import ProductImages from "../ProductImages";
|
||||
import ProductOrganization from "../ProductOrganization";
|
||||
import ProductPricing from "../ProductPricing";
|
||||
import ProductShipping from "../ProductShipping/ProductShipping";
|
||||
import ProductStocks, { ProductStockInput } from "../ProductStocks";
|
||||
import ProductVariants from "../ProductVariants";
|
||||
|
||||
export interface ProductUpdatePageProps extends ListActions {
|
||||
defaultWeightUnit: string;
|
||||
errors: ProductErrorFragment[];
|
||||
placeholderImage: string;
|
||||
collections: SearchCollections_search_edges_node[];
|
||||
|
@ -89,6 +91,7 @@ export interface ProductUpdatePageSubmitData extends ProductUpdatePageFormData {
|
|||
}
|
||||
|
||||
export const ProductUpdatePage: React.FC<ProductUpdatePageProps> = ({
|
||||
defaultWeightUnit,
|
||||
disabled,
|
||||
categories: categoryChoiceList,
|
||||
collections: collectionChoiceList,
|
||||
|
@ -278,33 +281,43 @@ export const ProductUpdatePage: React.FC<ProductUpdatePageProps> = ({
|
|||
toggleAll={toggleAll}
|
||||
/>
|
||||
) : (
|
||||
<ProductStocks
|
||||
data={data}
|
||||
disabled={disabled}
|
||||
errors={errors}
|
||||
stocks={stocks}
|
||||
warehouses={warehouses}
|
||||
onChange={(id, value) => {
|
||||
triggerChange();
|
||||
changeStockData(id, value);
|
||||
}}
|
||||
onFormDataChange={change}
|
||||
onWarehouseStockAdd={id => {
|
||||
triggerChange();
|
||||
addStock({
|
||||
data: null,
|
||||
id,
|
||||
label: warehouses.find(
|
||||
warehouse => warehouse.id === id
|
||||
).name,
|
||||
value: "0"
|
||||
});
|
||||
}}
|
||||
onWarehouseStockDelete={id => {
|
||||
triggerChange();
|
||||
removeStock(id);
|
||||
}}
|
||||
/>
|
||||
<>
|
||||
<ProductShipping
|
||||
data={data}
|
||||
disabled={disabled}
|
||||
errors={errors}
|
||||
weightUnit={product?.weight?.unit || defaultWeightUnit}
|
||||
onChange={change}
|
||||
/>
|
||||
<CardSpacer />
|
||||
<ProductStocks
|
||||
data={data}
|
||||
disabled={disabled}
|
||||
errors={errors}
|
||||
stocks={stocks}
|
||||
warehouses={warehouses}
|
||||
onChange={(id, value) => {
|
||||
triggerChange();
|
||||
changeStockData(id, value);
|
||||
}}
|
||||
onFormDataChange={change}
|
||||
onWarehouseStockAdd={id => {
|
||||
triggerChange();
|
||||
addStock({
|
||||
data: null,
|
||||
id,
|
||||
label: warehouses.find(
|
||||
warehouse => warehouse.id === id
|
||||
).name,
|
||||
value: "0"
|
||||
});
|
||||
}}
|
||||
onWarehouseStockDelete={id => {
|
||||
triggerChange();
|
||||
removeStock(id);
|
||||
}}
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
<CardSpacer />
|
||||
<SeoForm
|
||||
|
|
|
@ -12,9 +12,9 @@ import { ProductVariant_attributes_attribute_values } from "@saleor/fragments/ty
|
|||
import { FormsetAtomicData, FormsetChange } from "@saleor/hooks/useFormset";
|
||||
import { commonMessages } from "@saleor/intl";
|
||||
import { VariantCreate_productVariantCreate_errors } from "@saleor/products/types/VariantCreate";
|
||||
import { ProductErrorCode } from "@saleor/types/globalTypes";
|
||||
import { getProductVariantAttributeErrorMessage } from "@saleor/utils/errors/product";
|
||||
import React from "react";
|
||||
import { IntlShape, useIntl } from "react-intl";
|
||||
import { useIntl } from "react-intl";
|
||||
|
||||
export interface VariantAttributeInputData {
|
||||
values: ProductVariant_attributes_attribute_values[];
|
||||
|
@ -66,19 +66,6 @@ function getAttributeValueChoices(
|
|||
}));
|
||||
}
|
||||
|
||||
function translateErrors(intl: IntlShape) {
|
||||
return {
|
||||
[ProductErrorCode.REQUIRED]: intl.formatMessage({
|
||||
defaultMessage: "All attributes should have value",
|
||||
description: "product attribute error"
|
||||
}),
|
||||
[ProductErrorCode.UNIQUE]: intl.formatMessage({
|
||||
defaultMessage: "This variant already exists",
|
||||
description: "product attribute error"
|
||||
})
|
||||
};
|
||||
}
|
||||
|
||||
const ProductVariantAttributes: React.FC<ProductVariantAttributesProps> = ({
|
||||
attributes,
|
||||
disabled,
|
||||
|
@ -87,8 +74,6 @@ const ProductVariantAttributes: React.FC<ProductVariantAttributesProps> = ({
|
|||
}) => {
|
||||
const intl = useIntl();
|
||||
|
||||
const translatedErrors = translateErrors(intl);
|
||||
|
||||
return (
|
||||
<Card>
|
||||
<CardTitle
|
||||
|
@ -126,7 +111,7 @@ const ProductVariantAttributes: React.FC<ProductVariantAttributesProps> = ({
|
|||
.filter(error => error.field === "attributes")
|
||||
.map(error => (
|
||||
<Typography color="error" key={error.code}>
|
||||
{translatedErrors[error.code]}
|
||||
{getProductVariantAttributeErrorMessage(error, intl)}
|
||||
</Typography>
|
||||
))}
|
||||
</>
|
||||
|
|
|
@ -18,6 +18,7 @@ import { useIntl } from "react-intl";
|
|||
|
||||
import { maybe } from "../../../misc";
|
||||
import { ProductVariantCreateData_product } from "../../types/ProductVariantCreateData";
|
||||
import ProductShipping from "../ProductShipping/ProductShipping";
|
||||
import ProductStocks, { ProductStockInput } from "../ProductStocks";
|
||||
import ProductVariantAttributes, {
|
||||
VariantAttributeInputData
|
||||
|
@ -32,6 +33,7 @@ interface ProductVariantCreatePageFormData {
|
|||
quantity: string;
|
||||
sku: string;
|
||||
trackInventory: boolean;
|
||||
weight: string;
|
||||
}
|
||||
|
||||
export interface ProductVariantCreatePageSubmitData
|
||||
|
@ -48,6 +50,7 @@ interface ProductVariantCreatePageProps {
|
|||
product: ProductVariantCreateData_product;
|
||||
saveButtonBarState: ConfirmButtonTransitionState;
|
||||
warehouses: SearchWarehouses_search_edges_node[];
|
||||
weightUnit: string;
|
||||
onBack: () => void;
|
||||
onSubmit: (data: ProductVariantCreatePageSubmitData) => void;
|
||||
onVariantClick: (variantId: string) => void;
|
||||
|
@ -61,6 +64,7 @@ const ProductVariantCreatePage: React.FC<ProductVariantCreatePageProps> = ({
|
|||
product,
|
||||
saveButtonBarState,
|
||||
warehouses,
|
||||
weightUnit,
|
||||
onBack,
|
||||
onSubmit,
|
||||
onVariantClick
|
||||
|
@ -86,7 +90,8 @@ const ProductVariantCreatePage: React.FC<ProductVariantCreatePageProps> = ({
|
|||
price: "",
|
||||
quantity: "0",
|
||||
sku: "",
|
||||
trackInventory: true
|
||||
trackInventory: true,
|
||||
weight: ""
|
||||
};
|
||||
|
||||
const handleSubmit = (data: ProductVariantCreatePageFormData) =>
|
||||
|
@ -137,6 +142,14 @@ const ProductVariantCreatePage: React.FC<ProductVariantCreatePageProps> = ({
|
|||
onChange={change}
|
||||
/>
|
||||
<CardSpacer />
|
||||
<ProductShipping
|
||||
data={data}
|
||||
disabled={disabled}
|
||||
errors={errors}
|
||||
weightUnit={weightUnit}
|
||||
onChange={change}
|
||||
/>
|
||||
<CardSpacer />
|
||||
<ProductStocks
|
||||
data={data}
|
||||
disabled={disabled}
|
||||
|
|
|
@ -21,6 +21,7 @@ import { diff } from "fast-array-diff";
|
|||
import React from "react";
|
||||
|
||||
import { maybe } from "../../../misc";
|
||||
import ProductShipping from "../ProductShipping/ProductShipping";
|
||||
import ProductStocks, { ProductStockInput } from "../ProductStocks";
|
||||
import ProductVariantAttributes, {
|
||||
VariantAttributeInputData
|
||||
|
@ -35,6 +36,7 @@ export interface ProductVariantPageFormData {
|
|||
price: string;
|
||||
sku: string;
|
||||
trackInventory: boolean;
|
||||
weight: string;
|
||||
}
|
||||
|
||||
export interface ProductVariantPageSubmitData
|
||||
|
@ -46,6 +48,7 @@ export interface ProductVariantPageSubmitData
|
|||
}
|
||||
|
||||
interface ProductVariantPageProps {
|
||||
defaultWeightUnit: string;
|
||||
variant?: ProductVariant;
|
||||
errors: VariantUpdate_productVariantUpdate_errors[];
|
||||
saveButtonBarState: ConfirmButtonTransitionState;
|
||||
|
@ -62,6 +65,7 @@ interface ProductVariantPageProps {
|
|||
}
|
||||
|
||||
const ProductVariantPage: React.FC<ProductVariantPageProps> = ({
|
||||
defaultWeightUnit,
|
||||
errors,
|
||||
loading,
|
||||
header,
|
||||
|
@ -112,7 +116,8 @@ const ProductVariantPage: React.FC<ProductVariantPageProps> = ({
|
|||
costPrice: maybe(() => variant.costPrice.amount.toString(), ""),
|
||||
price: maybe(() => variant.price.amount.toString(), ""),
|
||||
sku: maybe(() => variant.sku, ""),
|
||||
trackInventory: variant?.trackInventory
|
||||
trackInventory: variant?.trackInventory,
|
||||
weight: variant?.weight?.value.toString() || ""
|
||||
};
|
||||
|
||||
const handleSubmit = (data: ProductVariantPageFormData) => {
|
||||
|
@ -195,6 +200,14 @@ const ProductVariantPage: React.FC<ProductVariantPageProps> = ({
|
|||
onChange={change}
|
||||
/>
|
||||
<CardSpacer />
|
||||
<ProductShipping
|
||||
data={data}
|
||||
disabled={loading}
|
||||
errors={errors}
|
||||
weightUnit={variant?.weight?.unit || defaultWeightUnit}
|
||||
onChange={change}
|
||||
/>
|
||||
<CardSpacer />
|
||||
<ProductStocks
|
||||
data={data}
|
||||
disabled={loading}
|
||||
|
|
|
@ -278,7 +278,12 @@ export const product: (
|
|||
warehouse: warehouseList[1]
|
||||
}
|
||||
],
|
||||
trackInventory: true
|
||||
trackInventory: true,
|
||||
weight: {
|
||||
__typename: "Weight",
|
||||
unit: "kg",
|
||||
value: 3
|
||||
}
|
||||
},
|
||||
{
|
||||
__typename: "ProductVariant",
|
||||
|
@ -308,9 +313,19 @@ export const product: (
|
|||
warehouse: warehouseList[0]
|
||||
}
|
||||
],
|
||||
trackInventory: false
|
||||
trackInventory: false,
|
||||
weight: {
|
||||
__typename: "Weight",
|
||||
unit: "kg",
|
||||
value: 4
|
||||
}
|
||||
}
|
||||
]
|
||||
],
|
||||
weight: {
|
||||
__typename: "Weight",
|
||||
unit: "kg",
|
||||
value: 5
|
||||
}
|
||||
});
|
||||
export const products = (
|
||||
placeholderImage: string
|
||||
|
@ -1654,7 +1669,12 @@ export const variant = (placeholderImage: string): ProductVariant => ({
|
|||
}
|
||||
}
|
||||
],
|
||||
trackInventory: true
|
||||
trackInventory: true,
|
||||
weight: {
|
||||
__typename: "Weight",
|
||||
unit: "kg",
|
||||
value: 6
|
||||
}
|
||||
});
|
||||
export const variantImages = (placeholderImage: string) =>
|
||||
variant(placeholderImage).images;
|
||||
|
|
|
@ -192,6 +192,7 @@ export const simpleProductUpdateMutation = gql`
|
|||
$addStocks: [StockInput!]!
|
||||
$deleteStocks: [ID!]!
|
||||
$updateStocks: [StockInput!]!
|
||||
$weight: WeightScalar
|
||||
) {
|
||||
productUpdate(
|
||||
id: $id
|
||||
|
@ -206,6 +207,7 @@ export const simpleProductUpdateMutation = gql`
|
|||
name: $name
|
||||
basePrice: $basePrice
|
||||
seo: $seo
|
||||
weight: $weight
|
||||
}
|
||||
) {
|
||||
errors: productErrors {
|
||||
|
@ -281,6 +283,7 @@ export const productCreateMutation = gql`
|
|||
$seo: SeoInput
|
||||
$stocks: [StockInput!]!
|
||||
$trackInventory: Boolean!
|
||||
$weight: WeightScalar
|
||||
) {
|
||||
productCreate(
|
||||
input: {
|
||||
|
@ -298,6 +301,7 @@ export const productCreateMutation = gql`
|
|||
seo: $seo
|
||||
stocks: $stocks
|
||||
trackInventory: $trackInventory
|
||||
weight: $weight
|
||||
}
|
||||
) {
|
||||
errors: productErrors {
|
||||
|
@ -346,6 +350,7 @@ export const variantUpdateMutation = gql`
|
|||
$sku: String
|
||||
$trackInventory: Boolean!
|
||||
$stocks: [StockInput!]!
|
||||
$weight: WeightScalar
|
||||
) {
|
||||
productVariantUpdate(
|
||||
id: $id
|
||||
|
@ -355,6 +360,7 @@ export const variantUpdateMutation = gql`
|
|||
price: $price
|
||||
sku: $sku
|
||||
trackInventory: $trackInventory
|
||||
weight: $weight
|
||||
}
|
||||
) {
|
||||
errors: productErrors {
|
||||
|
|
|
@ -174,6 +174,12 @@ export interface ProductCreate_productCreate_product_variants {
|
|||
trackInventory: boolean;
|
||||
}
|
||||
|
||||
export interface ProductCreate_productCreate_product_weight {
|
||||
__typename: "Weight";
|
||||
unit: string;
|
||||
value: number;
|
||||
}
|
||||
|
||||
export interface ProductCreate_productCreate_product {
|
||||
__typename: "Product";
|
||||
id: string;
|
||||
|
@ -194,6 +200,7 @@ export interface ProductCreate_productCreate_product {
|
|||
publicationDate: any | null;
|
||||
images: (ProductCreate_productCreate_product_images | null)[] | null;
|
||||
variants: (ProductCreate_productCreate_product_variants | null)[] | null;
|
||||
weight: ProductCreate_productCreate_product_weight | null;
|
||||
}
|
||||
|
||||
export interface ProductCreate_productCreate {
|
||||
|
@ -221,4 +228,5 @@ export interface ProductCreateVariables {
|
|||
seo?: SeoInput | null;
|
||||
stocks: StockInput[];
|
||||
trackInventory: boolean;
|
||||
weight?: any | null;
|
||||
}
|
||||
|
|
|
@ -168,6 +168,12 @@ export interface ProductDetails_product_variants {
|
|||
trackInventory: boolean;
|
||||
}
|
||||
|
||||
export interface ProductDetails_product_weight {
|
||||
__typename: "Weight";
|
||||
unit: string;
|
||||
value: number;
|
||||
}
|
||||
|
||||
export interface ProductDetails_product {
|
||||
__typename: "Product";
|
||||
id: string;
|
||||
|
@ -188,6 +194,7 @@ export interface ProductDetails_product {
|
|||
publicationDate: any | null;
|
||||
images: (ProductDetails_product_images | null)[] | null;
|
||||
variants: (ProductDetails_product_variants | null)[] | null;
|
||||
weight: ProductDetails_product_weight | null;
|
||||
}
|
||||
|
||||
export interface ProductDetails {
|
||||
|
|
|
@ -174,6 +174,12 @@ export interface ProductImageCreate_productImageCreate_product_variants {
|
|||
trackInventory: boolean;
|
||||
}
|
||||
|
||||
export interface ProductImageCreate_productImageCreate_product_weight {
|
||||
__typename: "Weight";
|
||||
unit: string;
|
||||
value: number;
|
||||
}
|
||||
|
||||
export interface ProductImageCreate_productImageCreate_product {
|
||||
__typename: "Product";
|
||||
id: string;
|
||||
|
@ -194,6 +200,7 @@ export interface ProductImageCreate_productImageCreate_product {
|
|||
publicationDate: any | null;
|
||||
images: (ProductImageCreate_productImageCreate_product_images | null)[] | null;
|
||||
variants: (ProductImageCreate_productImageCreate_product_variants | null)[] | null;
|
||||
weight: ProductImageCreate_productImageCreate_product_weight | null;
|
||||
}
|
||||
|
||||
export interface ProductImageCreate_productImageCreate {
|
||||
|
|
|
@ -174,6 +174,12 @@ export interface ProductImageUpdate_productImageUpdate_product_variants {
|
|||
trackInventory: boolean;
|
||||
}
|
||||
|
||||
export interface ProductImageUpdate_productImageUpdate_product_weight {
|
||||
__typename: "Weight";
|
||||
unit: string;
|
||||
value: number;
|
||||
}
|
||||
|
||||
export interface ProductImageUpdate_productImageUpdate_product {
|
||||
__typename: "Product";
|
||||
id: string;
|
||||
|
@ -194,6 +200,7 @@ export interface ProductImageUpdate_productImageUpdate_product {
|
|||
publicationDate: any | null;
|
||||
images: (ProductImageUpdate_productImageUpdate_product_images | null)[] | null;
|
||||
variants: (ProductImageUpdate_productImageUpdate_product_variants | null)[] | null;
|
||||
weight: ProductImageUpdate_productImageUpdate_product_weight | null;
|
||||
}
|
||||
|
||||
export interface ProductImageUpdate_productImageUpdate {
|
||||
|
|
|
@ -174,6 +174,12 @@ export interface ProductUpdate_productUpdate_product_variants {
|
|||
trackInventory: boolean;
|
||||
}
|
||||
|
||||
export interface ProductUpdate_productUpdate_product_weight {
|
||||
__typename: "Weight";
|
||||
unit: string;
|
||||
value: number;
|
||||
}
|
||||
|
||||
export interface ProductUpdate_productUpdate_product {
|
||||
__typename: "Product";
|
||||
id: string;
|
||||
|
@ -194,6 +200,7 @@ export interface ProductUpdate_productUpdate_product {
|
|||
publicationDate: any | null;
|
||||
images: (ProductUpdate_productUpdate_product_images | null)[] | null;
|
||||
variants: (ProductUpdate_productUpdate_product_variants | null)[] | null;
|
||||
weight: ProductUpdate_productUpdate_product_weight | null;
|
||||
}
|
||||
|
||||
export interface ProductUpdate_productUpdate {
|
||||
|
|
|
@ -103,6 +103,12 @@ export interface ProductVariantDetails_productVariant_stocks {
|
|||
warehouse: ProductVariantDetails_productVariant_stocks_warehouse;
|
||||
}
|
||||
|
||||
export interface ProductVariantDetails_productVariant_weight {
|
||||
__typename: "Weight";
|
||||
unit: string;
|
||||
value: number;
|
||||
}
|
||||
|
||||
export interface ProductVariantDetails_productVariant {
|
||||
__typename: "ProductVariant";
|
||||
id: string;
|
||||
|
@ -115,6 +121,7 @@ export interface ProductVariantDetails_productVariant {
|
|||
sku: string;
|
||||
stocks: (ProductVariantDetails_productVariant_stocks | null)[] | null;
|
||||
trackInventory: boolean;
|
||||
weight: ProductVariantDetails_productVariant_weight | null;
|
||||
}
|
||||
|
||||
export interface ProductVariantDetails {
|
||||
|
|
|
@ -174,6 +174,12 @@ export interface SimpleProductUpdate_productUpdate_product_variants {
|
|||
trackInventory: boolean;
|
||||
}
|
||||
|
||||
export interface SimpleProductUpdate_productUpdate_product_weight {
|
||||
__typename: "Weight";
|
||||
unit: string;
|
||||
value: number;
|
||||
}
|
||||
|
||||
export interface SimpleProductUpdate_productUpdate_product {
|
||||
__typename: "Product";
|
||||
id: string;
|
||||
|
@ -194,6 +200,7 @@ export interface SimpleProductUpdate_productUpdate_product {
|
|||
publicationDate: any | null;
|
||||
images: (SimpleProductUpdate_productUpdate_product_images | null)[] | null;
|
||||
variants: (SimpleProductUpdate_productUpdate_product_variants | null)[] | null;
|
||||
weight: SimpleProductUpdate_productUpdate_product_weight | null;
|
||||
}
|
||||
|
||||
export interface SimpleProductUpdate_productUpdate {
|
||||
|
@ -305,6 +312,12 @@ export interface SimpleProductUpdate_productVariantUpdate_productVariant_stocks
|
|||
warehouse: SimpleProductUpdate_productVariantUpdate_productVariant_stocks_warehouse;
|
||||
}
|
||||
|
||||
export interface SimpleProductUpdate_productVariantUpdate_productVariant_weight {
|
||||
__typename: "Weight";
|
||||
unit: string;
|
||||
value: number;
|
||||
}
|
||||
|
||||
export interface SimpleProductUpdate_productVariantUpdate_productVariant {
|
||||
__typename: "ProductVariant";
|
||||
id: string;
|
||||
|
@ -317,6 +330,7 @@ export interface SimpleProductUpdate_productVariantUpdate_productVariant {
|
|||
sku: string;
|
||||
stocks: (SimpleProductUpdate_productVariantUpdate_productVariant_stocks | null)[] | null;
|
||||
trackInventory: boolean;
|
||||
weight: SimpleProductUpdate_productVariantUpdate_productVariant_weight | null;
|
||||
}
|
||||
|
||||
export interface SimpleProductUpdate_productVariantUpdate {
|
||||
|
@ -429,6 +443,12 @@ export interface SimpleProductUpdate_productVariantStocksCreate_productVariant_s
|
|||
warehouse: SimpleProductUpdate_productVariantStocksCreate_productVariant_stocks_warehouse;
|
||||
}
|
||||
|
||||
export interface SimpleProductUpdate_productVariantStocksCreate_productVariant_weight {
|
||||
__typename: "Weight";
|
||||
unit: string;
|
||||
value: number;
|
||||
}
|
||||
|
||||
export interface SimpleProductUpdate_productVariantStocksCreate_productVariant {
|
||||
__typename: "ProductVariant";
|
||||
id: string;
|
||||
|
@ -441,6 +461,7 @@ export interface SimpleProductUpdate_productVariantStocksCreate_productVariant {
|
|||
sku: string;
|
||||
stocks: (SimpleProductUpdate_productVariantStocksCreate_productVariant_stocks | null)[] | null;
|
||||
trackInventory: boolean;
|
||||
weight: SimpleProductUpdate_productVariantStocksCreate_productVariant_weight | null;
|
||||
}
|
||||
|
||||
export interface SimpleProductUpdate_productVariantStocksCreate {
|
||||
|
@ -552,6 +573,12 @@ export interface SimpleProductUpdate_productVariantStocksDelete_productVariant_s
|
|||
warehouse: SimpleProductUpdate_productVariantStocksDelete_productVariant_stocks_warehouse;
|
||||
}
|
||||
|
||||
export interface SimpleProductUpdate_productVariantStocksDelete_productVariant_weight {
|
||||
__typename: "Weight";
|
||||
unit: string;
|
||||
value: number;
|
||||
}
|
||||
|
||||
export interface SimpleProductUpdate_productVariantStocksDelete_productVariant {
|
||||
__typename: "ProductVariant";
|
||||
id: string;
|
||||
|
@ -564,6 +591,7 @@ export interface SimpleProductUpdate_productVariantStocksDelete_productVariant {
|
|||
sku: string;
|
||||
stocks: (SimpleProductUpdate_productVariantStocksDelete_productVariant_stocks | null)[] | null;
|
||||
trackInventory: boolean;
|
||||
weight: SimpleProductUpdate_productVariantStocksDelete_productVariant_weight | null;
|
||||
}
|
||||
|
||||
export interface SimpleProductUpdate_productVariantStocksDelete {
|
||||
|
@ -676,6 +704,12 @@ export interface SimpleProductUpdate_productVariantStocksUpdate_productVariant_s
|
|||
warehouse: SimpleProductUpdate_productVariantStocksUpdate_productVariant_stocks_warehouse;
|
||||
}
|
||||
|
||||
export interface SimpleProductUpdate_productVariantStocksUpdate_productVariant_weight {
|
||||
__typename: "Weight";
|
||||
unit: string;
|
||||
value: number;
|
||||
}
|
||||
|
||||
export interface SimpleProductUpdate_productVariantStocksUpdate_productVariant {
|
||||
__typename: "ProductVariant";
|
||||
id: string;
|
||||
|
@ -688,6 +722,7 @@ export interface SimpleProductUpdate_productVariantStocksUpdate_productVariant {
|
|||
sku: string;
|
||||
stocks: (SimpleProductUpdate_productVariantStocksUpdate_productVariant_stocks | null)[] | null;
|
||||
trackInventory: boolean;
|
||||
weight: SimpleProductUpdate_productVariantStocksUpdate_productVariant_weight | null;
|
||||
}
|
||||
|
||||
export interface SimpleProductUpdate_productVariantStocksUpdate {
|
||||
|
@ -721,4 +756,5 @@ export interface SimpleProductUpdateVariables {
|
|||
addStocks: StockInput[];
|
||||
deleteStocks: string[];
|
||||
updateStocks: StockInput[];
|
||||
weight?: any | null;
|
||||
}
|
||||
|
|
|
@ -111,6 +111,12 @@ export interface VariantCreate_productVariantCreate_productVariant_stocks {
|
|||
warehouse: VariantCreate_productVariantCreate_productVariant_stocks_warehouse;
|
||||
}
|
||||
|
||||
export interface VariantCreate_productVariantCreate_productVariant_weight {
|
||||
__typename: "Weight";
|
||||
unit: string;
|
||||
value: number;
|
||||
}
|
||||
|
||||
export interface VariantCreate_productVariantCreate_productVariant {
|
||||
__typename: "ProductVariant";
|
||||
id: string;
|
||||
|
@ -123,6 +129,7 @@ export interface VariantCreate_productVariantCreate_productVariant {
|
|||
sku: string;
|
||||
stocks: (VariantCreate_productVariantCreate_productVariant_stocks | null)[] | null;
|
||||
trackInventory: boolean;
|
||||
weight: VariantCreate_productVariantCreate_productVariant_weight | null;
|
||||
}
|
||||
|
||||
export interface VariantCreate_productVariantCreate {
|
||||
|
|
|
@ -111,6 +111,12 @@ export interface VariantImageAssign_variantImageAssign_productVariant_stocks {
|
|||
warehouse: VariantImageAssign_variantImageAssign_productVariant_stocks_warehouse;
|
||||
}
|
||||
|
||||
export interface VariantImageAssign_variantImageAssign_productVariant_weight {
|
||||
__typename: "Weight";
|
||||
unit: string;
|
||||
value: number;
|
||||
}
|
||||
|
||||
export interface VariantImageAssign_variantImageAssign_productVariant {
|
||||
__typename: "ProductVariant";
|
||||
id: string;
|
||||
|
@ -123,6 +129,7 @@ export interface VariantImageAssign_variantImageAssign_productVariant {
|
|||
sku: string;
|
||||
stocks: (VariantImageAssign_variantImageAssign_productVariant_stocks | null)[] | null;
|
||||
trackInventory: boolean;
|
||||
weight: VariantImageAssign_variantImageAssign_productVariant_weight | null;
|
||||
}
|
||||
|
||||
export interface VariantImageAssign_variantImageAssign {
|
||||
|
|
|
@ -111,6 +111,12 @@ export interface VariantImageUnassign_variantImageUnassign_productVariant_stocks
|
|||
warehouse: VariantImageUnassign_variantImageUnassign_productVariant_stocks_warehouse;
|
||||
}
|
||||
|
||||
export interface VariantImageUnassign_variantImageUnassign_productVariant_weight {
|
||||
__typename: "Weight";
|
||||
unit: string;
|
||||
value: number;
|
||||
}
|
||||
|
||||
export interface VariantImageUnassign_variantImageUnassign_productVariant {
|
||||
__typename: "ProductVariant";
|
||||
id: string;
|
||||
|
@ -123,6 +129,7 @@ export interface VariantImageUnassign_variantImageUnassign_productVariant {
|
|||
sku: string;
|
||||
stocks: (VariantImageUnassign_variantImageUnassign_productVariant_stocks | null)[] | null;
|
||||
trackInventory: boolean;
|
||||
weight: VariantImageUnassign_variantImageUnassign_productVariant_weight | null;
|
||||
}
|
||||
|
||||
export interface VariantImageUnassign_variantImageUnassign {
|
||||
|
|
|
@ -111,6 +111,12 @@ export interface VariantUpdate_productVariantUpdate_productVariant_stocks {
|
|||
warehouse: VariantUpdate_productVariantUpdate_productVariant_stocks_warehouse;
|
||||
}
|
||||
|
||||
export interface VariantUpdate_productVariantUpdate_productVariant_weight {
|
||||
__typename: "Weight";
|
||||
unit: string;
|
||||
value: number;
|
||||
}
|
||||
|
||||
export interface VariantUpdate_productVariantUpdate_productVariant {
|
||||
__typename: "ProductVariant";
|
||||
id: string;
|
||||
|
@ -123,6 +129,7 @@ export interface VariantUpdate_productVariantUpdate_productVariant {
|
|||
sku: string;
|
||||
stocks: (VariantUpdate_productVariantUpdate_productVariant_stocks | null)[] | null;
|
||||
trackInventory: boolean;
|
||||
weight: VariantUpdate_productVariantUpdate_productVariant_weight | null;
|
||||
}
|
||||
|
||||
export interface VariantUpdate_productVariantUpdate {
|
||||
|
@ -235,6 +242,12 @@ export interface VariantUpdate_productVariantStocksUpdate_productVariant_stocks
|
|||
warehouse: VariantUpdate_productVariantStocksUpdate_productVariant_stocks_warehouse;
|
||||
}
|
||||
|
||||
export interface VariantUpdate_productVariantStocksUpdate_productVariant_weight {
|
||||
__typename: "Weight";
|
||||
unit: string;
|
||||
value: number;
|
||||
}
|
||||
|
||||
export interface VariantUpdate_productVariantStocksUpdate_productVariant {
|
||||
__typename: "ProductVariant";
|
||||
id: string;
|
||||
|
@ -247,6 +260,7 @@ export interface VariantUpdate_productVariantStocksUpdate_productVariant {
|
|||
sku: string;
|
||||
stocks: (VariantUpdate_productVariantStocksUpdate_productVariant_stocks | null)[] | null;
|
||||
trackInventory: boolean;
|
||||
weight: VariantUpdate_productVariantStocksUpdate_productVariant_weight | null;
|
||||
}
|
||||
|
||||
export interface VariantUpdate_productVariantStocksUpdate {
|
||||
|
@ -337,4 +351,5 @@ export interface VariantUpdateVariables {
|
|||
sku?: string | null;
|
||||
trackInventory: boolean;
|
||||
stocks: StockInput[];
|
||||
weight?: any | null;
|
||||
}
|
||||
|
|
|
@ -181,6 +181,7 @@ export interface ProductUpdatePageFormData {
|
|||
seoTitle: string;
|
||||
sku: string;
|
||||
trackInventory: boolean;
|
||||
weight: string;
|
||||
}
|
||||
|
||||
export function getProductUpdatePageFormData(
|
||||
|
@ -210,7 +211,8 @@ export function getProductUpdatePageFormData(
|
|||
: undefined,
|
||||
""
|
||||
),
|
||||
trackInventory: !!product?.variants[0]?.trackInventory
|
||||
trackInventory: !!product?.variants[0]?.trackInventory,
|
||||
weight: product?.weight?.value.toString() || ""
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ import { useWarehouseList } from "@saleor/warehouses/queries";
|
|||
import React from "react";
|
||||
import { useIntl } from "react-intl";
|
||||
|
||||
import { decimal, maybe } from "../../misc";
|
||||
import { decimal, maybe, weight } from "../../misc";
|
||||
import ProductCreatePage, {
|
||||
ProductCreatePageSubmitData
|
||||
} from "../components/ProductCreatePage";
|
||||
|
@ -96,7 +96,8 @@ export const ProductCreateView: React.FC = () => {
|
|||
quantity: parseInt(stock.value, 0),
|
||||
warehouse: stock.id
|
||||
})),
|
||||
trackInventory: formData.trackInventory
|
||||
trackInventory: formData.trackInventory,
|
||||
weight: weight(formData.weight)
|
||||
}
|
||||
});
|
||||
};
|
||||
|
@ -158,6 +159,7 @@ export const ProductCreateView: React.FC = () => {
|
|||
warehouses={
|
||||
warehouses.data?.warehouses.edges.map(edge => edge.node) || []
|
||||
}
|
||||
weightUnit={shop?.defaultWeightUnit}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
|
|
|
@ -9,6 +9,7 @@ import { DEFAULT_INITIAL_SEARCH_DATA } from "@saleor/config";
|
|||
import useBulkActions from "@saleor/hooks/useBulkActions";
|
||||
import useNavigator from "@saleor/hooks/useNavigator";
|
||||
import useNotifier from "@saleor/hooks/useNotifier";
|
||||
import useShop from "@saleor/hooks/useShop";
|
||||
import { commonMessages } from "@saleor/intl";
|
||||
import useCategorySearch from "@saleor/searches/useCategorySearch";
|
||||
import useCollectionSearch from "@saleor/searches/useCollectionSearch";
|
||||
|
@ -75,6 +76,7 @@ export const ProductUpdate: React.FC<ProductUpdateProps> = ({ id, params }) => {
|
|||
first: 50
|
||||
}
|
||||
});
|
||||
const shop = useShop();
|
||||
|
||||
const [openModal, closeModal] = createDialogActionHandlers<
|
||||
ProductUrlDialog,
|
||||
|
@ -217,6 +219,7 @@ export const ProductUpdate: React.FC<ProductUpdateProps> = ({ id, params }) => {
|
|||
<ProductUpdatePage
|
||||
categories={categories}
|
||||
collections={collections}
|
||||
defaultWeightUnit={shop?.defaultWeightUnit}
|
||||
disabled={disableFormSave}
|
||||
errors={errors}
|
||||
fetchCategories={searchCategories}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { decimal } from "@saleor/misc";
|
||||
import { decimal, weight } from "@saleor/misc";
|
||||
import { ProductUpdatePageSubmitData } from "@saleor/products/components/ProductUpdatePage";
|
||||
import { ProductDetails_product } from "@saleor/products/types/ProductDetails";
|
||||
import { ProductImageCreateVariables } from "@saleor/products/types/ProductImageCreate";
|
||||
|
@ -48,7 +48,8 @@ export function createUpdateHandler(
|
|||
sku: data.sku,
|
||||
trackInventory: data.trackInventory
|
||||
},
|
||||
updateStocks: data.updateStocks.map(mapFormsetStockToStockInput)
|
||||
updateStocks: data.updateStocks.map(mapFormsetStockToStockInput),
|
||||
weight: weight(data.weight)
|
||||
});
|
||||
}
|
||||
};
|
||||
|
|
|
@ -3,13 +3,14 @@ import NotFoundPage from "@saleor/components/NotFoundPage";
|
|||
import { WindowTitle } from "@saleor/components/WindowTitle";
|
||||
import useNavigator from "@saleor/hooks/useNavigator";
|
||||
import useNotifier from "@saleor/hooks/useNotifier";
|
||||
import useShop from "@saleor/hooks/useShop";
|
||||
import { commonMessages } from "@saleor/intl";
|
||||
import createDialogActionHandlers from "@saleor/utils/handlers/dialogActionHandlers";
|
||||
import { useWarehouseList } from "@saleor/warehouses/queries";
|
||||
import React, { useEffect, useState } from "react";
|
||||
import { useIntl } from "react-intl";
|
||||
|
||||
import { decimal } from "../../misc";
|
||||
import { decimal, weight } from "../../misc";
|
||||
import ProductVariantDeleteDialog from "../components/ProductVariantDeleteDialog";
|
||||
import ProductVariantPage, {
|
||||
ProductVariantPageSubmitData
|
||||
|
@ -40,6 +41,7 @@ export const ProductVariant: React.FC<ProductUpdateProps> = ({
|
|||
productId,
|
||||
params
|
||||
}) => {
|
||||
const shop = useShop();
|
||||
const navigate = useNavigator();
|
||||
const notify = useNotifier();
|
||||
const intl = useIntl();
|
||||
|
@ -133,6 +135,7 @@ export const ProductVariant: React.FC<ProductUpdateProps> = ({
|
|||
<>
|
||||
<WindowTitle title={data?.productVariant?.name} />
|
||||
<ProductVariantPage
|
||||
defaultWeightUnit={shop?.defaultWeightUnit}
|
||||
errors={errors}
|
||||
saveButtonBarState={updateVariant.opts.status}
|
||||
loading={disableFormSave}
|
||||
|
@ -165,7 +168,8 @@ export const ProductVariant: React.FC<ProductUpdateProps> = ({
|
|||
stocks: data.updateStocks.map(
|
||||
mapFormsetStockToStockInput
|
||||
),
|
||||
trackInventory: data.trackInventory
|
||||
trackInventory: data.trackInventory,
|
||||
weight: weight(data.weight)
|
||||
})
|
||||
}
|
||||
onVariantClick={variantId => {
|
||||
|
|
|
@ -8,7 +8,7 @@ import { useWarehouseList } from "@saleor/warehouses/queries";
|
|||
import React from "react";
|
||||
import { useIntl } from "react-intl";
|
||||
|
||||
import { decimal } from "../../misc";
|
||||
import { decimal, weight } from "../../misc";
|
||||
import ProductVariantCreatePage, {
|
||||
ProductVariantCreatePageSubmitData
|
||||
} from "../components/ProductVariantCreatePage";
|
||||
|
@ -83,7 +83,8 @@ export const ProductVariant: React.FC<ProductVariantCreateProps> = ({
|
|||
quantity: parseInt(stock.value, 0),
|
||||
warehouse: stock.id
|
||||
})),
|
||||
trackInventory: true
|
||||
trackInventory: true,
|
||||
weight: weight(formData.weight)
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -121,6 +122,7 @@ export const ProductVariant: React.FC<ProductVariantCreateProps> = ({
|
|||
edge => edge.node
|
||||
) || []
|
||||
}
|
||||
weightUnit={shop?.defaultWeightUnit}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
|
|
|
@ -1,10 +1,15 @@
|
|||
import { CreateShippingRateVariables } from "@saleor/shipping/types/CreateShippingRate";
|
||||
import { ShippingZone_shippingZone_shippingMethods } from "@saleor/shipping/types/ShippingZone";
|
||||
import { UpdateShippingRateVariables } from "@saleor/shipping/types/UpdateShippingRate";
|
||||
import { ShippingZoneUrlQueryParams } from "@saleor/shipping/urls";
|
||||
import { ShippingMethodTypeEnum } from "@saleor/types/globalTypes";
|
||||
|
||||
import { FormData as ShippingZoneRateDialogFormData } from "../../components/ShippingZoneRateDialog";
|
||||
|
||||
function getValue(value: string, hasLimits: boolean): number | null {
|
||||
return hasLimits ? null : parseFloat(value);
|
||||
}
|
||||
|
||||
export function getCreateShippingRateVariables(
|
||||
data: ShippingZoneRateDialogFormData,
|
||||
params: ShippingZoneUrlQueryParams,
|
||||
|
@ -14,28 +19,20 @@ export function getCreateShippingRateVariables(
|
|||
input: {
|
||||
maximumOrderPrice:
|
||||
params.type === ShippingMethodTypeEnum.PRICE
|
||||
? data.noLimits
|
||||
? null
|
||||
: parseFloat(data.maxValue)
|
||||
? getValue(data.maxValue, data.noLimits)
|
||||
: null,
|
||||
maximumOrderWeight:
|
||||
params.type === ShippingMethodTypeEnum.WEIGHT
|
||||
? data.noLimits
|
||||
? null
|
||||
: parseFloat(data.maxValue)
|
||||
? getValue(data.maxValue, data.noLimits)
|
||||
: null,
|
||||
|
||||
minimumOrderPrice:
|
||||
params.type === ShippingMethodTypeEnum.PRICE
|
||||
? data.noLimits
|
||||
? null
|
||||
: parseFloat(data.minValue)
|
||||
? getValue(data.maxValue, data.noLimits)
|
||||
: null,
|
||||
minimumOrderWeight:
|
||||
params.type === ShippingMethodTypeEnum.WEIGHT
|
||||
? data.noLimits
|
||||
? null
|
||||
: parseFloat(data.minValue)
|
||||
? getValue(data.minValue, data.noLimits)
|
||||
: null,
|
||||
name: data.name,
|
||||
price: data.isFree ? 0 : parseFloat(data.price),
|
||||
|
@ -47,25 +44,36 @@ export function getCreateShippingRateVariables(
|
|||
|
||||
export function getUpdateShippingRateVariables(
|
||||
data: ShippingZoneRateDialogFormData,
|
||||
params: ShippingZoneUrlQueryParams,
|
||||
id: string
|
||||
shippingRate: ShippingZone_shippingZone_shippingMethods,
|
||||
shippingZoneId: string
|
||||
): UpdateShippingRateVariables {
|
||||
const isPriceType = data.type === ShippingMethodTypeEnum.PRICE;
|
||||
const parsedMinValue = parseFloat(data.minValue);
|
||||
const parsedMaxValue = parseFloat(data.maxValue);
|
||||
const isPriceSet = !data.noLimits && isPriceType;
|
||||
const isWeightSet = !data.noLimits && !isPriceType;
|
||||
return {
|
||||
id: params.id,
|
||||
const base: UpdateShippingRateVariables = {
|
||||
id: shippingRate.id,
|
||||
input: {
|
||||
maximumOrderPrice: isPriceSet ? parsedMaxValue : null,
|
||||
maximumOrderWeight: isWeightSet ? parsedMaxValue : null,
|
||||
minimumOrderPrice: isPriceSet ? parsedMinValue : null,
|
||||
minimumOrderWeight: isWeightSet ? parsedMinValue : null,
|
||||
name: data.name,
|
||||
price: data.isFree ? 0 : parseFloat(data.price),
|
||||
shippingZone: id,
|
||||
type: data.type
|
||||
shippingZone: shippingZoneId,
|
||||
type: shippingRate.type
|
||||
}
|
||||
};
|
||||
|
||||
if (shippingRate.type === ShippingMethodTypeEnum.PRICE) {
|
||||
return {
|
||||
...base,
|
||||
input: {
|
||||
...base.input,
|
||||
maximumOrderPrice: getValue(data.maxValue, data.noLimits),
|
||||
minimumOrderPrice: getValue(data.minValue, data.noLimits)
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
...base,
|
||||
input: {
|
||||
...base.input,
|
||||
maximumOrderWeight: getValue(data.maxValue, data.noLimits),
|
||||
minimumOrderWeight: getValue(data.minValue, data.noLimits)
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -227,9 +227,15 @@ const ShippingZoneDetails: React.FC<ShippingZoneDetailsProps> = ({
|
|||
disabled={updateShippingRateOpts.loading}
|
||||
errors={updateShippingRateOpts.data?.shippingPriceUpdate.errors || []}
|
||||
onClose={closeModal}
|
||||
onSubmit={data =>
|
||||
onSubmit={submitData =>
|
||||
updateShippingRate({
|
||||
variables: getUpdateShippingRateVariables(data, params, id)
|
||||
variables: getUpdateShippingRateVariables(
|
||||
submitData,
|
||||
data?.shippingZone?.shippingMethods.find(
|
||||
shippingMethod => shippingMethod.id === params.id
|
||||
),
|
||||
id
|
||||
)
|
||||
})
|
||||
}
|
||||
open={params.action === "edit-rate"}
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -34,6 +34,7 @@ storiesOf("Views / Products / Create product", module)
|
|||
onSubmit={() => undefined}
|
||||
saveButtonBarState="default"
|
||||
warehouses={warehouseList}
|
||||
weightUnit="kg"
|
||||
/>
|
||||
))
|
||||
.add("When loading", () => (
|
||||
|
@ -55,6 +56,7 @@ storiesOf("Views / Products / Create product", module)
|
|||
onSubmit={() => undefined}
|
||||
saveButtonBarState="default"
|
||||
warehouses={undefined}
|
||||
weightUnit="kg"
|
||||
/>
|
||||
))
|
||||
.add("form errors", () => (
|
||||
|
@ -82,5 +84,6 @@ storiesOf("Views / Products / Create product", module)
|
|||
onSubmit={() => undefined}
|
||||
saveButtonBarState="default"
|
||||
warehouses={warehouseList}
|
||||
weightUnit="kg"
|
||||
/>
|
||||
));
|
||||
|
|
|
@ -19,6 +19,7 @@ const props: ProductUpdatePageProps = {
|
|||
...listActionsProps,
|
||||
categories: [product.category],
|
||||
collections,
|
||||
defaultWeightUnit: "kg",
|
||||
disabled: false,
|
||||
errors: [],
|
||||
fetchCategories: () => undefined,
|
||||
|
|
|
@ -15,6 +15,7 @@ storiesOf("Views / Products / Create product variant", module)
|
|||
.add("default", () => (
|
||||
<ProductVariantCreatePage
|
||||
currencySymbol="USD"
|
||||
weightUnit="kg"
|
||||
disabled={false}
|
||||
errors={[]}
|
||||
header="Add variant"
|
||||
|
@ -29,6 +30,7 @@ storiesOf("Views / Products / Create product variant", module)
|
|||
.add("with errors", () => (
|
||||
<ProductVariantCreatePage
|
||||
currencySymbol="USD"
|
||||
weightUnit="kg"
|
||||
disabled={false}
|
||||
errors={[
|
||||
{
|
||||
|
@ -59,6 +61,7 @@ storiesOf("Views / Products / Create product variant", module)
|
|||
.add("when loading data", () => (
|
||||
<ProductVariantCreatePage
|
||||
currencySymbol="USD"
|
||||
weightUnit="kg"
|
||||
disabled={true}
|
||||
errors={[]}
|
||||
header="Add variant"
|
||||
|
@ -73,6 +76,7 @@ storiesOf("Views / Products / Create product variant", module)
|
|||
.add("add first variant", () => (
|
||||
<ProductVariantCreatePage
|
||||
currencySymbol="USD"
|
||||
weightUnit="kg"
|
||||
disabled={false}
|
||||
errors={[]}
|
||||
header="Add variant"
|
||||
|
|
|
@ -14,6 +14,7 @@ storiesOf("Views / Products / Product variant details", module)
|
|||
.addDecorator(Decorator)
|
||||
.add("when loaded data", () => (
|
||||
<ProductVariantPage
|
||||
defaultWeightUnit="kg"
|
||||
header={variant.name || variant.sku}
|
||||
errors={[]}
|
||||
variant={variant}
|
||||
|
@ -29,6 +30,7 @@ storiesOf("Views / Products / Product variant details", module)
|
|||
))
|
||||
.add("when loading data", () => (
|
||||
<ProductVariantPage
|
||||
defaultWeightUnit="kg"
|
||||
header={undefined}
|
||||
errors={[]}
|
||||
loading={true}
|
||||
|
@ -45,6 +47,7 @@ storiesOf("Views / Products / Product variant details", module)
|
|||
))
|
||||
.add("attribute errors", () => (
|
||||
<ProductVariantPage
|
||||
defaultWeightUnit="kg"
|
||||
header={variant.name || variant.sku}
|
||||
variant={variant}
|
||||
onAdd={() => undefined}
|
||||
|
|
|
@ -14,15 +14,26 @@ const messages = defineMessages({
|
|||
attributeCannotBeAssigned: {
|
||||
defaultMessage: "This attribute cannot be assigned to this product type"
|
||||
},
|
||||
attributeRequired: {
|
||||
defaultMessage: "All attributes should have value",
|
||||
description: "product attribute error"
|
||||
},
|
||||
attributeVariantsDisabled: {
|
||||
defaultMessage: "Variants are disabled in this product type"
|
||||
},
|
||||
duplicatedInputItem: {
|
||||
defaultMessage: "Variant with these attributes already exists"
|
||||
},
|
||||
skuUnique: {
|
||||
defaultMessage: "SKUs must be unique",
|
||||
description: "bulk variant create error"
|
||||
},
|
||||
variantNoDigitalContent: {
|
||||
defaultMessage: "This variant does not have any digital content"
|
||||
},
|
||||
variantUnique: {
|
||||
defaultMessage: "This variant already exists",
|
||||
description: "product attribute error"
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -38,6 +49,8 @@ function getProductErrorMessage(
|
|||
return intl.formatMessage(messages.attributeCannotBeAssigned);
|
||||
case ProductErrorCode.ATTRIBUTE_VARIANTS_DISABLED:
|
||||
return intl.formatMessage(messages.attributeVariantsDisabled);
|
||||
case ProductErrorCode.DUPLICATED_INPUT_ITEM:
|
||||
return intl.formatMessage(messages.duplicatedInputItem);
|
||||
case ProductErrorCode.GRAPHQL_ERROR:
|
||||
return intl.formatMessage(commonErrorMessages.graphqlError);
|
||||
case ProductErrorCode.REQUIRED:
|
||||
|
@ -54,6 +67,24 @@ function getProductErrorMessage(
|
|||
return undefined;
|
||||
}
|
||||
|
||||
export function getProductVariantAttributeErrorMessage(
|
||||
err: Omit<ProductErrorFragment, "__typename"> | undefined,
|
||||
intl: IntlShape
|
||||
): string {
|
||||
if (err) {
|
||||
switch (err.code) {
|
||||
case ProductErrorCode.REQUIRED:
|
||||
return intl.formatMessage(messages.attributeRequired);
|
||||
case ProductErrorCode.UNIQUE:
|
||||
return intl.formatMessage(messages.variantUnique);
|
||||
default:
|
||||
return getProductErrorMessage(err, intl);
|
||||
}
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
export function getBulkProductErrorMessage(
|
||||
err: BulkProductErrorFragment | undefined,
|
||||
intl: IntlShape
|
||||
|
|
|
@ -51,7 +51,9 @@ const WarehouseDetailsPage: React.FC<WarehouseDetailsPageProps> = ({
|
|||
onSubmit
|
||||
}) => {
|
||||
const intl = useIntl();
|
||||
const [displayCountry, setDisplayCountry] = useStateFromProps("");
|
||||
const [displayCountry, setDisplayCountry] = useStateFromProps(
|
||||
warehouse?.address?.country.country || ""
|
||||
);
|
||||
|
||||
const {
|
||||
errors: validationErrors,
|
||||
|
|
Loading…
Reference in a new issue