Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Rebase fixes
dominik-zeglenff01ca34ced3
diff --git a/saleor/static/dashboard-next/misc.ts b/saleor/static/dashboard-next/misc.tsindex a420224a6c..8f00376e2b 100644--- a/saleor/static/dashboard-next/misc.ts+++ b/saleor/static/dashboard-next/misc.ts@@ -1,4 +1,6 @@import { stringify } from "qs";+import { TaxRateType } from "./gql-types";+import i18n from "./i18n";export interface PageInfo {endCursor: string;@@ -109,3 +111,36 @@ export function decimal(value: string) {export const removeDoubleSlashes = (url: string) =>url.replace(/([^:]\/)\/+/g, "$1");++export const translatedTaxRates = () => ({+ [TaxRateType.ACCOMODATION]: i18n.t("Accomodation"),+ [TaxRateType.ADMISSION_TO_CULTURAL_EVENTS]: i18n.t(+ "Admission to cultural events"+ ),+ [TaxRateType.ADMISSION_TO_ENTERTAINMENT_EVENTS]: i18n.t(+ "Admission to enterainment events"+ ),+ [TaxRateType.ADMISSION_TO_SPORTING_EVENTS]: i18n.t(+ "Admission to sporting events"+ ),+ [TaxRateType.ADVERTISING]: i18n.t("Advertising"),+ [TaxRateType.AGRICULTURAL_SUPPLIES]: i18n.t("Agricultural supplies"),+ [TaxRateType.BABY_FOODSTUFFS]: i18n.t("Baby foodstuffs"),+ [TaxRateType.BIKES]: i18n.t("Bikes"),+ [TaxRateType.BOOKS]: i18n.t("Books"),+ [TaxRateType.CHILDRENS_CLOTHING]: i18n.t("Children's clothing"),+ [TaxRateType.DOMESTIC_FUEL]: i18n.t("Domestic fuel"),+ [TaxRateType.DOMESTIC_SERVICES]: i18n.t("Domestic services"),+ [TaxRateType.E_BOOKS]: i18n.t("E-books"),+ [TaxRateType.FOODSTUFFS]: i18n.t("Foodstuffs"),+ [TaxRateType.HOTELS]: i18n.t("Hotels"),+ [TaxRateType.MEDICAL]: i18n.t("Medical"),+ [TaxRateType.NEWSPAPERS]: i18n.t("Newspapers"),+ [TaxRateType.PASSENGER_TRANSPORT]: i18n.t("Passenger transport"),+ [TaxRateType.PHARMACEUTICALS]: i18n.t("Pharmaceuticals"),+ [TaxRateType.PROPERTY_RENOVATIONS]: i18n.t("Property renovations"),+ [TaxRateType.RESTAURANTS]: i18n.t("Restaurants"),+ [TaxRateType.SOCIAL_HOUSING]: i18n.t("Social housing"),+ [TaxRateType.STANDARD]: i18n.t("Standard"),+ [TaxRateType.WATER]: i18n.t("Water")+});diff --git a/saleor/static/dashboard-next/productTypes/components/ProductTypeDetailsPage/ProductTypeDetailsPage.tsx b/saleor/static/dashboard-next/productTypes/components/ProductTypeDetailsPage/ProductTypeDetailsPage.tsxindex 68575dab99..8b7f588cb6 100644--- a/saleor/static/dashboard-next/productTypes/components/ProductTypeDetailsPage/ProductTypeDetailsPage.tsx+++ b/saleor/static/dashboard-next/productTypes/components/ProductTypeDetailsPage/ProductTypeDetailsPage.tsx@@ -55,7 +55,6 @@ interface ProductTypeDetailsPageProps {id: string;name: string;}>;- taxRates: TaxRateType[];onAttributeSearch: (name: string) => void;onBack: () => void;onDelete?: () => void;@@ -80,7 +79,6 @@ const ProductTypeDetailsPage = decorate<ProductTypeDetailsPageProps>(saveButtonBarState,searchLoading,searchResults,- taxRates,variantAttributes,onAttributeSearch,onBack,@@ -148,7 +146,6 @@ const ProductTypeDetailsPage = decorate<ProductTypeDetailsPageProps>(<ProductTypePropertiesdata={data}disabled={disabled}- taxRates={taxRates}onChange={change}/></div>diff --git a/saleor/static/dashboard-next/productTypes/components/ProductTypeProperties/ProductTypeProperties.tsx b/saleor/static/dashboard-next/productTypes/components/ProductTypeProperties/ProductTypeProperties.tsxindex d2f8835166..fc17c92021 100644--- a/saleor/static/dashboard-next/productTypes/components/ProductTypeProperties/ProductTypeProperties.tsx+++ b/saleor/static/dashboard-next/productTypes/components/ProductTypeProperties/ProductTypeProperties.tsx@@ -7,6 +7,7 @@ import ControlledCheckbox from "../../../components/ControlledCheckbox";import FormSpacer from "../../../components/FormSpacer";import SingleSelectField from "../../../components/SingleSelectField";import i18n from "../../../i18n";+import { translatedTaxRates as taxRates } from "../../../misc";interface ProductTypePropertiesProps {data?: {@@ -15,13 +16,17 @@ interface ProductTypePropertiesProps {taxRate: string;};disabled: boolean;- taxRates: string[];onChange: (event: React.ChangeEvent<any>) => void;}+const taxRateChoices = Object.keys(taxRates()).map(key => ({+ label: taxRates()[key],+ value: key+}));+const ProductTypeProperties: React.StatelessComponent<ProductTypePropertiesProps-> = ({ data, disabled, taxRates, onChange }) => (+> = ({ data, disabled, onChange }) => (<Card><CardTitle title={i18n.t("Properties")} /><CardContent>@@ -41,7 +46,7 @@ const ProductTypeProperties: React.StatelessComponent</><FormSpacer /><SingleSelectField- choices={taxRates.map(t => ({ label: i18n.t(t), value: t }))}+ choices={taxRateChoices}hint={i18n.t("Optional")}label={i18n.t("Tax rate")}name="taxRate"diff --git a/saleor/static/dashboard-next/productTypes/queries.ts b/saleor/static/dashboard-next/productTypes/queries.tsindex 3a9b18af5e..3bd9829d22 100644--- a/saleor/static/dashboard-next/productTypes/queries.ts+++ b/saleor/static/dashboard-next/productTypes/queries.ts@@ -2,7 +2,6 @@ import gql from "graphql-tag";import { Query, QueryProps } from "react-apollo";import {- ProductTypeCreateDataQuery,ProductTypeDetailsQuery,ProductTypeDetailsQueryVariables,ProductTypeListQuery,@@ -93,19 +92,6 @@ export const productTypeDetailsQuery = gql`}`;-export const TypedProductTypeCreateDataQuery = Query as React.ComponentType<- QueryProps<ProductTypeCreateDataQuery>->;-export const productTypeCreateQuery = gql`- query ProductTypeCreateData {- __type(name: "TaxRateType") {- enumValues {- name- }- }- }-`;-export const TypedSearchAttributeQuery = Query as React.ComponentType<QueryProps<SearchAttributeQuery, SearchAttributeQueryVariables>>;diff --git a/saleor/static/dashboard-next/productTypes/views/ProductTypeCreate.tsx b/saleor/static/dashboard-next/productTypes/views/ProductTypeCreate.tsxindex f200965b3b..0ae652d00f 100644--- a/saleor/static/dashboard-next/productTypes/views/ProductTypeCreate.tsx+++ b/saleor/static/dashboard-next/productTypes/views/ProductTypeCreate.tsx@@ -3,17 +3,13 @@ import Navigator from "../../components/Navigator";import { productTypeDetailsUrl, productTypeListUrl } from "..";import Messages from "../../components/messages";-import { ProductTypeCreateMutation, TaxRateType } from "../../gql-types";+import { ProductTypeCreateMutation } from "../../gql-types";import i18n from "../../i18n";import ProductTypeDetailsPage, {ProductTypeForm} from "../components/ProductTypeDetailsPage";import { AttributeSearchProvider } from "../containers/AttributeSearch";import { TypedProductTypeCreateMutation } from "../mutations";-import {- productTypeCreateQuery,- TypedProductTypeCreateDataQuery-} from "../queries";const formData = {hasVariants: false,@@ -29,94 +25,83 @@ export const ProductTypeCreate: React.StatelessComponent = () => ({pushMessage => (<Navigator>{navigate => (- <TypedProductTypeCreateDataQuery query={productTypeCreateQuery}>- {createData => (- <AttributeSearchProvider>- {(searchAttribute, searchState) => {- const handleCreateSuccess = (- updateData: ProductTypeCreateMutation+ <AttributeSearchProvider>+ {(searchAttribute, searchState) => {+ const handleCreateSuccess = (+ updateData: ProductTypeCreateMutation+ ) => {+ if (updateData.productTypeCreate.errors.length === 0) {+ pushMessage({+ text: i18n.t("Successfully created product type")+ });+ navigate(+ productTypeDetailsUrl(+ updateData.productTypeCreate.productType.id+ )+ );+ }+ };+ return (+ <TypedProductTypeCreateMutation+ onCompleted={handleCreateSuccess}+ >+ {(+ createProductType,+ { loading: loadingCreate, data: createProductTypeData }) => {- if (updateData.productTypeCreate.errors.length === 0) {- pushMessage({- text: i18n.t("Successfully created product type")+ const handleCreate = (formData: ProductTypeForm) =>+ createProductType({+ variables: {+ input: {+ ...formData,+ productAttributes: formData.productAttributes.map(+ choice => choice.value+ ),+ variantAttributes: formData.variantAttributes.map(+ choice => choice.value+ )+ }+ }});- navigate(- productTypeDetailsUrl(- updateData.productTypeCreate.productType.id- )- );- }- };- return (- <TypedProductTypeCreateMutation- onCompleted={handleCreateSuccess}- >- {(- createProductType,- { loading: loadingCreate, data: createProductTypeData }- ) => {- const handleCreate = (formData: ProductTypeForm) =>- createProductType({- variables: {- input: {- ...formData,- productAttributes: formData.productAttributes.map(- choice => choice.value- ),- variantAttributes: formData.variantAttributes.map(- choice => choice.value- )- }- }- });- return (- <ProductTypeDetailsPage- disabled={loadingCreate}- errors={- createProductTypeData- ? createProductTypeData.productTypeCreate.errors- : undefined- }- pageTitle={i18n.t("Create Product Type", {- context: "page title"- })}- productType={formData}- productAttributes={[]}- variantAttributes={[]}- saveButtonBarState={- loadingCreate ? "loading" : "default"- }- searchLoading={- searchState ? searchState.loading : false- }- searchResults={- searchState &&- searchState.data &&- searchState.data.attributes- ? searchState.data.attributes.edges.map(- edge => edge.node- )- : []- }- taxRates={- createData.data && createData.data.__type- ? createData.data.__type.enumValues.map(- value => value.name as TaxRateType- )- : []- }- onAttributeSearch={searchAttribute}- onBack={() => navigate(productTypeListUrl)}- onSubmit={handleCreate}- />- );- }}- </TypedProductTypeCreateMutation>- );- }}- </AttributeSearchProvider>- )}- </TypedProductTypeCreateDataQuery>+ return (+ <ProductTypeDetailsPage+ disabled={loadingCreate}+ errors={+ createProductTypeData+ ? createProductTypeData.productTypeCreate.errors+ : undefined+ }+ pageTitle={i18n.t("Create Product Type", {+ context: "page title"+ })}+ productType={formData}+ productAttributes={[]}+ variantAttributes={[]}+ saveButtonBarState={+ loadingCreate ? "loading" : "default"+ }+ searchLoading={+ searchState ? searchState.loading : false+ }+ searchResults={+ searchState &&+ searchState.data &&+ searchState.data.attributes+ ? searchState.data.attributes.edges.map(+ edge => edge.node+ )+ : []+ }+ onAttributeSearch={searchAttribute}+ onBack={() => navigate(productTypeListUrl)}+ onSubmit={handleCreate}+ />+ );+ }}+ </TypedProductTypeCreateMutation>+ );+ }}+ </AttributeSearchProvider>)}</Navigator>)}diff --git a/saleor/static/dashboard-next/productTypes/views/ProductTypeUpdate.tsx b/saleor/static/dashboard-next/productTypes/views/ProductTypeUpdate.tsxindex 11415ad590..1dcc237080 100644--- a/saleor/static/dashboard-next/productTypes/views/ProductTypeUpdate.tsx+++ b/saleor/static/dashboard-next/productTypes/views/ProductTypeUpdate.tsx@@ -6,8 +6,7 @@ import ErrorMessageCard from "../../components/ErrorMessageCard";import Messages from "../../components/messages";import {ProductTypeDeleteMutation,- ProductTypeUpdateMutation,- TaxRateType+ ProductTypeUpdateMutation} from "../../gql-types";import i18n from "../../i18n";import ProductTypeDetailsPage, {@@ -139,13 +138,6 @@ export const ProductTypeUpdate: React.StatelessComponent<): []}- taxRates={- data && data.__type && data.__type.enumValues- ? data.__type.enumValues.map(- value => value.name as TaxRateType- )- : []- }onAttributeSearch={searchAttribute}onBack={() => navigate(productTypeListUrl)}onDelete={handleDelete}diff --git a/saleor/static/dashboard-next/storybook/stories/productTypes/ProductTypeDetailsPage.tsx b/saleor/static/dashboard-next/storybook/stories/productTypes/ProductTypeDetailsPage.tsxindex 8f88dfb017..a9d158e45e 100644--- a/saleor/static/dashboard-next/storybook/stories/productTypes/ProductTypeDetailsPage.tsx+++ b/saleor/static/dashboard-next/storybook/stories/productTypes/ProductTypeDetailsPage.tsx@@ -1,13 +1,10 @@import { storiesOf } from "@storybook/react";import * as React from "react";-import { TaxRateType } from "../../../gql-types";import ProductTypeDetailsPage from "../../../productTypes/components/ProductTypeDetailsPage";import { attributes, productType } from "../../../productTypes/fixtures";import Decorator from "../../Decorator";-const taxRates = Object.keys(TaxRateType).map(key => TaxRateType[key]);-storiesOf("Views / Product types / Product type details", module).addDecorator(Decorator).add("default", () => (@@ -25,7 +22,6 @@ storiesOf("Views / Product types / Product type details", module)saveButtonBarState="default"searchLoading={false}searchResults={attributes}- taxRates={taxRates}onAttributeSearch={undefined}onBack={() => undefined}onDelete={undefined}@@ -40,7 +36,6 @@ storiesOf("Views / Product types / Product type details", module)saveButtonBarState="default"searchLoading={false}searchResults={[]}- taxRates={[]}onAttributeSearch={undefined}onBack={() => undefined}onDelete={undefined}