Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Add country list view
dominik-zeglenaa81277aa374
diff --git a/saleor/static/dashboard-next/configuration/index.tsx b/saleor/static/dashboard-next/configuration/index.tsxindex 8502816b29..e033414fd1 100644--- a/saleor/static/dashboard-next/configuration/index.tsx+++ b/saleor/static/dashboard-next/configuration/index.tsx@@ -14,6 +14,7 @@ import StoreMall from "../icons/StoreMall";import { productTypeListUrl } from "../productTypes/urls";import { siteSettingsUrl } from "../siteSettings/urls";import { staffListUrl } from "../staff/urls";+import { taxSection } from "../taxes/urls";import { PermissionEnum } from "../types/globalTypes";import ConfigurationPage, { MenuItem } from "./ConfigurationPage";@@ -42,7 +43,8 @@ export const configurationMenu: MenuItem[] = [description: i18n.t("Manage how your store charges tax"),icon: <Monetization fontSize="inherit" />,permission: PermissionEnum.MANAGE_PRODUCTS,- title: i18n.t("Taxes")+ title: i18n.t("Taxes"),+ url: taxSection},{description: i18n.t("Define how users can navigate through your store"),diff --git a/saleor/static/dashboard-next/index.tsx b/saleor/static/dashboard-next/index.tsxindex 16d60dcdc6..997e772407 100644--- a/saleor/static/dashboard-next/index.tsx+++ b/saleor/static/dashboard-next/index.tsx@@ -40,6 +40,7 @@ import ProductSection from "./products";import ProductTypesSection from "./productTypes";import SiteSettingsSection from "./siteSettings";import StaffSection from "./staff";+import TaxesSection from "./taxes";import theme from "./theme";import { PermissionEnum } from "./types/globalTypes";@@ -173,6 +174,11 @@ render(path="/site-settings"component={SiteSettingsSection}/>+ <SectionRoute+ permissions={[PermissionEnum.MANAGE_SETTINGS]}+ path="/taxes"+ component={TaxesSection}+ />{configurationMenu.filter(menuItem =>hasPermission(menuItem.permission, user)).length > 0 && (diff --git a/saleor/static/dashboard-next/taxes/components/CountryListPage/CountryListPage.tsx b/saleor/static/dashboard-next/taxes/components/CountryListPage/CountryListPage.tsxindex cbc954826e..bca5d5ccfc 100644--- a/saleor/static/dashboard-next/taxes/components/CountryListPage/CountryListPage.tsx+++ b/saleor/static/dashboard-next/taxes/components/CountryListPage/CountryListPage.tsx@@ -49,8 +49,8 @@ const CountryListPage = withStyles(styles, { name: "CountryListPage" })(const initialForm: FormData = {// chargeTaxesOnShipping: maybe(() => shop.chargeTaxesOnShipping),chargeTaxesOnShipping: false,- includeTax: maybe(() => shop.includeTaxesInPrices),- showGross: maybe(() => shop.displayGrossPrices)+ includeTax: maybe(() => shop.includeTaxesInPrices, false),+ showGross: maybe(() => shop.displayGrossPrices, false)};return (<Form initial={initialForm} onSubmit={onSubmit}>diff --git a/saleor/static/dashboard-next/taxes/index.tsx b/saleor/static/dashboard-next/taxes/index.tsxnew file mode 100644index 0000000000..b2c17ca043--- /dev/null+++ b/saleor/static/dashboard-next/taxes/index.tsx@@ -0,0 +1,18 @@+import * as React from "react";+import { Route, Switch } from "react-router-dom";++import { WindowTitle } from "../components/WindowTitle";+import i18n from "../i18n";+import { countryListPath } from "./urls";+import CountryList from "./views/CountryList";++const Component = () => (+ <>+ <WindowTitle title={i18n.t("Taxes")} />+ <Switch>+ <Route exact path={countryListPath} component={CountryList} />+ </Switch>+ </>+);++export default Component;diff --git a/saleor/static/dashboard-next/taxes/urls.ts b/saleor/static/dashboard-next/taxes/urls.tsnew file mode 100644index 0000000000..caedb736c4--- /dev/null+++ b/saleor/static/dashboard-next/taxes/urls.ts@@ -0,0 +1,9 @@+import * as urlJoin from "url-join";++export const taxSection = "/taxes/";++export const countryListPath = taxSection;+export const countryListUrl = taxSection;++export const countryTaxRatesPath = (code: string) => urlJoin(taxSection, code);+export const countryTaxRatesUrl = countryTaxRatesPath;diff --git a/saleor/static/dashboard-next/taxes/views/CountryList.tsx b/saleor/static/dashboard-next/taxes/views/CountryList.tsxnew file mode 100644index 0000000000..caaf77c33a--- /dev/null+++ b/saleor/static/dashboard-next/taxes/views/CountryList.tsx@@ -0,0 +1,29 @@+import * as React from "react";++import Navigator from "../../components/Navigator";+import { maybe } from "../../misc";+import CountryListPage from "../components/CountryListPage";+import { TypedCountryListQuery } from "../queries";+import { countryTaxRatesUrl } from "../urls";++export const CountryList: React.StatelessComponent = () => (+ <Navigator>+ {navigate => (+ <TypedCountryListQuery displayLoader={true}>+ {({ data, loading }) => (+ <CountryListPage+ disabled={loading}+ onRowClick={code => navigate(countryTaxRatesUrl(code))}+ onSubmit={() => undefined}+ onTaxFetch={() => undefined}+ shop={maybe(() => ({+ ...data.shop,+ countries: data.shop.countries.filter(country => country.vat)+ }))}+ />+ )}+ </TypedCountryListQuery>+ )}+ </Navigator>+);+export default CountryList;