Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Remove charge_taxes flag
dominik-zeglen79c61195940d
diff --git a/saleor/static/dashboard-next/productTypes/components/ProductTypeDetailsPage/ProductTypeDetailsPage.tsx b/saleor/static/dashboard-next/productTypes/components/ProductTypeDetailsPage/ProductTypeDetailsPage.tsxindex f7a2a3afad..87e7bcefe3 100644--- a/saleor/static/dashboard-next/productTypes/components/ProductTypeDetailsPage/ProductTypeDetailsPage.tsx+++ b/saleor/static/dashboard-next/productTypes/components/ProductTypeDetailsPage/ProductTypeDetailsPage.tsx@@ -26,7 +26,6 @@ interface ChoiceType {value: string;}export interface ProductTypeForm {- chargeTaxes: boolean;name: string;hasVariants: boolean;isShippingRequired: boolean;@@ -81,7 +80,6 @@ const ProductTypeDetailsPage = decorate<ProductTypeDetailsPageProps>(onSubmit}) => {const formInitialData: ProductTypeForm = {- chargeTaxes: maybe(() => productType.taxRate !== null, false),hasVariants:maybe(() => productType.hasVariants) !== undefined? productType.hasVariantsdiff --git a/saleor/static/dashboard-next/productTypes/components/ProductTypeTaxes/ProductTypeTaxes.tsx b/saleor/static/dashboard-next/productTypes/components/ProductTypeTaxes/ProductTypeTaxes.tsxindex 7af29d63e1..b23a7df964 100644--- a/saleor/static/dashboard-next/productTypes/components/ProductTypeTaxes/ProductTypeTaxes.tsx+++ b/saleor/static/dashboard-next/productTypes/components/ProductTypeTaxes/ProductTypeTaxes.tsx@@ -3,8 +3,6 @@ import CardContent from "@material-ui/core/CardContent";import * as React from "react";import CardTitle from "../../../components/CardTitle";-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";@@ -12,7 +10,6 @@ import { TaxRateType } from "../../../types/globalTypes";interface ProductTypeTaxesProps {data: {- chargeTaxes: boolean;taxRate: TaxRateType | null;};disabled: boolean;@@ -28,29 +25,18 @@ const ProductTypeTaxes: React.StatelessComponent<ProductTypeTaxesProps> = ({onChange}) => (<Card>- <CardTitle title={i18n.t("Shipping")} />+ <CardTitle title={i18n.t("Taxes")} /><CardContent>- <ControlledCheckbox- checked={data.chargeTaxes}+ <SingleSelectField+ choices={taxRateChoices}disabled={disabled}- label={i18n.t("Charge taxes for this product")}- name="chargeTaxes"+ label={i18n.t("Tax rate (optional)", {+ context: "select field label"+ })}+ name="taxRate"onChange={onChange}+ value={data.taxRate}/>- {data.chargeTaxes && (- <>- <FormSpacer />- <SingleSelectField- choices={taxRateChoices}- label={i18n.t("Tax rate (optional)", {- context: "select field label"- })}- name="taxRate"- onChange={onChange}- value={data.taxRate}- />- </>- )}</CardContent></Card>);diff --git a/saleor/static/dashboard-next/productTypes/views/ProductTypeUpdate.tsx b/saleor/static/dashboard-next/productTypes/views/ProductTypeUpdate.tsxindex fe05d5af7c..d40664c43b 100644--- a/saleor/static/dashboard-next/productTypes/views/ProductTypeUpdate.tsx+++ b/saleor/static/dashboard-next/productTypes/views/ProductTypeUpdate.tsx@@ -9,7 +9,6 @@ import { maybe } from "../../misc";import ProductTypeDetailsPage, {ProductTypeForm} from "../components/ProductTypeDetailsPage";-import { AttributeSearchProvider } from "../containers/AttributeSearch";import ProductTypeOperations from "../containers/ProductTypeOperations";import { TypedProductTypeDetailsQuery } from "../queries";import { ProductTypeDelete } from "../types/ProductTypeDelete";@@ -35,97 +34,79 @@ export const ProductTypeUpdate: React.StatelessComponent</>);}+ const handleDeleteSuccess = (deleteData: ProductTypeDelete) => {+ if (deleteData.productTypeDelete.errors.length === 0) {+ pushMessage({+ text: i18n.t("Successfully deleted product type")+ });+ navigate(productTypeListUrl);+ }+ };+ const handleUpdateSuccess = (+ updateData: ProductTypeUpdateMutation+ ) => {+ if (updateData.productTypeUpdate.errors.length === 0) {+ pushMessage({+ text: i18n.t("Successfully updated product type")+ });+ }+ };+return (- <AttributeSearchProvider>- {(searchAttribute, searchState) => {- const handleDeleteSuccess = (- deleteData: ProductTypeDelete- ) => {- if (deleteData.productTypeDelete.errors.length === 0) {- pushMessage({- text: i18n.t("Successfully deleted product type")- });- navigate(productTypeListUrl);- }- };- const handleUpdateSuccess = (- updateData: ProductTypeUpdateMutation- ) => {- if (updateData.productTypeUpdate.errors.length === 0) {- pushMessage({- text: i18n.t("Successfully updated product type")- });- }+ <ProductTypeOperations+ id={id}+ onDelete={handleDeleteSuccess}+ onUpdate={handleUpdateSuccess}+ >+ {({+ deleteProductType,+ errors,+ loading: mutationLoading,+ updateProductType+ }) => {+ const handleDelete = () => deleteProductType.mutate({ id });+ const handleUpdate = (formData: ProductTypeForm) => {+ updateProductType.mutate({+ id,+ input: {+ hasVariants: formData.hasVariants,+ isShippingRequired: formData.isShippingRequired,+ name: formData.name,+ productAttributes: formData.productAttributes.map(+ choice => choice.value+ ),+ taxRate: formData.taxRate,+ variantAttributes: formData.variantAttributes.map(+ choice => choice.value+ ),+ weight: formData.weight+ }+ });};+ const loading = mutationLoading || dataLoading;return (- <ProductTypeOperations- id={id}- onDelete={handleDeleteSuccess}- onUpdate={handleUpdateSuccess}- >- {({- deleteProductType,- errors,- loading: mutationLoading,- updateProductType- }) => {- const handleDelete = () =>- deleteProductType.mutate({ id });- const handleUpdate = (formData: ProductTypeForm) => {- updateProductType.mutate({- id,- input: {- hasVariants: formData.hasVariants,- isShippingRequired: formData.isShippingRequired,- name: formData.name,- productAttributes: formData.productAttributes.map(- choice => choice.value- ),- taxRate: formData.taxRate,- variantAttributes: formData.variantAttributes.map(- choice => choice.value- ),- weight: formData.weight- }- });- };- const loading = mutationLoading || dataLoading;- return (- <ProductTypeDetailsPage- defaultWeightUnit={maybe(- () => data.shop.defaultWeightUnit- )}- disabled={loading}- errors={errors}- pageTitle={- data && data.productType- ? data.productType.name- : undefined- }- productType={maybe(() => data.productType)}- saveButtonBarState={- loading ? "loading" : "default"- }- searchLoading={maybe(() => searchState.loading)}- searchResults={maybe(- () =>- searchState.data.attributes.edges.map(- edge => edge.node- ),- []- )}- onAttributeSearch={searchAttribute}- onBack={() => navigate(productTypeListUrl)}- onDelete={handleDelete}- onSubmit={handleUpdate}- key={searchState ? undefined : "search"}- />- );- }}- </ProductTypeOperations>+ <ProductTypeDetailsPage+ defaultWeightUnit={maybe(+ () => data.shop.defaultWeightUnit+ )}+ disabled={loading}+ errors={errors}+ pageTitle={+ data && data.productType+ ? data.productType.name+ : undefined+ }+ productType={maybe(() => data.productType)}+ saveButtonBarState={loading ? "loading" : "default"}+ onAttributeAdd={() => undefined}+ onAttributeUpdate={() => undefined}+ onBack={() => navigate(productTypeListUrl)}+ onDelete={handleDelete}+ onSubmit={handleUpdate}+ />);}}- </AttributeSearchProvider>+ </ProductTypeOperations>);}}</TypedProductTypeDetailsQuery>