Skip to content

Commit

Permalink
Excluded Products in shipping view (#866)
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 <krzysztof.k.wolski@gmail.com>

* Allow zip codes to be assigned to shipping method

* 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 schema

* Refresh zip code list after assigning them

* Update types and snapshots

* Update snapshots

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

* Fix error message, checkbox default value

* Update snapshots

* Update schema and types

* Update stories

* add excluded products section in shipping methods views

* create UnassignDialog component

* use priceRangeFragment in shipping queries

* remove unneeded price from ShippingMethodAddProductsDialog

* update messages in ShippingMethodProducts

* updates after rebase

* update snapshots, fix lint errors

* fix ShippingMethodProductsAddDialog

* update snapshots

* small fix in ShippingMethodProducts

* update snapshots after rebase

* add handleClose func in ShippingMethodProductsAddDialog

* Fix metadata not showing in category update

* update snapshots again

* update ShippingMethodProductsAddDialog

* updates after rebase

* update Price and Weight rates views

Co-authored-by: dominik-zeglen <flesz3@o2.pl>
Co-authored-by: Krzysztof Wolski <krzysztof.k.wolski@gmail.com>
Co-authored-by: Tomasz Szymański <lime129@gmail.com>
Co-authored-by: Magdalena Markusik <magdalena.markusik@mirumee.com>
  • Loading branch information
5 people authored Dec 2, 2020
1 parent f97ddd0 commit b774cc9
Show file tree
Hide file tree
Showing 32 changed files with 7,170 additions and 1,087 deletions.
52 changes: 49 additions & 3 deletions locale/defaultMessages.json
Original file line number Diff line number Diff line change
Expand Up @@ -5349,6 +5349,33 @@
"context": "column title",
"string": "Channel name"
},
"src_dot_shipping_dot_components_dot_ShippingMethodProductsAddDialog_dot_2850255786": {
"string": "Search Products"
},
"src_dot_shipping_dot_components_dot_ShippingMethodProductsAddDialog_dot_353369701": {
"string": "No products matching given query"
},
"src_dot_shipping_dot_components_dot_ShippingMethodProductsAddDialog_dot_3756118423": {
"context": "dialog header",
"string": "Assign Products"
},
"src_dot_shipping_dot_components_dot_ShippingMethodProducts_dot_1737533260": {
"string": "No Products"
},
"src_dot_shipping_dot_components_dot_ShippingMethodProducts_dot_1781179817": {
"context": "section header",
"string": "Excluded Products"
},
"src_dot_shipping_dot_components_dot_ShippingMethodProducts_dot_2100305525": {
"context": "button",
"string": "Assign products"
},
"src_dot_shipping_dot_components_dot_ShippingMethodProducts_dot_2697405188": {
"string": "Product Name"
},
"src_dot_shipping_dot_components_dot_ShippingMethodProducts_dot_4190792473": {
"string": "Actions"
},
"src_dot_shipping_dot_components_dot_ShippingRateZipCodeRangeRemoveDialog_dot_1083561409": {
"string": "Are you sure you want to remove this ZIP-code rule?"
},
Expand Down Expand Up @@ -5427,17 +5454,20 @@
"src_dot_shipping_dot_components_dot_ShippingZoneInfo_dot_579967655": {
"string": "Shipping rate name"
},
"src_dot_shipping_dot_components_dot_ShippingZoneRatesPage_dot_1161979494": {
"src_dot_shipping_dot_components_dot_ShippingZoneRatesCreatePage_dot_1161979494": {
"context": "page title",
"string": "Price Rate Create"
},
"src_dot_shipping_dot_components_dot_ShippingZoneRatesPage_dot_1325966144": {
"src_dot_shipping_dot_components_dot_ShippingZoneRatesCreatePage_dot_1325966144": {
"string": "Shipping"
},
"src_dot_shipping_dot_components_dot_ShippingZoneRatesPage_dot_3538551526": {
"src_dot_shipping_dot_components_dot_ShippingZoneRatesCreatePage_dot_3538551526": {
"context": "page title",
"string": "Weight Rate Create"
},
"src_dot_shipping_dot_components_dot_ShippingZoneRatesPage_dot_1325966144": {
"string": "Shipping"
},
"src_dot_shipping_dot_components_dot_ShippingZoneRates_dot_1134347598": {
"context": "shipping method price",
"string": "Price"
Expand Down Expand Up @@ -5554,6 +5584,14 @@
"src_dot_shipping_dot_components_dot_ShippingZonesList_dot_655374584": {
"string": "No shipping zones found"
},
"src_dot_shipping_dot_components_dot_UnassignDialog_dot_1203193503": {
"context": "dialog header",
"string": "Unassign Products From Shipping"
},
"src_dot_shipping_dot_components_dot_UnassignDialog_dot_3215481647": {
"context": "dialog content",
"string": "{counter,plural,one{Are you sure you want to unassign this product?} other{Are you sure you want to unassign {displayQuantity} products?}}"
},
"src_dot_shipping_dot_invalid": {
"context": "error message",
"string": "Value is invalid"
Expand Down Expand Up @@ -5587,6 +5625,10 @@
"src_dot_shipping_dot_views_dot_PriceRatesUpdate_dot_3823295269": {
"string": "Manage Channel Availability"
},
"src_dot_shipping_dot_views_dot_PriceRatesUpdate_dot_870815507": {
"context": "unassign products from shipping method, button",
"string": "Unassign"
},
"src_dot_shipping_dot_views_dot_ShippingZoneDetails_dot_1010705153": {
"context": "dialog header",
"string": "Delete Shipping Zone"
Expand All @@ -5609,6 +5651,10 @@
"src_dot_shipping_dot_views_dot_WeightRatesUpdate_dot_3014453080": {
"string": "Manage Channels Availability"
},
"src_dot_shipping_dot_views_dot_WeightRatesUpdate_dot_870815507": {
"context": "unassign products from shipping method, button",
"string": "Unassign"
},
"src_dot_shipping_dot_weight": {
"context": "error message",
"string": "Maximum weight cannot be lower than minimum"
Expand Down
2 changes: 1 addition & 1 deletion src/categories/components/CategoryUpdatePage/form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ function useCategoryUpdateForm(
// Need to make it function to always have description.current up to date
const getData = (): CategoryUpdateData => ({
...form.data,
...getMetadata(form.data, isMetadataModified, isPrivateMetadataModified),
description: description.current
});

const getSubmitData = (): CategoryUpdateData => ({
...getData(),
...getMetadata(form.data, isMetadataModified, isPrivateMetadataModified)
Expand Down
30 changes: 30 additions & 0 deletions src/fragments/shipping.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,36 @@ export const shippingMethodFragment = gql`
}
}
`;
export const shippingMethodWithExcludedProductsFragment = gql`
${fragmentMoney}
${shippingMethodFragment}
fragment ShippingMethodWithExcludedProductsFragment on ShippingMethod {
...ShippingMethodFragment
excludedProducts(
before: $before
after: $after
first: $first
last: $last
) {
pageInfo {
hasNextPage
hasPreviousPage
endCursor
startCursor
}
edges {
node {
id
name
thumbnail {
url
}
}
}
}
}
`;

export const shippingZoneDetailsFragment = gql`
${shippingZoneFragment}
${shippingMethodFragment}
Expand Down
105 changes: 105 additions & 0 deletions src/fragments/types/ShippingMethodWithExcludedProductsFragment.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
/* tslint:disable */
/* eslint-disable */
// This file was automatically generated and should not be edited.

import { WeightUnitsEnum, ShippingMethodTypeEnum } from "./../../types/globalTypes";

// ====================================================
// GraphQL fragment: ShippingMethodWithExcludedProductsFragment
// ====================================================

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

export interface ShippingMethodWithExcludedProductsFragment_minimumOrderWeight {
__typename: "Weight";
unit: WeightUnitsEnum;
value: number;
}

export interface ShippingMethodWithExcludedProductsFragment_maximumOrderWeight {
__typename: "Weight";
unit: WeightUnitsEnum;
value: number;
}

export interface ShippingMethodWithExcludedProductsFragment_channelListings_channel {
__typename: "Channel";
id: string;
name: string;
currencyCode: string;
}

export interface ShippingMethodWithExcludedProductsFragment_channelListings_price {
__typename: "Money";
amount: number;
currency: string;
}

export interface ShippingMethodWithExcludedProductsFragment_channelListings_minimumOrderPrice {
__typename: "Money";
amount: number;
currency: string;
}

export interface ShippingMethodWithExcludedProductsFragment_channelListings_maximumOrderPrice {
__typename: "Money";
amount: number;
currency: string;
}

export interface ShippingMethodWithExcludedProductsFragment_channelListings {
__typename: "ShippingMethodChannelListing";
id: string;
channel: ShippingMethodWithExcludedProductsFragment_channelListings_channel;
price: ShippingMethodWithExcludedProductsFragment_channelListings_price | null;
minimumOrderPrice: ShippingMethodWithExcludedProductsFragment_channelListings_minimumOrderPrice | null;
maximumOrderPrice: ShippingMethodWithExcludedProductsFragment_channelListings_maximumOrderPrice | null;
}

export interface ShippingMethodWithExcludedProductsFragment_excludedProducts_pageInfo {
__typename: "PageInfo";
hasNextPage: boolean;
hasPreviousPage: boolean;
endCursor: string | null;
startCursor: string | null;
}

export interface ShippingMethodWithExcludedProductsFragment_excludedProducts_edges_node_thumbnail {
__typename: "Image";
url: string;
}

export interface ShippingMethodWithExcludedProductsFragment_excludedProducts_edges_node {
__typename: "Product";
id: string;
name: string;
thumbnail: ShippingMethodWithExcludedProductsFragment_excludedProducts_edges_node_thumbnail | null;
}

export interface ShippingMethodWithExcludedProductsFragment_excludedProducts_edges {
__typename: "ProductCountableEdge";
node: ShippingMethodWithExcludedProductsFragment_excludedProducts_edges_node;
}

export interface ShippingMethodWithExcludedProductsFragment_excludedProducts {
__typename: "ProductCountableConnection";
pageInfo: ShippingMethodWithExcludedProductsFragment_excludedProducts_pageInfo;
edges: ShippingMethodWithExcludedProductsFragment_excludedProducts_edges[];
}

export interface ShippingMethodWithExcludedProductsFragment {
__typename: "ShippingMethod";
id: string;
zipCodeRules: (ShippingMethodWithExcludedProductsFragment_zipCodeRules | null)[] | null;
minimumOrderWeight: ShippingMethodWithExcludedProductsFragment_minimumOrderWeight | null;
maximumOrderWeight: ShippingMethodWithExcludedProductsFragment_maximumOrderWeight | null;
name: string;
type: ShippingMethodTypeEnum | null;
channelListings: ShippingMethodWithExcludedProductsFragment_channelListings[] | null;
excludedProducts: ShippingMethodWithExcludedProductsFragment_excludedProducts | null;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { shippingZone } from "@saleor/shipping/fixtures";
import Decorator from "@saleor/storybook//Decorator";
import { storiesOf } from "@storybook/react";
import React from "react";

import ShippingMethodProducts, {
ShippingMethodProductsProps
} from "./ShippingMethodProducts";

const products = shippingZone.shippingMethods[0].excludedProducts.edges.map(
edge => edge.node
);

const props: ShippingMethodProductsProps = {
disabled: false,
isChecked: () => undefined,
onNextPage: () => undefined,
onPreviousPage: () => undefined,
onProductAssign: () => undefined,
onProductUnassign: () => undefined,
pageInfo: {
hasNextPage: false,
hasPreviousPage: false
},
products,
selected: products.length,
toggle: () => undefined,
toggleAll: () => undefined,
toolbar: () => undefined
};

storiesOf("Shipping / ShippingMethodProducts", module)
.addDecorator(Decorator)
.add("default", () => <ShippingMethodProducts {...props} />);
Loading

0 comments on commit b774cc9

Please sign in to comment.