Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Add shop provider
dominik-zeglen7ee99741cdd9
diff --git a/saleor/static/dashboard-next/components/Shop/Shop.tsx b/saleor/static/dashboard-next/components/Shop/Shop.tsxnew file mode 100644index 0000000000..12d257bc86--- /dev/null+++ b/saleor/static/dashboard-next/components/Shop/Shop.tsx@@ -0,0 +1,26 @@+import * as React from "react";++import { maybe } from "../../misc";+import { TypedShopInfoQuery } from "./query";+import { ShopInfo_shop } from "./types/ShopInfo";++type ShopContext = ShopInfo_shop;++export const shopContext = React.createContext<ShopContext>(undefined);++export const ShopProvider: React.StatelessComponent<{}> = ({ children }) => (+ <TypedShopInfoQuery>+ {({ data }) =>+ maybe(+ () => (+ <shopContext.Provider value={data.shop}>+ {children}+ </shopContext.Provider>+ ),+ children+ )+ }+ </TypedShopInfoQuery>+);+export const Shop = shopContext.Consumer;+export default Shop;diff --git a/saleor/static/dashboard-next/components/Shop/query.tsx b/saleor/static/dashboard-next/components/Shop/query.tsxnew file mode 100644index 0000000000..44d8e0ce9c--- /dev/null+++ b/saleor/static/dashboard-next/components/Shop/query.tsx@@ -0,0 +1,27 @@+import gql from "graphql-tag";+import * as React from "react";++import { TypedQuery } from "../../queries";+import { ShopInfo } from "./types/ShopInfo";++const shopInfo = gql`+ query ShopInfo {+ shop {+ defaultCountry {+ code+ country+ }+ defaultCurrency+ defaultWeightUnit+ displayGrossPrices+ domain {+ host+ url+ }+ includeTaxesInPrices+ name+ trackInventoryByDefault+ }+ }+`;+export const TypedShopInfoQuery = TypedQuery<ShopInfo, {}>(shopInfo);diff --git a/saleor/static/dashboard-next/components/Shop/types/ShopInfo.ts b/saleor/static/dashboard-next/components/Shop/types/ShopInfo.tsnew file mode 100644index 0000000000..d59dd0c64f--- /dev/null+++ b/saleor/static/dashboard-next/components/Shop/types/ShopInfo.ts@@ -0,0 +1,36 @@+/* tslint:disable */+// This file was automatically generated and should not be edited.++import { WeightUnitsEnum } from "./../../../types/globalTypes";++// ====================================================+// GraphQL query operation: ShopInfo+// ====================================================++export interface ShopInfo_shop_defaultCountry {+ __typename: "CountryDisplay";+ code: string;+ country: string;+}++export interface ShopInfo_shop_domain {+ __typename: "Domain";+ host: string;+ url: string;+}++export interface ShopInfo_shop {+ __typename: "Shop";+ defaultCountry: ShopInfo_shop_defaultCountry | null;+ defaultCurrency: string;+ defaultWeightUnit: WeightUnitsEnum | null;+ displayGrossPrices: boolean | null;+ domain: ShopInfo_shop_domain;+ includeTaxesInPrices: boolean | null;+ name: string;+ trackInventoryByDefault: boolean | null;+}++export interface ShopInfo {+ shop: ShopInfo_shop | null;+}diff --git a/saleor/static/dashboard-next/index.tsx b/saleor/static/dashboard-next/index.tsxindex e1a9362108..a488eb0efc 100644--- a/saleor/static/dashboard-next/index.tsx+++ b/saleor/static/dashboard-next/index.tsx@@ -21,6 +21,7 @@ import CollectionSection from "./collections";import { DateProvider } from "./components/DateFormatter";import { LocaleProvider } from "./components/Locale";import { MessageManager } from "./components/messages";+import { ShopProvider } from "./components/Shop/Shop";import ConfigurationSection, { configurationMenu } from "./configuration";import { CustomerSection } from "./customers";import HomePage from "./home";@@ -92,83 +93,85 @@ render(<DateProvider><LocaleProvider><MessageManager>- <CssBaseline />- <AuthProvider>- {({- hasToken,- isAuthenticated,- tokenAuthLoading,- tokenVerifyLoading,- user- }) => {- return isAuthenticated &&- !tokenAuthLoading &&- !tokenVerifyLoading ? (- <Switch>- <SectionRoute exact path="/" component={HomePage} />- <SectionRoute- permissions={[PermissionEnum.MANAGE_PRODUCTS]}- path="/categories"- component={CategorySection}- />- <SectionRoute- permissions={[PermissionEnum.MANAGE_PRODUCTS]}- path="/collections"- component={CollectionSection}- />- <SectionRoute- permissions={[PermissionEnum.MANAGE_USERS]}- path="/customers"- component={CustomerSection}- />- <SectionRoute- permissions={[PermissionEnum.MANAGE_PAGES]}- path="/pages"- component={PageSection}- />- <SectionRoute- permissions={[PermissionEnum.MANAGE_ORDERS]}- path="/orders"- component={OrdersSection}- />- <SectionRoute- permissions={[PermissionEnum.MANAGE_PRODUCTS]}- path="/products"- component={ProductSection}- />- <SectionRoute- permissions={[PermissionEnum.MANAGE_PRODUCTS]}- path="/productTypes"- component={ProductTypesSection}- />- <SectionRoute- permissions={[PermissionEnum.MANAGE_STAFF]}- path="/staff"- component={StaffSection}- />- <SectionRoute- permissions={[PermissionEnum.MANAGE_SETTINGS]}- path="/siteSettings"- component={SiteSettingsSection}- />- {configurationMenu.filter(menuItem =>- hasPermission(menuItem.permission, user)- ).length > 0 && (+ <ShopProvider>+ <CssBaseline />+ <AuthProvider>+ {({+ hasToken,+ isAuthenticated,+ tokenAuthLoading,+ tokenVerifyLoading,+ user+ }) => {+ return isAuthenticated &&+ !tokenAuthLoading &&+ !tokenVerifyLoading ? (+ <Switch>+ <SectionRoute exact path="/" component={HomePage} /><SectionRoute- exact- path="/configuration"- component={ConfigurationSection}+ permissions={[PermissionEnum.MANAGE_PRODUCTS]}+ path="/categories"+ component={CategorySection}/>- )}- <Route component={NotFound} />- </Switch>- ) : hasToken && tokenVerifyLoading ? (- <LoginLoading />- ) : (- <Auth loading={tokenAuthLoading} />- );- }}- </AuthProvider>+ <SectionRoute+ permissions={[PermissionEnum.MANAGE_PRODUCTS]}+ path="/collections"+ component={CollectionSection}+ />+ <SectionRoute+ permissions={[PermissionEnum.MANAGE_USERS]}+ path="/customers"+ component={CustomerSection}+ />+ <SectionRoute+ permissions={[PermissionEnum.MANAGE_PAGES]}+ path="/pages"+ component={PageSection}+ />+ <SectionRoute+ permissions={[PermissionEnum.MANAGE_ORDERS]}+ path="/orders"+ component={OrdersSection}+ />+ <SectionRoute+ permissions={[PermissionEnum.MANAGE_PRODUCTS]}+ path="/products"+ component={ProductSection}+ />+ <SectionRoute+ permissions={[PermissionEnum.MANAGE_PRODUCTS]}+ path="/productTypes"+ component={ProductTypesSection}+ />+ <SectionRoute+ permissions={[PermissionEnum.MANAGE_STAFF]}+ path="/staff"+ component={StaffSection}+ />+ <SectionRoute+ permissions={[PermissionEnum.MANAGE_SETTINGS]}+ path="/siteSettings"+ component={SiteSettingsSection}+ />+ {configurationMenu.filter(menuItem =>+ hasPermission(menuItem.permission, user)+ ).length > 0 && (+ <SectionRoute+ exact+ path="/configuration"+ component={ConfigurationSection}+ />+ )}+ <Route component={NotFound} />+ </Switch>+ ) : hasToken && tokenVerifyLoading ? (+ <LoginLoading />+ ) : (+ <Auth loading={tokenAuthLoading} />+ );+ }}+ </AuthProvider>+ </ShopProvider></MessageManager></LocaleProvider></DateProvider>diff --git a/saleor/static/dashboard-next/orders/types/OrderDetails.ts b/saleor/static/dashboard-next/orders/types/OrderDetails.tsindex fe0f1a39cf..01378c815c 100644--- a/saleor/static/dashboard-next/orders/types/OrderDetails.ts+++ b/saleor/static/dashboard-next/orders/types/OrderDetails.ts@@ -1,15 +1,7 @@/* tslint:disable */// This file was automatically generated and should not be edited.-import {- OrderEventsEmails,- OrderEvents,- FulfillmentStatus,- PaymentChargeStatusEnum,- OrderStatus,- OrderAction,- WeightUnitsEnum-} from "./../../types/globalTypes";+import { OrderEventsEmails, OrderEvents, FulfillmentStatus, PaymentChargeStatusEnum, OrderStatus, OrderAction, WeightUnitsEnum } from "./../../types/globalTypes";// ====================================================// GraphQL query operation: OrderDetails@@ -259,9 +251,7 @@ export interface OrderDetails_order {totalCaptured: OrderDetails_order_totalCaptured | null;user: OrderDetails_order_user | null;userEmail: string | null;- availableShippingMethods:- | (OrderDetails_order_availableShippingMethods | null)[]- | null;+ availableShippingMethods: (OrderDetails_order_availableShippingMethods | null)[] | null;}export interface OrderDetails_shop_countries {