From c0426d502412e879ed443afa1d88a4342c1ef154 Mon Sep 17 00:00:00 2001
From: Tomasz Szymanski
Date: Mon, 21 Dec 2020 14:03:22 +0100
Subject: [PATCH 01/10] Show hidden radio buttons of shipping method zip codes
---
.../components/ShippingZoneZipCodes/ShippingZoneZipCodes.tsx | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/src/shipping/components/ShippingZoneZipCodes/ShippingZoneZipCodes.tsx b/src/shipping/components/ShippingZoneZipCodes/ShippingZoneZipCodes.tsx
index b14fb03f4..b36b03f32 100644
--- a/src/shipping/components/ShippingZoneZipCodes/ShippingZoneZipCodes.tsx
+++ b/src/shipping/components/ShippingZoneZipCodes/ShippingZoneZipCodes.tsx
@@ -48,9 +48,6 @@ const useStyles = makeStyles(
width: 80
},
colCode: {},
- hide: {
- display: "none"
- },
option: {
marginBottom: theme.spacing(2),
width: 400
@@ -100,7 +97,7 @@ const ShippingZoneZipCodes: React.FC = ({
}
/>
-
+
Date: Tue, 22 Dec 2020 12:22:23 +0100
Subject: [PATCH 02/10] Update snapshots
---
src/storybook/__snapshots__/Stories.test.ts.snap | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/src/storybook/__snapshots__/Stories.test.ts.snap b/src/storybook/__snapshots__/Stories.test.ts.snap
index 282d2dbd5..97476a595 100644
--- a/src/storybook/__snapshots__/Stories.test.ts.snap
+++ b/src/storybook/__snapshots__/Stories.test.ts.snap
@@ -15840,7 +15840,7 @@ exports[`Storyshots Shipping / ShippingZoneRatesCreatePage page create price 1`]
class="CardTitle-hr-id"
/>
Date: Wed, 30 Dec 2020 11:06:26 +0100
Subject: [PATCH 03/10] Deploy to staging after merge to master
---
.github/workflows/deploy-staging.yaml | 42 +++++++++++++++++++++++++++
1 file changed, 42 insertions(+)
create mode 100644 .github/workflows/deploy-staging.yaml
diff --git a/.github/workflows/deploy-staging.yaml b/.github/workflows/deploy-staging.yaml
new file mode 100644
index 000000000..20b90e74c
--- /dev/null
+++ b/.github/workflows/deploy-staging.yaml
@@ -0,0 +1,42 @@
+name: Deploy to staging
+on:
+ push:
+ branches:
+ - master
+jobs:
+ build:
+ runs-on: ubuntu-20.04
+ env:
+ API_URI: https://master.staging.saleor.cloud/graphql
+ APP_MOUNT_URI: /dashboard/
+ STATIC_URL: /dashboard/static/
+ steps:
+ - uses: actions/checkout@v2
+ - name: Package
+ run: |
+ npm ci
+ npm run build
+ - uses: actions/upload-artifact@v2
+ with:
+ name: build
+ path: build
+ deploy:
+ needs:
+ - build
+ runs-on: ubuntu-20.04
+ steps:
+ - uses: actions/download-artifact@v2
+ with:
+ name: build
+ path: build
+ - name: Configure AWS Credentials
+ uses: aws-actions/configure-aws-credentials@v1
+ with:
+ aws-access-key-id: ${{ secrets.AWS_STAGING_ACCESS_KEY_ID }}
+ aws-secret-access-key: ${{ secrets.AWS_STAGING_SECRET_ACCESS_KEY }}
+ aws-region: us-east-1
+ - name: Deploy
+ run: |
+ aws s3 sync build/dashboard s3://${{ secrets.AWS_STAGING_DEPLOYMENT_BUCKET }}/saleor-master-staging/static/
+ aws s3 cp build/dashboard/index.html s3://${{ secrets.AWS_STAGING_DEPLOYMENT_BUCKET }}/saleor-master-staging/
+ aws cloudfront create-invalidation --distribution-id ${{ secrets.AWS_STAGING_CF_DIST_ID }} --paths "/dashboard*"
\ No newline at end of file
From 5af85e5157ce78132e0fec8d42840e860bd81aa1 Mon Sep 17 00:00:00 2001
From: Tomasz Szymanski
Date: Wed, 30 Dec 2020 13:25:40 +0100
Subject: [PATCH 04/10] Shipping zone description
---
locale/defaultMessages.json | 7 +
schema.graphql | 2 +
src/fragments/shipping.ts | 1 +
.../types/ShippingZoneDetailsFragment.ts | 1 +
src/fragments/types/ShippingZoneFragment.ts | 1 +
.../ShippingZoneDetailsPage.tsx | 58 +++++++
.../ShippingZoneRates/ShippingZoneRates.tsx | 8 +-
src/shipping/fixtures.ts | 9 +-
src/shipping/types/CreateShippingRate.ts | 1 +
src/shipping/types/DeleteShippingRate.ts | 1 +
src/shipping/types/ShippingZone.ts | 1 +
src/shipping/types/ShippingZones.ts | 1 +
.../views/ShippingZoneDetails/index.tsx | 1 +
.../__snapshots__/Stories.test.ts.snap | 143 ++++++++++++++++++
src/types/globalTypes.ts | 1 +
15 files changed, 229 insertions(+), 7 deletions(-)
diff --git a/locale/defaultMessages.json b/locale/defaultMessages.json
index 2f7279e23..cb2c58d30 100644
--- a/locale/defaultMessages.json
+++ b/locale/defaultMessages.json
@@ -5452,6 +5452,13 @@
"src_dot_shipping_dot_components_dot_ShippingZoneDetailsPage_dot_3109712047": {
"string": "Countries"
},
+ "src_dot_shipping_dot_components_dot_ShippingZoneDetailsPage_dot_3374163063": {
+ "string": "Description"
+ },
+ "src_dot_shipping_dot_components_dot_ShippingZoneDetailsPage_dot_3877274856": {
+ "context": "character limit",
+ "string": "{numberOfCharacters} of {maxCharacters} characters"
+ },
"src_dot_shipping_dot_components_dot_ShippingZoneDetailsPage_dot_4270729636": {
"string": "This is default shipping zone, which means that it covers all of the countries which are not assigned to other shipping zones"
},
diff --git a/schema.graphql b/schema.graphql
index aa914316b..8e6b828a1 100644
--- a/schema.graphql
+++ b/schema.graphql
@@ -4782,6 +4782,7 @@ type ShippingZone implements Node & ObjectWithMetadata {
countries: [CountryDisplay]
shippingMethods: [ShippingMethod]
warehouses: [Warehouse]
+ description: String
}
type ShippingZoneBulkDelete {
@@ -4830,6 +4831,7 @@ input ShippingZoneUpdateInput {
name: String
countries: [String]
default: Boolean
+ description: String
addWarehouses: [ID]
removeWarehouses: [ID]
}
diff --git a/src/fragments/shipping.ts b/src/fragments/shipping.ts
index 25a89d06c..bf19fe7d9 100644
--- a/src/fragments/shipping.ts
+++ b/src/fragments/shipping.ts
@@ -13,6 +13,7 @@ export const shippingZoneFragment = gql`
country
}
name
+ description
}
`;
diff --git a/src/fragments/types/ShippingZoneDetailsFragment.ts b/src/fragments/types/ShippingZoneDetailsFragment.ts
index da530e989..961b71048 100644
--- a/src/fragments/types/ShippingZoneDetailsFragment.ts
+++ b/src/fragments/types/ShippingZoneDetailsFragment.ts
@@ -117,6 +117,7 @@ export interface ShippingZoneDetailsFragment {
id: string;
countries: (ShippingZoneDetailsFragment_countries | null)[] | null;
name: string;
+ description: string | null;
default: boolean;
shippingMethods: (ShippingZoneDetailsFragment_shippingMethods | null)[] | null;
warehouses: (ShippingZoneDetailsFragment_warehouses | null)[] | null;
diff --git a/src/fragments/types/ShippingZoneFragment.ts b/src/fragments/types/ShippingZoneFragment.ts
index ddbf30da6..2aa596c72 100644
--- a/src/fragments/types/ShippingZoneFragment.ts
+++ b/src/fragments/types/ShippingZoneFragment.ts
@@ -31,4 +31,5 @@ export interface ShippingZoneFragment {
id: string;
countries: (ShippingZoneFragment_countries | null)[] | null;
name: string;
+ description: string | null;
}
diff --git a/src/shipping/components/ShippingZoneDetailsPage/ShippingZoneDetailsPage.tsx b/src/shipping/components/ShippingZoneDetailsPage/ShippingZoneDetailsPage.tsx
index 204ee2bdb..8c6cfd482 100644
--- a/src/shipping/components/ShippingZoneDetailsPage/ShippingZoneDetailsPage.tsx
+++ b/src/shipping/components/ShippingZoneDetailsPage/ShippingZoneDetailsPage.tsx
@@ -1,3 +1,5 @@
+import makeStyles from "@material-ui/core/styles/makeStyles";
+import TextField from "@material-ui/core/TextField";
import AppHeader from "@saleor/components/AppHeader";
import CardSpacer from "@saleor/components/CardSpacer";
import { ConfirmButtonTransitionState } from "@saleor/components/ConfirmButton";
@@ -33,9 +35,27 @@ import ShippingZoneWarehouses from "../ShippingZoneWarehouses";
export interface FormData extends MetadataFormData {
name: string;
+ description: string;
warehouses: string[];
}
+const maxDescriptionLength = 300;
+
+const useStyles = makeStyles(
+ {
+ label: {
+ flex: 1
+ },
+ labelContainer: {
+ "& span": {
+ paddingRight: 30
+ },
+ display: "flex"
+ }
+ },
+ { name: "ShippingZoneDetailsPage" }
+);
+
export interface ShippingZoneDetailsPageProps
extends FetchMoreProps,
SearchProps,
@@ -91,8 +111,10 @@ const ShippingZoneDetailsPage: React.FC = ({
warehouses
}) => {
const intl = useIntl();
+ const classes = useStyles({});
const initialForm: FormData = {
+ description: shippingZone?.description || "",
metadata: shippingZone?.metadata.map(mapMetadataItemToInput),
name: shippingZone?.name || "",
privateMetadata: shippingZone?.privateMetadata.map(mapMetadataItemToInput),
@@ -124,6 +146,7 @@ const ShippingZoneDetailsPage: React.FC = ({
);
const changeMetadata = makeMetadataChangeHandler(change);
+ const description = data.description;
return (
@@ -202,6 +225,41 @@ const ShippingZoneDetailsPage: React.FC = ({
warehouses={warehouseChoices}
/>
+
maxDescriptionLength}
+ name={"description"}
+ label={
+
+
+
+
+ {description?.length > 0 && (
+
+
+
+ )}
+
+ }
+ InputProps={{
+ inputProps: {
+ maxLength: maxDescriptionLength
+ }
+ }}
+ value={description}
+ onChange={change}
+ disabled={loading || disabled}
+ fullWidth
+ multiline
+ placeholder={"placeholder"}
+ rows={10}
+ />
= ({
id,
input: {
addWarehouses: warehouseDiff.added,
+ description: submitData.description,
name: submitData.name,
removeWarehouses: warehouseDiff.removed
}
diff --git a/src/storybook/__snapshots__/Stories.test.ts.snap b/src/storybook/__snapshots__/Stories.test.ts.snap
index 7f790fbf8..e1e89a6cd 100644
--- a/src/storybook/__snapshots__/Stories.test.ts.snap
+++ b/src/storybook/__snapshots__/Stories.test.ts.snap
@@ -209429,6 +209429,55 @@ exports[`Storyshots Views / Shipping / Shipping zone details default 1`] = `
+
+
+
+
+
+
+
@@ -210346,6 +210395,55 @@ exports[`Storyshots Views / Shipping / Shipping zone details form errors 1`] = `
+
+
+
+
+
+
+
@@ -211040,6 +211138,51 @@ exports[`Storyshots Views / Shipping / Shipping zone details loading 1`] = `
+
+
+
+
+
+
+
diff --git a/src/types/globalTypes.ts b/src/types/globalTypes.ts
index fbbd6b2bd..ac1657c4d 100644
--- a/src/types/globalTypes.ts
+++ b/src/types/globalTypes.ts
@@ -1719,6 +1719,7 @@ export interface ShippingZoneUpdateInput {
name?: string | null;
countries?: (string | null)[] | null;
default?: boolean | null;
+ description?: string | null;
addWarehouses?: (string | null)[] | null;
removeWarehouses?: (string | null)[] | null;
}
From 331ab84440c759a9077286414696ccf53c912564 Mon Sep 17 00:00:00 2001
From: Tomasz Szymanski
Date: Wed, 30 Dec 2020 13:41:37 +0100
Subject: [PATCH 05/10] Unmock placeholder
---
locale/defaultMessages.json | 3 +++
.../ShippingZoneDetailsPage/ShippingZoneDetailsPage.tsx | 4 +++-
src/storybook/__snapshots__/Stories.test.ts.snap | 6 +++---
3 files changed, 9 insertions(+), 4 deletions(-)
diff --git a/locale/defaultMessages.json b/locale/defaultMessages.json
index cb2c58d30..c885269b2 100644
--- a/locale/defaultMessages.json
+++ b/locale/defaultMessages.json
@@ -5446,6 +5446,9 @@
"src_dot_shipping_dot_components_dot_ShippingZoneDetailsPage_dot_1325966144": {
"string": "Shipping"
},
+ "src_dot_shipping_dot_components_dot_ShippingZoneDetailsPage_dot_1470703814": {
+ "string": "Description of a shipping zone."
+ },
"src_dot_shipping_dot_components_dot_ShippingZoneDetailsPage_dot_2364051773": {
"string": "Currently, there are no countries assigned to this shipping zone"
},
diff --git a/src/shipping/components/ShippingZoneDetailsPage/ShippingZoneDetailsPage.tsx b/src/shipping/components/ShippingZoneDetailsPage/ShippingZoneDetailsPage.tsx
index 8c6cfd482..6e8b681ac 100644
--- a/src/shipping/components/ShippingZoneDetailsPage/ShippingZoneDetailsPage.tsx
+++ b/src/shipping/components/ShippingZoneDetailsPage/ShippingZoneDetailsPage.tsx
@@ -257,7 +257,9 @@ const ShippingZoneDetailsPage: React.FC = ({
disabled={loading || disabled}
fullWidth
multiline
- placeholder={"placeholder"}
+ placeholder={intl.formatMessage({
+ defaultMessage: "Description of a shipping zone."
+ })}
rows={10}
/>
diff --git a/src/storybook/__snapshots__/Stories.test.ts.snap b/src/storybook/__snapshots__/Stories.test.ts.snap
index e1e89a6cd..84c23d269 100644
--- a/src/storybook/__snapshots__/Stories.test.ts.snap
+++ b/src/storybook/__snapshots__/Stories.test.ts.snap
@@ -209457,7 +209457,7 @@ exports[`Storyshots Views / Shipping / Shipping zone details default 1`] = `
class="MuiInputBase-input-id MuiOutlinedInput-input-id MuiInputBase-inputMultiline-id MuiOutlinedInput-inputMultiline-id"
maxlength="300"
name="description"
- placeholder="placeholder"
+ placeholder="Description of a shipping zone."
rows="10"
>
Shipping zone description
@@ -210423,7 +210423,7 @@ exports[`Storyshots Views / Shipping / Shipping zone details form errors 1`] = `
class="MuiInputBase-input-id MuiOutlinedInput-input-id MuiInputBase-inputMultiline-id MuiOutlinedInput-inputMultiline-id"
maxlength="300"
name="description"
- placeholder="placeholder"
+ placeholder="Description of a shipping zone."
rows="10"
>
Shipping zone description
@@ -211164,7 +211164,7 @@ exports[`Storyshots Views / Shipping / Shipping zone details loading 1`] = `
disabled=""
maxlength="300"
name="description"
- placeholder="placeholder"
+ placeholder="Description of a shipping zone."
rows="10"
/>
+
@@ -59814,6 +59736,9 @@ exports[`Storyshots Views / Customers / Customer details different addresses 1`]
>
Elizabeth Vaughn
+
@@ -59851,6 +59776,9 @@ exports[`Storyshots Views / Customers / Customer details different addresses 1`]
>
Elizabeth Vaughn
+
@@ -60545,6 +60473,9 @@ exports[`Storyshots Views / Customers / Customer details form errors 1`] = `
>
Elizabeth Vaughn
+
@@ -61840,6 +61771,9 @@ exports[`Storyshots Views / Customers / Customer details never logged 1`] = `
>
Elizabeth Vaughn
+
@@ -62513,6 +62447,9 @@ exports[`Storyshots Views / Customers / Customer details never placed order 1`]
>
Elizabeth Vaughn
+
@@ -63840,6 +63777,9 @@ exports[`Storyshots Views / Customers / Customer details no default billing addr
>
Elizabeth Vaughn
+
@@ -64519,6 +64459,9 @@ exports[`Storyshots Views / Customers / Customer details no default shipping add
>
Elizabeth Vaughn
+
From e48c025bec55cbdbdef7bce3e478222d3460a3ab Mon Sep 17 00:00:00 2001
From: Tomasz Szymanski
Date: Thu, 7 Jan 2021 11:52:12 +0100
Subject: [PATCH 10/10] ShippingRateInfo component, separate ShippingZoneInfo,
cleanups
---
locale/defaultMessages.json | 58 +-
.../ShippingRateInfo/ShippingRateInfo.tsx | 52 ++
.../components/ShippingRateInfo/index.ts | 2 +
.../ShippingZoneCreatePage.tsx | 80 +--
.../ShippingZoneDetailsPage.tsx | 74 +--
.../ShippingZoneInfo/ShippingZoneInfo.tsx | 65 +-
.../ShippingZoneRatesCreatePage.tsx | 4 +-
.../ShippingZoneRatesPage.tsx | 4 +-
.../__snapshots__/Stories.test.ts.snap | 561 +++++++++---------
9 files changed, 434 insertions(+), 466 deletions(-)
create mode 100644 src/shipping/components/ShippingRateInfo/ShippingRateInfo.tsx
create mode 100644 src/shipping/components/ShippingRateInfo/index.ts
diff --git a/locale/defaultMessages.json b/locale/defaultMessages.json
index cbcb95ceb..a04d47c49 100644
--- a/locale/defaultMessages.json
+++ b/locale/defaultMessages.json
@@ -5380,6 +5380,9 @@
"src_dot_shipping_dot_components_dot_ShippingMethodProducts_dot_4190792473": {
"string": "Actions"
},
+ "src_dot_shipping_dot_components_dot_ShippingRateInfo_dot_579967655": {
+ "string": "Shipping rate name"
+ },
"src_dot_shipping_dot_components_dot_ShippingRateZipCodeRangeRemoveDialog_dot_1083561409": {
"string": "Are you sure you want to remove this ZIP-code rule?"
},
@@ -5430,68 +5433,47 @@
"src_dot_shipping_dot_components_dot_ShippingZoneCountriesAssignDialog_dot_3510295703": {
"string": "Search Countries"
},
- "src_dot_shipping_dot_components_dot_ShippingZoneCreatePage_dot_3877274856": {
- "context": "character limit",
- "string": "{numberOfCharacters} of {maxCharacters} characters"
- },
"src_dot_shipping_dot_components_dot_ShippingZoneCreatePage_dot_countries": {
- "context": "countries",
+ "context": "country list header",
"string": "Countries"
},
"src_dot_shipping_dot_components_dot_ShippingZoneCreatePage_dot_createZone": {
- "context": "header",
+ "context": "section header",
"string": "Create New Shipping Zone"
},
"src_dot_shipping_dot_components_dot_ShippingZoneCreatePage_dot_defaultZone": {
- "context": "default shipping zone",
"string": "This is default shipping zone, which means that it covers all of the countries which are not assigned to other shipping zones"
},
- "src_dot_shipping_dot_components_dot_ShippingZoneCreatePage_dot_description": {
- "context": "description",
- "string": "Description"
- },
- "src_dot_shipping_dot_components_dot_ShippingZoneCreatePage_dot_descriptionMessage": {
- "context": "field placeholder",
- "string": "Description of a shipping zone."
- },
"src_dot_shipping_dot_components_dot_ShippingZoneCreatePage_dot_noCountriesAssigned": {
- "context": "no countries assigned to zone",
"string": "Currently, there are no countries assigned to this shipping zone"
},
- "src_dot_shipping_dot_components_dot_ShippingZoneCreatePage_dot_shipping": {
- "context": "shipping",
- "string": "Shipping"
- },
- "src_dot_shipping_dot_components_dot_ShippingZoneDetailsPage_dot_3877274856": {
- "context": "character limit",
- "string": "{numberOfCharacters} of {maxCharacters} characters"
- },
"src_dot_shipping_dot_components_dot_ShippingZoneDetailsPage_dot_countries": {
- "context": "countries",
+ "context": "country list header",
"string": "Countries"
},
"src_dot_shipping_dot_components_dot_ShippingZoneDetailsPage_dot_defaultZone": {
- "context": "default shipping zone",
"string": "This is default shipping zone, which means that it covers all of the countries which are not assigned to other shipping zones"
},
- "src_dot_shipping_dot_components_dot_ShippingZoneDetailsPage_dot_description": {
- "context": "description",
- "string": "Description"
- },
- "src_dot_shipping_dot_components_dot_ShippingZoneDetailsPage_dot_descriptionMessage": {
- "context": "field placeholder",
- "string": "Description of a shipping zone."
- },
"src_dot_shipping_dot_components_dot_ShippingZoneDetailsPage_dot_noCountriesAssigned": {
- "context": "no countries assigned to zone",
"string": "Currently, there are no countries assigned to this shipping zone"
},
"src_dot_shipping_dot_components_dot_ShippingZoneDetailsPage_dot_shipping": {
- "context": "shipping",
+ "context": "shipping section header",
"string": "Shipping"
},
- "src_dot_shipping_dot_components_dot_ShippingZoneInfo_dot_579967655": {
- "string": "Shipping rate name"
+ "src_dot_shipping_dot_components_dot_ShippingZoneInfo_dot_1470703814": {
+ "context": "field placeholder",
+ "string": "Description of a shipping zone."
+ },
+ "src_dot_shipping_dot_components_dot_ShippingZoneInfo_dot_1560416099": {
+ "string": "Shipping zone name"
+ },
+ "src_dot_shipping_dot_components_dot_ShippingZoneInfo_dot_3374163063": {
+ "string": "Description"
+ },
+ "src_dot_shipping_dot_components_dot_ShippingZoneInfo_dot_3877274856": {
+ "context": "character limit",
+ "string": "{numberOfCharacters} of {maxCharacters} characters"
},
"src_dot_shipping_dot_components_dot_ShippingZoneRatesCreatePage_dot_1161979494": {
"context": "page title",
diff --git a/src/shipping/components/ShippingRateInfo/ShippingRateInfo.tsx b/src/shipping/components/ShippingRateInfo/ShippingRateInfo.tsx
new file mode 100644
index 000000000..b66937bee
--- /dev/null
+++ b/src/shipping/components/ShippingRateInfo/ShippingRateInfo.tsx
@@ -0,0 +1,52 @@
+import Card from "@material-ui/core/Card";
+import CardContent from "@material-ui/core/CardContent";
+import TextField from "@material-ui/core/TextField";
+import CardTitle from "@saleor/components/CardTitle";
+import { ShippingErrorFragment } from "@saleor/fragments/types/ShippingErrorFragment";
+import { commonMessages } from "@saleor/intl";
+import { getFormErrors } from "@saleor/utils/errors";
+import getShippingErrorMessage from "@saleor/utils/errors/shipping";
+import React from "react";
+import { useIntl } from "react-intl";
+
+export interface ShippingRateInfoProps {
+ data: Record<"name", string>;
+ disabled: boolean;
+ errors: ShippingErrorFragment[];
+ onChange: (event: React.ChangeEvent) => void;
+}
+
+const ShippingRateInfo: React.FC = ({
+ data,
+ disabled,
+ errors,
+ onChange
+}) => {
+ const intl = useIntl();
+
+ const formErrors = getFormErrors(["name"], errors);
+
+ return (
+
+
+
+
+
+
+ );
+};
+ShippingRateInfo.displayName = "ShippingRateInfo";
+export default ShippingRateInfo;
diff --git a/src/shipping/components/ShippingRateInfo/index.ts b/src/shipping/components/ShippingRateInfo/index.ts
new file mode 100644
index 000000000..8002507b2
--- /dev/null
+++ b/src/shipping/components/ShippingRateInfo/index.ts
@@ -0,0 +1,2 @@
+export { default } from "./ShippingRateInfo";
+export * from "./ShippingRateInfo";
diff --git a/src/shipping/components/ShippingZoneCreatePage/ShippingZoneCreatePage.tsx b/src/shipping/components/ShippingZoneCreatePage/ShippingZoneCreatePage.tsx
index 30e968e02..c221a5c1c 100644
--- a/src/shipping/components/ShippingZoneCreatePage/ShippingZoneCreatePage.tsx
+++ b/src/shipping/components/ShippingZoneCreatePage/ShippingZoneCreatePage.tsx
@@ -1,5 +1,3 @@
-import makeStyles from "@material-ui/core/styles/makeStyles";
-import TextField from "@material-ui/core/TextField";
import AppHeader from "@saleor/components/AppHeader";
import CardSpacer from "@saleor/components/CardSpacer";
import { ConfirmButtonTransitionState } from "@saleor/components/ConfirmButton";
@@ -13,7 +11,7 @@ import { CountryFragment } from "@saleor/fragments/types/CountryFragment";
import { ShippingErrorFragment } from "@saleor/fragments/types/ShippingErrorFragment";
import { sectionNames } from "@saleor/intl";
import React from "react";
-import { defineMessages, FormattedMessage, useIntl } from "react-intl";
+import { defineMessages, useIntl } from "react-intl";
import ShippingZoneCountriesAssignDialog from "../ShippingZoneCountriesAssignDialog";
import ShippingZoneInfo from "../ShippingZoneInfo";
@@ -25,53 +23,22 @@ export interface FormData {
name: string;
}
-const MAX_DESCRIPTION_LENGTH = 300;
-
-const useStyles = makeStyles(
- {
- label: {
- flex: 1
- },
- labelContainer: {
- "& span": {
- paddingRight: 30
- },
- display: "flex"
- }
- },
- { name: "ShippingZoneCreatePage" }
-);
-
const messages = defineMessages({
countries: {
defaultMessage: "Countries",
- description: "countries"
+ description: "country list header"
},
createZone: {
defaultMessage: "Create New Shipping Zone",
- description: "header"
+ description: "section header"
},
defaultZone: {
defaultMessage:
- "This is default shipping zone, which means that it covers all of the countries which are not assigned to other shipping zones",
- description: "default shipping zone"
- },
- description: {
- defaultMessage: "Description",
- description: "description"
- },
- descriptionMessage: {
- defaultMessage: "Description of a shipping zone.",
- description: "field placeholder"
+ "This is default shipping zone, which means that it covers all of the countries which are not assigned to other shipping zones"
},
noCountriesAssigned: {
defaultMessage:
- "Currently, there are no countries assigned to this shipping zone",
- description: "no countries assigned to zone"
- },
- shipping: {
- defaultMessage: "Shipping",
- description: "shipping"
+ "Currently, there are no countries assigned to this shipping zone"
}
});
@@ -93,7 +60,6 @@ const ShippingZoneCreatePage: React.FC = ({
saveButtonBarState
}) => {
const intl = useIntl();
- const classes = useStyles({});
const [isModalOpened, setModalStatus] = React.useState(false);
const toggleModal = () => setModalStatus(!isModalOpened);
@@ -122,42 +88,6 @@ const ShippingZoneCreatePage: React.FC = ({
onChange={change}
/>
- MAX_DESCRIPTION_LENGTH}
- name={"description"}
- label={
-
-
-
-
- {data.description?.length > 0 && (
-
-
-
- )}
-
- }
- InputProps={{
- inputProps: {
- maxLength: MAX_DESCRIPTION_LENGTH
- }
- }}
- value={data.description}
- onChange={change}
- disabled={disabled}
- fullWidth
- multiline
- placeholder={intl.formatMessage(messages.descriptionMessage)}
- rows={10}
- />
-
countries.find(country => country.code === selectedCountry)
diff --git a/src/shipping/components/ShippingZoneDetailsPage/ShippingZoneDetailsPage.tsx b/src/shipping/components/ShippingZoneDetailsPage/ShippingZoneDetailsPage.tsx
index 4c8238bf8..0c7a55b0e 100644
--- a/src/shipping/components/ShippingZoneDetailsPage/ShippingZoneDetailsPage.tsx
+++ b/src/shipping/components/ShippingZoneDetailsPage/ShippingZoneDetailsPage.tsx
@@ -1,5 +1,3 @@
-import makeStyles from "@material-ui/core/styles/makeStyles";
-import TextField from "@material-ui/core/TextField";
import AppHeader from "@saleor/components/AppHeader";
import CardSpacer from "@saleor/components/CardSpacer";
import { ConfirmButtonTransitionState } from "@saleor/components/ConfirmButton";
@@ -39,49 +37,22 @@ export interface FormData extends MetadataFormData {
warehouses: string[];
}
-const MAX_DESCRIPTION_LENGTH = 300;
-
-const useStyles = makeStyles(
- {
- label: {
- flex: 1
- },
- labelContainer: {
- "& span": {
- paddingRight: 30
- },
- display: "flex"
- }
- },
- { name: "ShippingZoneDetailsPage" }
-);
-
const messages = defineMessages({
countries: {
defaultMessage: "Countries",
- description: "countries"
+ description: "country list header"
},
defaultZone: {
defaultMessage:
- "This is default shipping zone, which means that it covers all of the countries which are not assigned to other shipping zones",
- description: "default shipping zone"
- },
- description: {
- defaultMessage: "Description",
- description: "description"
- },
- descriptionMessage: {
- defaultMessage: "Description of a shipping zone.",
- description: "field placeholder"
+ "This is default shipping zone, which means that it covers all of the countries which are not assigned to other shipping zones"
},
noCountriesAssigned: {
defaultMessage:
- "Currently, there are no countries assigned to this shipping zone",
- description: "no countries assigned to zone"
+ "Currently, there are no countries assigned to this shipping zone"
},
shipping: {
defaultMessage: "Shipping",
- description: "shipping"
+ description: "shipping section header"
}
});
@@ -140,7 +111,6 @@ const ShippingZoneDetailsPage: React.FC = ({
warehouses
}) => {
const intl = useIntl();
- const classes = useStyles({});
const initialForm: FormData = {
description: shippingZone?.description || "",
@@ -175,7 +145,6 @@ const ShippingZoneDetailsPage: React.FC = ({
);
const changeMetadata = makeMetadataChangeHandler(change);
- const description = data.description;
return (
@@ -246,41 +215,6 @@ const ShippingZoneDetailsPage: React.FC = ({
warehouses={warehouseChoices}
/>
- MAX_DESCRIPTION_LENGTH}
- name={"description"}
- label={
-
-
-
-
- {description?.length > 0 && (
-
-
-
- )}
-
- }
- InputProps={{
- inputProps: {
- maxLength: MAX_DESCRIPTION_LENGTH
- }
- }}
- value={description}
- onChange={change}
- disabled={loading || disabled}
- fullWidth
- multiline
- placeholder={intl.formatMessage(messages.descriptionMessage)}
- rows={10}
- />
;
+ data: Record<"name" | "description", string>;
disabled: boolean;
errors: ShippingErrorFragment[];
onChange: (event: React.ChangeEvent) => void;
}
+const useStyles = makeStyles(
+ {
+ label: {
+ flex: 1
+ },
+ labelContainer: {
+ "& span": {
+ paddingRight: 30
+ },
+ display: "flex"
+ }
+ },
+ { name: "ShippingZoneCreatePage" }
+);
+
+const MAX_DESCRIPTION_LENGTH = 300;
+
const ShippingZoneInfo: React.FC = ({
data,
disabled,
@@ -23,6 +42,7 @@ const ShippingZoneInfo: React.FC = ({
onChange
}) => {
const intl = useIntl();
+ const classes = useStyles({});
const formErrors = getFormErrors(["name"], errors);
@@ -38,12 +58,51 @@ const ShippingZoneInfo: React.FC = ({
fullWidth
helperText={getShippingErrorMessage(formErrors.name, intl)}
label={intl.formatMessage({
- defaultMessage: "Shipping rate name"
+ defaultMessage: "Shipping zone name"
})}
name="name"
value={data.name}
onChange={onChange}
/>
+
+ MAX_DESCRIPTION_LENGTH}
+ name={"description"}
+ label={
+
+
+
+
+ {data.description?.length > 0 && (
+
+
+
+ )}
+
+ }
+ InputProps={{
+ inputProps: {
+ maxLength: MAX_DESCRIPTION_LENGTH
+ }
+ }}
+ value={data.description}
+ onChange={onChange}
+ disabled={disabled}
+ fullWidth
+ multiline
+ placeholder={intl.formatMessage({
+ defaultMessage: "Description of a shipping zone.",
+ description: "field placeholder"
+ })}
+ rows={10}
+ />
);
diff --git a/src/shipping/components/ShippingZoneRatesCreatePage/ShippingZoneRatesCreatePage.tsx b/src/shipping/components/ShippingZoneRatesCreatePage/ShippingZoneRatesCreatePage.tsx
index c390d76e1..952c9c421 100644
--- a/src/shipping/components/ShippingZoneRatesCreatePage/ShippingZoneRatesCreatePage.tsx
+++ b/src/shipping/components/ShippingZoneRatesCreatePage/ShippingZoneRatesCreatePage.tsx
@@ -15,7 +15,7 @@ import { validatePrice } from "@saleor/products/utils/validation";
import OrderValue from "@saleor/shipping/components/OrderValue";
import OrderWeight from "@saleor/shipping/components/OrderWeight";
import PricingCard from "@saleor/shipping/components/PricingCard";
-import ShippingZoneInfo from "@saleor/shipping/components/ShippingZoneInfo";
+import ShippingRateInfo from "@saleor/shipping/components/ShippingRateInfo";
import { createChannelsChangeHandler } from "@saleor/shipping/handlers";
import { ShippingMethodTypeEnum } from "@saleor/types/globalTypes";
import React from "react";
@@ -116,7 +116,7 @@ export const ShippingZoneRatesCreatePage: React.FC
-
= ({
-
- Shipping rate name
+ Shipping zone name
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Description
-
-
- 25 of 300 characters
-
-
-
-
-
-
-
-
-
-
@@ -209685,7 +209688,7 @@ exports[`Storyshots Views / Shipping / Shipping zone details form errors 1`] = `
class="MuiFormLabel-root-id MuiInputLabel-root-id MuiInputLabel-formControl-id MuiInputLabel-animated-id MuiInputLabel-shrink-id MuiInputLabel-outlined-id MuiFormLabel-error-id MuiInputLabel-error-id MuiFormLabel-filled-id"
data-shrink="true"
>
- Shipping rate name
+ Shipping zone name
+
+
+
+
+
+ Description
+
+
+ 25 of 300 characters
+
+
+
+
+
+
+
+
+
+
-
-
-
-
- Description
-
-
- 25 of 300 characters
-
-
-
-
-
-
-
-
-
-
@@ -210656,7 +210662,7 @@ exports[`Storyshots Views / Shipping / Shipping zone details loading 1`] = `
class="MuiFormLabel-root-id MuiInputLabel-root-id MuiInputLabel-formControl-id MuiInputLabel-animated-id MuiInputLabel-outlined-id MuiFormLabel-disabled-id MuiInputLabel-disabled-id"
data-shrink="false"
>
- Shipping rate name
+ Shipping zone name
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-