Skip to content

Commit

Permalink
Add zip code exclusion (#877)
Browse files Browse the repository at this point in the history
* Clean up stories

* Add missing props

* Add zip codes section (#861)

* Add zip code listing

* Add list wrapping

* Update snapshots

* Set up API data

* Fix lgtm warning

* Update snapshots

* Run Actions on all PR

* Checks on PR

* Test envs on PR

* Cleanup action on PR

* Update messages

Co-authored-by: Krzysztof Wolski <[email protected]>

* Add zip code range dialog

* Fix path management

* Use query params to handle modal actions

* Allow zip codes to be assigned to shipping method

* Make params optional

* Fix types

* Add zip code deletion (#871)

* Add zip code range dialog

* Fix path management

* Use query params to handle modal actions

* Allow zip codes to be assigned to shipping method

* Make params optional

* Fix types

* Clean up urls

* Add zip code range delete action

* Update snapshots and messages

* Update testing and changelog

* Update schema

* Simplify code

* Refresh zip code list after assigning them

* Update view after zip code deletion

* Update types and snapshots

* Update snapshots

* Fix error message, checkbox default value (#880)

* Fix error message, checkbox default value

* Update snapshots

* Use price instead of weight variant

* Update schema and types

* Hide exclude/include zip codes section

* Update stories

Co-authored-by: Krzysztof Wolski <[email protected]>
Co-authored-by: Tomasz Szymański <[email protected]>
  • Loading branch information
3 people authored Dec 1, 2020
1 parent eb351b3 commit e55805a
Show file tree
Hide file tree
Showing 41 changed files with 33,383 additions and 29,774 deletions.
1 change: 0 additions & 1 deletion .github/workflows/test-env-cleanup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ name: TEST-ENV-CLEANUP
on:
pull_request:
types: [closed]
branches: ["*"]

jobs:
cleanup:
Expand Down
6 changes: 1 addition & 5 deletions .github/workflows/test-env-deploy.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
name: TEST-ENV-DEPLOYMENT
# Build and deploy test instance for every pull request

on:
pull_request:
# trigger on "edited" to update instance when configuration changes in PR description
types: [opened, reopened, synchronize]
branches: ["*"]
on: [pull_request]

jobs:
deploy:
Expand Down
4 changes: 1 addition & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
name: QA

on:
pull_request:
branches: ["*"]
on: [pull_request]

jobs:
check-lock:
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ All notable, unreleased changes to this project will be documented in this file.
- Add Page Types - #807 by @orzechdev
- Add shipping methods to translation section - #864 by @marekchoinski
- New Miscellaneous and Product refunds - #870 by @orzechdev
- Add zip code exclusion - #877 by @dominik-zeglen

# 2.11.1

Expand Down
75 changes: 69 additions & 6 deletions locale/defaultMessages.json
Original file line number Diff line number Diff line change
Expand Up @@ -5292,9 +5292,9 @@
"context": "channels discount info",
"string": "Channels that don’t have assigned discounts will use their parent channel to define the price. Price will be converted to channel’s currency"
},
"src_dot_shipping_dot_components_dot_OrderValue_dot_2946165345": {
"src_dot_shipping_dot_components_dot_OrderValue_dot_3989471564": {
"context": "card title",
"string": "Order value"
"string": "Order Value"
},
"src_dot_shipping_dot_components_dot_OrderValue_dot_4226393146": {
"context": "price rates info",
Expand All @@ -5319,13 +5319,13 @@
"context": "info text",
"string": "This rate will apply to all orders"
},
"src_dot_shipping_dot_components_dot_OrderWeight_dot_2211490913": {
"context": "card title",
"string": "Order Weight"
},
"src_dot_shipping_dot_components_dot_OrderWeight_dot_2935375344": {
"string": "Min. Order Weight"
},
"src_dot_shipping_dot_components_dot_OrderWeight_dot_3721863048": {
"context": "card title",
"string": "Order weight"
},
"src_dot_shipping_dot_components_dot_OrderWeight_dot_882649212": {
"context": "checkbox label",
"string": "There are no value limits"
Expand All @@ -5349,6 +5349,13 @@
"context": "column title",
"string": "Channel name"
},
"src_dot_shipping_dot_components_dot_ShippingRateZipCodeRangeRemoveDialog_dot_1083561409": {
"string": "Are you sure you want to remove this ZIP-code rule?"
},
"src_dot_shipping_dot_components_dot_ShippingRateZipCodeRangeRemoveDialog_dot_2944856644": {
"context": "header",
"string": "Remove ZIP-codes from Shipping Rate"
},
"src_dot_shipping_dot_components_dot_ShippingWeightUnitForm_dot_2863708228": {
"string": "This unit will be used as default shipping weight"
},
Expand Down Expand Up @@ -5477,6 +5484,54 @@
"context": "input placeholder",
"string": "Select Warehouse"
},
"src_dot_shipping_dot_components_dot_ShippingZoneZipCodeRangeDialog_dot_1938537617": {
"string": "Please provide range of ZIP codes you want to add to the include/exclude list."
},
"src_dot_shipping_dot_components_dot_ShippingZoneZipCodeRangeDialog_dot_3099331554": {
"context": "add zip code range, button",
"string": "Add"
},
"src_dot_shipping_dot_components_dot_ShippingZoneZipCodeRangeDialog_dot_3529644799": {
"context": "range input label",
"string": "Zip Codes (Start)"
},
"src_dot_shipping_dot_components_dot_ShippingZoneZipCodeRangeDialog_dot_4196919717": {
"context": "dialog header",
"string": "Add ZIP-Codes"
},
"src_dot_shipping_dot_components_dot_ShippingZoneZipCodeRangeDialog_dot_551327109": {
"context": "range input label",
"string": "Zip Codes (End)"
},
"src_dot_shipping_dot_components_dot_ShippingZoneZipCodes_dot_1462092303": {
"string": "Added ZIP-codes will be excluded from using this delivery methods. If none are added all ZIP-Codes will be able to use that shipping rate"
},
"src_dot_shipping_dot_components_dot_ShippingZoneZipCodes_dot_1605967697": {
"context": "action",
"string": "Exclude ZIP-codes"
},
"src_dot_shipping_dot_components_dot_ShippingZoneZipCodes_dot_2728850129": {
"string": "Only added ZIP-codes will be able to use this shipping rate"
},
"src_dot_shipping_dot_components_dot_ShippingZoneZipCodes_dot_2850315665": {
"context": "number of zip code ranges",
"string": "{number} ZIP-Code ranges"
},
"src_dot_shipping_dot_components_dot_ShippingZoneZipCodes_dot_3795380518": {
"context": "button",
"string": "Add ZIP-Code range"
},
"src_dot_shipping_dot_components_dot_ShippingZoneZipCodes_dot_4288715411": {
"string": "This shipping rate has no ZIP-codes assigned"
},
"src_dot_shipping_dot_components_dot_ShippingZoneZipCodes_dot_529495587": {
"context": "postal codes, header",
"string": "ZIP-Codes"
},
"src_dot_shipping_dot_components_dot_ShippingZoneZipCodes_dot_671838332": {
"context": "action",
"string": "Include ZIP-codes"
},
"src_dot_shipping_dot_components_dot_ShippingZonesListPage_dot_1325966144": {
"context": "header",
"string": "Shipping"
Expand Down Expand Up @@ -5525,6 +5580,10 @@
"src_dot_shipping_dot_views_dot_PriceRatesCreate_dot_3823295269": {
"string": "Manage Channel Availability"
},
"src_dot_shipping_dot_views_dot_PriceRatesUpdate_dot_2710215007": {
"context": "zip code range add error text",
"string": "Cannot add specified zip codes range."
},
"src_dot_shipping_dot_views_dot_PriceRatesUpdate_dot_3823295269": {
"string": "Manage Channel Availability"
},
Expand All @@ -5543,6 +5602,10 @@
"src_dot_shipping_dot_views_dot_WeightRatesCreate_dot_3014453080": {
"string": "Manage Channels Availability"
},
"src_dot_shipping_dot_views_dot_WeightRatesUpdate_dot_2710215007": {
"context": "zip code range add error text",
"string": "Cannot add specified zip codes range."
},
"src_dot_shipping_dot_views_dot_WeightRatesUpdate_dot_3014453080": {
"string": "Manage Channels Availability"
},
Expand Down
63 changes: 54 additions & 9 deletions schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -2565,11 +2565,15 @@ type Mutation {
shopAddressUpdate(input: AddressInput): ShopAddressUpdate
orderSettingsUpdate(input: OrderSettingsUpdateInput!): OrderSettingsUpdate
shippingMethodChannelListingUpdate(id: ID!, input: ShippingMethodChannelListingInput!): ShippingMethodChannelListingUpdate
shippingMethodZipCodeRulesCreate(input: ShippingZipCodeRulesCreateInput!, shippingMethodId: ID!): ShippingZipCodeRulesCreate
shippingMethodZipCodeRulesDelete(id: ID!): ShippingZipCodeRulesDelete
shippingPriceCreate(input: ShippingPriceInput!): ShippingPriceCreate
shippingPriceDelete(id: ID!): ShippingPriceDelete
shippingPriceBulkDelete(ids: [ID]!): ShippingPriceBulkDelete
shippingPriceUpdate(id: ID!, input: ShippingPriceInput!): ShippingPriceUpdate
shippingPriceTranslate(id: ID!, input: NameTranslationInput!, languageCode: LanguageCodeEnum!): ShippingPriceTranslate
shippingPriceExcludeProducts(id: ID!, input: ShippingPriceExcludeProductsInput!): ShippingPriceExcludeProducts
shippingPriceRemoveProductFromExclude(id: ID!, products: [ID]!): ShippingPriceRemoveProductFromExclude
shippingZoneCreate(input: ShippingZoneCreateInput!): ShippingZoneCreate
shippingZoneDelete(id: ID!): ShippingZoneDelete
shippingZoneBulkDelete(ids: [ID]!): ShippingZoneBulkDelete
Expand Down Expand Up @@ -2856,7 +2860,6 @@ type Order implements Node & ObjectWithMetadata {
totalBalance: Money!
userEmail: String
isShippingRequired: Boolean!
linesAvailableForRefund: [OrderLineAvailableForRefund]!
}

enum OrderAction {
Expand Down Expand Up @@ -3097,11 +3100,6 @@ type OrderLine implements Node {
allocations: [Allocation!]
}

type OrderLineAvailableForRefund {
quantity: Int
orderLine: OrderLine
}

input OrderLineCreateInput {
quantity: Int!
variantId: ID!
Expand All @@ -3124,19 +3122,18 @@ type OrderRefund {
}

input OrderRefundFulfillmentLineInput {
fulfillmentLineId: ID
fulfillmentLineId: ID!
quantity: Int!
}

input OrderRefundLineInput {
orderLineId: ID
orderLineId: ID!
quantity: Int!
}

input OrderRefundProductsInput {
orderLines: [OrderRefundLineInput!]
fulfillmentLines: [OrderRefundFulfillmentLineInput!]
notifyCustomer: Boolean
amountToRefund: PositiveDecimal
includeShippingCosts: Boolean = false
}
Expand Down Expand Up @@ -4656,6 +4653,8 @@ type ShippingMethod implements Node & ObjectWithMetadata {
price: Money
maximumOrderPrice: Money
minimumOrderPrice: Money
zipCodeRules: [ShippingMethodZipCodeRule]
excludedProducts(before: String, after: String, first: Int, last: Int): ProductCountableConnection
}

type ShippingMethodChannelListing implements Node {
Expand Down Expand Up @@ -4702,6 +4701,12 @@ enum ShippingMethodTypeEnum {
WEIGHT
}

type ShippingMethodZipCodeRule implements Node {
start: String
end: String
id: ID!
}

type ShippingPriceBulkDelete {
errors: [Error!]! @deprecated(reason: "Use typed errors with error codes. This field will be removed after 2020-07-31.")
count: Int!
Expand All @@ -4722,6 +4727,16 @@ type ShippingPriceDelete {
shippingErrors: [ShippingError!]!
}

type ShippingPriceExcludeProducts {
errors: [Error!]! @deprecated(reason: "Use typed errors with error codes. This field will be removed after 2020-07-31.")
shippingMethod: ShippingMethod
shippingErrors: [ShippingError!]!
}

input ShippingPriceExcludeProductsInput {
products: [ID]!
}

input ShippingPriceInput {
name: String
minimumOrderWeight: WeightScalar
Expand All @@ -4730,6 +4745,12 @@ input ShippingPriceInput {
shippingZone: ID
}

type ShippingPriceRemoveProductFromExclude {
errors: [Error!]! @deprecated(reason: "Use typed errors with error codes. This field will be removed after 2020-07-31.")
shippingMethod: ShippingMethod
shippingErrors: [ShippingError!]!
}

type ShippingPriceTranslate {
errors: [Error!]! @deprecated(reason: "Use typed errors with error codes. This field will be removed after 2020-07-31.")
translationErrors: [TranslationError!]!
Expand All @@ -4743,6 +4764,29 @@ type ShippingPriceUpdate {
shippingErrors: [ShippingError!]!
}

type ShippingZipCodeRulesCreate {
errors: [Error!]! @deprecated(reason: "Use typed errors with error codes. This field will be removed after 2020-07-31.")
zipCodeRules: [ShippingMethodZipCodeRule]
shippingMethod: ShippingMethod
shippingErrors: [ShippingError!]!
}

input ShippingZipCodeRulesCreateInput {
zipCodeRules: [ShippingZipCodeRulesCreateInputRange]!
}

input ShippingZipCodeRulesCreateInputRange {
start: String!
end: String
}

type ShippingZipCodeRulesDelete {
errors: [Error!]! @deprecated(reason: "Use typed errors with error codes. This field will be removed after 2020-07-31.")
shippingMethod: ShippingMethod
shippingErrors: [ShippingError!]!
shippingMethodZipCodeRule: ShippingMethodZipCodeRule
}

type ShippingZone implements Node & ObjectWithMetadata {
id: ID!
name: String!
Expand Down Expand Up @@ -4807,6 +4851,7 @@ input ShippingZoneUpdateInput {

type Shop {
availablePaymentGateways(currency: String): [PaymentGateway!]!
availableShippingMethods(channel: String!, address: AddressInput): [ShippingMethod]
geolocalization: Geolocalization
authorizationKeys: [AuthorizationKey]!
countries(languageCode: LanguageCodeEnum): [CountryDisplay!]!
Expand Down
16 changes: 15 additions & 1 deletion src/components/RadioGroupField/RadioGroupField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ import { FormattedMessage } from "react-intl";

const useStyles = makeStyles(
theme => ({
alignTop: {
alignSelf: "baseline",
position: "relative",
top: -6
},
formLabel: {
marginBottom: theme.spacing(1)
},
Expand Down Expand Up @@ -51,6 +56,7 @@ export interface RadioGroupFieldChoice<
}

interface RadioGroupFieldProps {
alignTop?: boolean;
choices: RadioGroupFieldChoice[];
className?: string;
disabled?: boolean;
Expand All @@ -65,6 +71,7 @@ interface RadioGroupFieldProps {

export const RadioGroupField: React.FC<RadioGroupFieldProps> = props => {
const {
alignTop,
className,
disabled,
error,
Expand Down Expand Up @@ -107,7 +114,14 @@ export const RadioGroupField: React.FC<RadioGroupFieldProps> = props => {
[classes.radioLabel]: variant !== "inline",
[classes.radioLabelInline]: variant === "inline"
})}
control={<Radio color="primary" />}
control={
<Radio
className={classNames({
[classes.alignTop]: alignTop
})}
color="primary"
/>
}
label={choice.label}
key={choice.value}
/>
Expand Down
14 changes: 13 additions & 1 deletion src/fragments/shipping.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,22 @@ export const shippingZoneFragment = gql`
name
}
`;

export const shippingMethodWithZipCodesFragment = gql`
fragment ShippingMethodWithZipCodesFragment on ShippingMethod {
id
zipCodeRules {
id
start
end
}
}
`;
export const shippingMethodFragment = gql`
${fragmentMoney}
${shippingMethodWithZipCodesFragment}
fragment ShippingMethodFragment on ShippingMethod {
id
...ShippingMethodWithZipCodesFragment
minimumOrderWeight {
unit
value
Expand Down
8 changes: 8 additions & 0 deletions src/fragments/types/ShippingMethodFragment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@ import { WeightUnitsEnum, ShippingMethodTypeEnum } from "./../../types/globalTyp
// GraphQL fragment: ShippingMethodFragment
// ====================================================

export interface ShippingMethodFragment_zipCodeRules {
__typename: "ShippingMethodZipCodeRule";
id: string;
start: string | null;
end: string | null;
}

export interface ShippingMethodFragment_minimumOrderWeight {
__typename: "Weight";
unit: WeightUnitsEnum;
Expand Down Expand Up @@ -57,6 +64,7 @@ export interface ShippingMethodFragment_channelListings {
export interface ShippingMethodFragment {
__typename: "ShippingMethod";
id: string;
zipCodeRules: (ShippingMethodFragment_zipCodeRules | null)[] | null;
minimumOrderWeight: ShippingMethodFragment_minimumOrderWeight | null;
maximumOrderWeight: ShippingMethodFragment_maximumOrderWeight | null;
name: string;
Expand Down
Loading

0 comments on commit e55805a

Please sign in to comment.