Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Add language switch
dominik-zeglen4f44e5968438
diff --git a/saleor/static/dashboard-next/components/LanguageSwitch/LanguageSwitch.tsx b/saleor/static/dashboard-next/components/LanguageSwitch/LanguageSwitch.tsxnew file mode 100644index 0000000000..1305816546--- /dev/null+++ b/saleor/static/dashboard-next/components/LanguageSwitch/LanguageSwitch.tsx@@ -0,0 +1,127 @@+import Card from "@material-ui/core/Card";+import ClickAwayListener from "@material-ui/core/ClickAwayListener";+import Grow from "@material-ui/core/Grow";+import MenuItem from "@material-ui/core/MenuItem";+import Menu from "@material-ui/core/MenuList";+import Paper from "@material-ui/core/Paper";+import Popper from "@material-ui/core/Popper";+import {+ createStyles,+ Theme,+ withStyles,+ WithStyles+} from "@material-ui/core/styles";+import Typography from "@material-ui/core/Typography";+import ArrowDropdown from "@material-ui/icons/ArrowDropdown";+import classNames from "classnames";+import * as React from "react";++import i18n from "../../i18n";+import { LanguageCodeEnum } from "../../types/globalTypes";+import { ShopInfo_shop_languages } from "../Shop/types/ShopInfo";++export interface LanguageSwitchProps {+ currentLanguage: LanguageCodeEnum;+ languages: ShopInfo_shop_languages[];+ onLanguageChange: (lang: LanguageCodeEnum) => void;+}++const styles = (theme: Theme) =>+ createStyles({+ arrow: {+ color: theme.palette.primary.main,+ transition: theme.transitions.duration.standard + "ms"+ },+ container: {+ paddingBottom: theme.spacing.unit+ },+ menuContainer: {+ cursor: "pointer",+ display: "flex",+ justifyContent: "space-between",+ minWidth: 90,+ padding: theme.spacing.unit,+ position: "relative"+ },+ menuItem: {+ textAlign: "justify"+ },+ popover: {+ zIndex: 1+ },+ rotate: {+ transform: "rotate(180deg)"+ }+ });+const LanguageSwitch = withStyles(styles, { name: "LanguageSwitch" })(+ ({+ classes,+ currentLanguage,+ languages,+ onLanguageChange+ }: LanguageSwitchProps & WithStyles<typeof styles>) => {+ const [isExpanded, setExpandedState] = React.useState(false);+ const anchor = React.useRef();++ return (+ <div className={classes.container} ref={anchor}>+ <Card+ className={classes.menuContainer}+ onClick={() => setExpandedState(!isExpanded)}+ >+ <Typography>{currentLanguage}</Typography>+ <ArrowDropdown+ className={classNames(classes.arrow, {+ [classes.rotate]: isExpanded+ })}+ />+ </Card>+ <Popper+ className={classes.popover}+ open={isExpanded}+ anchorEl={anchor.current}+ transition+ disablePortal+ placement="bottom-end"+ >+ {({ TransitionProps, placement }) => (+ <Grow+ {...TransitionProps}+ style={{+ transformOrigin:+ placement === "bottom" ? "right top" : "right bottom"+ }}+ >+ <Paper>+ <ClickAwayListener+ onClickAway={() => setExpandedState(false)}+ mouseEvent="onClick"+ >+ {languages.map(lang => (+ <Menu>+ <MenuItem+ className={classes.menuItem}+ onClick={() => {+ setExpandedState(false);+ onLanguageChange(lang.code);+ }}+ >+ {i18n.t("{{ languageName }} - {{ languageCode }}", {+ context: "button",+ languageCode: lang.code,+ languageName: lang.language+ })}+ </MenuItem>+ </Menu>+ ))}+ </ClickAwayListener>+ </Paper>+ </Grow>+ )}+ </Popper>+ </div>+ );+ }+);+LanguageSwitch.displayName = "LanguageSwitch";+export default LanguageSwitch;diff --git a/saleor/static/dashboard-next/components/LanguageSwitch/index.ts b/saleor/static/dashboard-next/components/LanguageSwitch/index.tsnew file mode 100644index 0000000000..4c425527ec--- /dev/null+++ b/saleor/static/dashboard-next/components/LanguageSwitch/index.ts@@ -0,0 +1,2 @@+export { default } from './LanguageSwitch';+export * from './LanguageSwitch';\ No newline at end of filediff --git a/saleor/static/dashboard-next/translations/components/TranslationsCategoriesPage/TranslationsCategoriesPage.tsx b/saleor/static/dashboard-next/translations/components/TranslationsCategoriesPage/TranslationsCategoriesPage.tsxindex 924c7c96ba..e9a6b7ada2 100644--- a/saleor/static/dashboard-next/translations/components/TranslationsCategoriesPage/TranslationsCategoriesPage.tsx+++ b/saleor/static/dashboard-next/translations/components/TranslationsCategoriesPage/TranslationsCategoriesPage.tsx@@ -2,23 +2,19 @@ import * as React from "react";import AppHeader from "../../../components/AppHeader";import CardSpacer from "../../../components/CardSpacer";-import { ConfirmButtonTransitionState } from "../../../components/ConfirmButton";import Container from "../../../components/Container";+import LanguageSwitch from "../../../components/LanguageSwitch";import PageHeader from "../../../components/PageHeader";import i18n from "../../../i18n";import { maybe } from "../../../misc";+import { LanguageCodeEnum } from "../../../types/globalTypes";import { CategoryTranslationFragment } from "../../types/CategoryTranslationFragment";+import { TranslationsEntitiesPageProps } from "../../types/TranslationsEntitiesPage";import TranslationFields from "../TranslationFields";-export interface TranslationsCategoriesPageProps {- activeField: string;- disabled: boolean;- languageCode: string;+export interface TranslationsCategoriesPageProps+ extends TranslationsEntitiesPageProps {category: CategoryTranslationFragment;- saveButtonState: ConfirmButtonTransitionState;- onBack: () => void;- onEdit: (field: string) => void;- onSubmit: (field: string, data: string) => void;}export const fieldNames = {@@ -34,10 +30,12 @@ const TranslationsCategoriesPage: React.StatelessComponent<activeField,disabled,languageCode,+ languages,category,saveButtonState,onBack,onEdit,+ onLanguageChange,onSubmit}) => (<Container>@@ -51,7 +49,13 @@ const TranslationsCategoriesPage: React.StatelessComponent<languageCode})}- />+ >+ <LanguageSwitch+ currentLanguage={LanguageCodeEnum[languageCode]}+ languages={languages}+ onLanguageChange={onLanguageChange}+ />+ </PageHeader><TranslationFieldsactiveField={activeField}disabled={disabled}diff --git a/saleor/static/dashboard-next/translations/components/TranslationsCollectionsPage/TranslationsCollectionsPage.tsx b/saleor/static/dashboard-next/translations/components/TranslationsCollectionsPage/TranslationsCollectionsPage.tsxindex 28457c8778..ba163f80b3 100644--- a/saleor/static/dashboard-next/translations/components/TranslationsCollectionsPage/TranslationsCollectionsPage.tsx+++ b/saleor/static/dashboard-next/translations/components/TranslationsCollectionsPage/TranslationsCollectionsPage.tsx@@ -2,23 +2,19 @@ import * as React from "react";import AppHeader from "../../../components/AppHeader";import CardSpacer from "../../../components/CardSpacer";-import { ConfirmButtonTransitionState } from "../../../components/ConfirmButton";import Container from "../../../components/Container";+import LanguageSwitch from "../../../components/LanguageSwitch";import PageHeader from "../../../components/PageHeader";import i18n from "../../../i18n";import { maybe } from "../../../misc";+import { LanguageCodeEnum } from "../../../types/globalTypes";import { CollectionTranslationFragment } from "../../types/CollectionTranslationFragment";+import { TranslationsEntitiesPageProps } from "../../types/TranslationsEntitiesPage";import TranslationFields from "../TranslationFields";-export interface TranslationsCollectionsPageProps {- activeField: string;- disabled: boolean;- languageCode: string;+export interface TranslationsCollectionsPageProps+ extends TranslationsEntitiesPageProps {collection: CollectionTranslationFragment;- saveButtonState: ConfirmButtonTransitionState;- onBack: () => void;- onEdit: (field: string) => void;- onSubmit: (field: string, data: string) => void;}export const fieldNames = {@@ -34,10 +30,12 @@ const TranslationsCollectionsPage: React.StatelessComponent<activeField,disabled,languageCode,+ languages,collection,saveButtonState,onBack,onEdit,+ onLanguageChange,onSubmit}) => (<Container>@@ -51,7 +49,13 @@ const TranslationsCollectionsPage: React.StatelessComponent<languageCode})}- />+ >+ <LanguageSwitch+ currentLanguage={LanguageCodeEnum[languageCode]}+ languages={languages}+ onLanguageChange={onLanguageChange}+ />+ </PageHeader><TranslationFieldsactiveField={activeField}disabled={disabled}diff --git a/saleor/static/dashboard-next/translations/components/TranslationsPagesPage/TranslationsPagesPage.tsx b/saleor/static/dashboard-next/translations/components/TranslationsPagesPage/TranslationsPagesPage.tsxindex 59e43169c2..2ddb6aec7d 100644--- a/saleor/static/dashboard-next/translations/components/TranslationsPagesPage/TranslationsPagesPage.tsx+++ b/saleor/static/dashboard-next/translations/components/TranslationsPagesPage/TranslationsPagesPage.tsx@@ -2,23 +2,19 @@ import * as React from "react";import AppHeader from "../../../components/AppHeader";import CardSpacer from "../../../components/CardSpacer";-import { ConfirmButtonTransitionState } from "../../../components/ConfirmButton";import Container from "../../../components/Container";+import LanguageSwitch from "../../../components/LanguageSwitch";import PageHeader from "../../../components/PageHeader";import i18n from "../../../i18n";import { maybe } from "../../../misc";+import { LanguageCodeEnum } from "../../../types/globalTypes";import { PageTranslationFragment } from "../../types/PageTranslationFragment";+import { TranslationsEntitiesPageProps } from "../../types/TranslationsEntitiesPage";import TranslationFields from "../TranslationFields";-export interface TranslationsPagesPageProps {- activeField: string;- disabled: boolean;- languageCode: string;+export interface TranslationsPagesPageProps+ extends TranslationsEntitiesPageProps {page: PageTranslationFragment;- saveButtonState: ConfirmButtonTransitionState;- onBack: () => void;- onEdit: (field: string) => void;- onSubmit: (field: string, data: string) => void;}export const fieldNames = {@@ -34,10 +30,12 @@ const TranslationsPagesPage: React.StatelessComponent<activeField,disabled,languageCode,+ languages,page,saveButtonState,onBack,onEdit,+ onLanguageChange,onSubmit}) => (<Container>@@ -48,7 +46,13 @@ const TranslationsPagesPage: React.StatelessComponent<languageCode,pageName: maybe(() => page.title, "...")})}- />+ >+ <LanguageSwitch+ currentLanguage={LanguageCodeEnum[languageCode]}+ languages={languages}+ onLanguageChange={onLanguageChange}+ />+ </PageHeader><TranslationFieldsactiveField={activeField}disabled={disabled}diff --git a/saleor/static/dashboard-next/translations/components/TranslationsProductTypesPage/TranslationsProductTypesPage.tsx b/saleor/static/dashboard-next/translations/components/TranslationsProductTypesPage/TranslationsProductTypesPage.tsxindex 303202c903..e0701e8339 100644--- a/saleor/static/dashboard-next/translations/components/TranslationsProductTypesPage/TranslationsProductTypesPage.tsx+++ b/saleor/static/dashboard-next/translations/components/TranslationsProductTypesPage/TranslationsProductTypesPage.tsx@@ -2,23 +2,19 @@ import * as React from "react";import AppHeader from "../../../components/AppHeader";import CardSpacer from "../../../components/CardSpacer";-import { ConfirmButtonTransitionState } from "../../../components/ConfirmButton";import Container from "../../../components/Container";+import LanguageSwitch from "../../../components/LanguageSwitch";import PageHeader from "../../../components/PageHeader";import i18n from "../../../i18n";import { maybe } from "../../../misc";+import { LanguageCodeEnum } from "../../../types/globalTypes";import { ProductTypeTranslationFragment } from "../../types/ProductTypeTranslationFragment";+import { TranslationsEntitiesPageProps } from "../../types/TranslationsEntitiesPage";import TranslationFields from "../TranslationFields";-export interface TranslationsProductTypesPageProps {- activeField: string;- disabled: boolean;- languageCode: string;+export interface TranslationsProductTypesPageProps+ extends TranslationsEntitiesPageProps {productType: ProductTypeTranslationFragment;- saveButtonState: ConfirmButtonTransitionState;- onBack: () => void;- onEdit: (field: string) => void;- onSubmit: (field: string, data: string) => void;}export const fieldNames = {@@ -31,11 +27,13 @@ const TranslationsProductTypesPage: React.StatelessComponent<> = ({activeField,disabled,+ languages,languageCode,productType,saveButtonState,onBack,onEdit,+ onLanguageChange,onSubmit}) => (<Container>@@ -49,7 +47,13 @@ const TranslationsProductTypesPage: React.StatelessComponent<productTypeName: maybe(() => productType.name, "...")})}- />+ >+ <LanguageSwitch+ currentLanguage={LanguageCodeEnum[languageCode]}+ languages={languages}+ onLanguageChange={onLanguageChange}+ />+ </PageHeader>{maybe(() => productType.productAttributes, []).map((attribute, attributeIndex) => (<>diff --git a/saleor/static/dashboard-next/translations/components/TranslationsProductsPage/TranslationsProductsPage.tsx b/saleor/static/dashboard-next/translations/components/TranslationsProductsPage/TranslationsProductsPage.tsxindex 96bebd052a..dc3092243a 100644--- a/saleor/static/dashboard-next/translations/components/TranslationsProductsPage/TranslationsProductsPage.tsx+++ b/saleor/static/dashboard-next/translations/components/TranslationsProductsPage/TranslationsProductsPage.tsx@@ -2,23 +2,19 @@ import * as React from "react";import AppHeader from "../../../components/AppHeader";import CardSpacer from "../../../components/CardSpacer";-import { ConfirmButtonTransitionState } from "../../../components/ConfirmButton";import Container from "../../../components/Container";+import LanguageSwitch from "../../../components/LanguageSwitch";import PageHeader from "../../../components/PageHeader";import i18n from "../../../i18n";import { maybe } from "../../../misc";+import { LanguageCodeEnum } from "../../../types/globalTypes";import { ProductTranslationFragment } from "../../types/ProductTranslationFragment";+import { TranslationsEntitiesPageProps } from "../../types/TranslationsEntitiesPage";import TranslationFields from "../TranslationFields";-export interface TranslationsProductsPageProps {- activeField: string;- disabled: boolean;- languageCode: string;+export interface TranslationsProductsPageProps+ extends TranslationsEntitiesPageProps {product: ProductTranslationFragment;- saveButtonState: ConfirmButtonTransitionState;- onBack: () => void;- onEdit: (field: string) => void;- onSubmit: (field: string, data: string) => void;}export const fieldNames = {@@ -34,10 +30,12 @@ const TranslationsProductsPage: React.StatelessComponent<activeField,disabled,languageCode,+ languages,product,saveButtonState,onBack,onEdit,+ onLanguageChange,onSubmit}) => (<Container>@@ -51,7 +49,13 @@ const TranslationsProductsPage: React.StatelessComponent<productName: maybe(() => product.name, "...")})}- />+ >+ <LanguageSwitch+ currentLanguage={LanguageCodeEnum[languageCode]}+ languages={languages}+ onLanguageChange={onLanguageChange}+ />+ </PageHeader><TranslationFieldsactiveField={activeField}disabled={disabled}diff --git a/saleor/static/dashboard-next/translations/components/TranslationsSalesPage/TranslationsSalesPage.tsx b/saleor/static/dashboard-next/translations/components/TranslationsSalesPage/TranslationsSalesPage.tsxindex 047c2dc3c5..bc2fe0f5cf 100644--- a/saleor/static/dashboard-next/translations/components/TranslationsSalesPage/TranslationsSalesPage.tsx+++ b/saleor/static/dashboard-next/translations/components/TranslationsSalesPage/TranslationsSalesPage.tsx@@ -1,23 +1,19 @@import * as React from "react";-import { ConfirmButtonTransitionState } from "../../../components/ConfirmButton";+import AppHeader from "../../../components/AppHeader";import Container from "../../../components/Container";+import LanguageSwitch from "../../../components/LanguageSwitch";import PageHeader from "../../../components/PageHeader";import i18n from "../../../i18n";import { maybe } from "../../../misc";+import { LanguageCodeEnum } from "../../../types/globalTypes";import { SaleTranslationFragment } from "../../types/SaleTranslationFragment";+import { TranslationsEntitiesPageProps } from "../../types/TranslationsEntitiesPage";import TranslationFields from "../TranslationFields";-import AppHeader from "../../../components/AppHeader";-export interface TranslationsSalesPageProps {- activeField: string;- disabled: boolean;- languageCode: string;+export interface TranslationsSalesPageProps+ extends TranslationsEntitiesPageProps {sale: SaleTranslationFragment;- saveButtonState: ConfirmButtonTransitionState;- onBack: () => void;- onEdit: (field: string) => void;- onSubmit: (field: string, data: string) => void;}export const fieldNames = {@@ -30,10 +26,12 @@ const TranslationsSalesPage: React.StatelessComponent<activeField,disabled,languageCode,+ languages,sale,saveButtonState,onBack,onEdit,+ onLanguageChange,onSubmit}) => (<Container>@@ -44,7 +42,13 @@ const TranslationsSalesPage: React.StatelessComponent<languageCode,saleName: maybe(() => sale.name, "...")})}- />+ >+ <LanguageSwitch+ currentLanguage={LanguageCodeEnum[languageCode]}+ languages={languages}+ onLanguageChange={onLanguageChange}+ />+ </PageHeader><TranslationFieldsactiveField={activeField}disabled={disabled}diff --git a/saleor/static/dashboard-next/translations/components/TranslationsVouchersPage/TranslationsVouchersPage.tsx b/saleor/static/dashboard-next/translations/components/TranslationsVouchersPage/TranslationsVouchersPage.tsxindex 217c3e3201..73bbecdb2d 100644--- a/saleor/static/dashboard-next/translations/components/TranslationsVouchersPage/TranslationsVouchersPage.tsx+++ b/saleor/static/dashboard-next/translations/components/TranslationsVouchersPage/TranslationsVouchersPage.tsx@@ -1,23 +1,19 @@import * as React from "react";import AppHeader from "../../../components/AppHeader";-import { ConfirmButtonTransitionState } from "../../../components/ConfirmButton";import Container from "../../../components/Container";+import LanguageSwitch from "../../../components/LanguageSwitch";import PageHeader from "../../../components/PageHeader";import i18n from "../../../i18n";import { maybe } from "../../../misc";+import { LanguageCodeEnum } from "../../../types/globalTypes";+import { TranslationsEntitiesPageProps } from "../../types/TranslationsEntitiesPage";import { VoucherTranslationFragment } from "../../types/VoucherTranslationFragment";import TranslationFields from "../TranslationFields";-export interface TranslationsVouchersPageProps {- activeField: string;- disabled: boolean;- languageCode: string;+export interface TranslationsVouchersPageProps+ extends TranslationsEntitiesPageProps {voucher: VoucherTranslationFragment;- saveButtonState: ConfirmButtonTransitionState;- onBack: () => void;- onEdit: (field: string) => void;- onSubmit: (field: string, data: string) => void;}export const fieldNames = {@@ -29,11 +25,13 @@ const TranslationsVouchersPage: React.StatelessComponent<> = ({activeField,disabled,+ languages,languageCode,voucher,saveButtonState,onBack,onEdit,+ onLanguageChange,onSubmit}) => (<Container>@@ -47,7 +45,13 @@ const TranslationsVouchersPage: React.StatelessComponent<voucherName: maybe(() => voucher.name, "...")})}- />+ >+ <LanguageSwitch+ currentLanguage={LanguageCodeEnum[languageCode]}+ languages={languages}+ onLanguageChange={onLanguageChange}+ />+ </PageHeader><TranslationFieldsactiveField={activeField}disabled={disabled}diff --git a/saleor/static/dashboard-next/translations/types/TranslationsEntitiesPage.ts b/saleor/static/dashboard-next/translations/types/TranslationsEntitiesPage.tsnew file mode 100644index 0000000000..454c2dca42--- /dev/null+++ b/saleor/static/dashboard-next/translations/types/TranslationsEntitiesPage.ts@@ -0,0 +1,14 @@+import { ConfirmButtonTransitionState } from "../../components/ConfirmButton";+import { ShopInfo_shop_languages } from "../../components/Shop/types/ShopInfo";++export interface TranslationsEntitiesPageProps {+ activeField: string;+ disabled: boolean;+ languageCode: string;+ languages: ShopInfo_shop_languages[];+ saveButtonState: ConfirmButtonTransitionState;+ onBack: () => void;+ onEdit: (field: string) => void;+ onLanguageChange: (lang: string) => void;+ onSubmit: (field: string, data: string) => void;+}diff --git a/saleor/static/dashboard-next/translations/views/TranslationsCategories.tsx b/saleor/static/dashboard-next/translations/views/TranslationsCategories.tsxindex 7142245914..4070968e54 100644--- a/saleor/static/dashboard-next/translations/views/TranslationsCategories.tsx+++ b/saleor/static/dashboard-next/translations/views/TranslationsCategories.tsx@@ -3,6 +3,7 @@ import * as React from "react";import useNavigator from "../../hooks/useNavigator";import useNotifier from "../../hooks/useNotifier";+import useShop from "../../hooks/useShop";import i18n from "../../i18n";import { getMutationState, maybe } from "../../misc";import { LanguageCodeEnum, TranslationInput } from "../../types/globalTypes";@@ -12,7 +13,11 @@ import TranslationsCategoriesPage, {import { TypedUpdateCategoryTranslations } from "../mutations";import { TypedCategoryTranslationDetails } from "../queries";import { UpdateCategoryTranslations } from "../types/UpdateCategoryTranslations";-import { languageEntitiesUrl, TranslatableEntities } from "../urls";+import {+ languageEntitiesUrl,+ languageEntityUrl,+ TranslatableEntities+} from "../urls";export interface TranslationsCategoriesQueryParams {activeField: string;@@ -30,6 +35,7 @@ const TranslationsCategories: React.FC<TranslationsCategoriesProps> = ({}) => {const navigate = useNavigator();const notify = useNotifier();+ const shop = useShop();const onEdit = (field: string) =>navigate(@@ -89,6 +95,7 @@ const TranslationsCategories: React.FC<TranslationsCategoriesProps> = ({categoryTranslations.loading || updateTranslationsOpts.loading}languageCode={languageCode}+ languages={maybe(() => shop.languages, [])}saveButtonState={saveButtonState}onBack={() =>navigate(@@ -99,6 +106,11 @@ const TranslationsCategories: React.FC<TranslationsCategoriesProps> = ({)}onEdit={onEdit}+ onLanguageChange={lang =>+ navigate(+ languageEntityUrl(lang, TranslatableEntities.categories, id)+ )+ }onSubmit={handleSubmit}category={maybe(() => categoryTranslations.data.category)}/>diff --git a/saleor/static/dashboard-next/translations/views/TranslationsCollections.tsx b/saleor/static/dashboard-next/translations/views/TranslationsCollections.tsxindex 987eeb196c..d9c9ef4f8d 100644--- a/saleor/static/dashboard-next/translations/views/TranslationsCollections.tsx+++ b/saleor/static/dashboard-next/translations/views/TranslationsCollections.tsx@@ -3,6 +3,7 @@ import * as React from "react";import useNavigator from "../../hooks/useNavigator";import useNotifier from "../../hooks/useNotifier";+import useShop from "../../hooks/useShop";import i18n from "../../i18n";import { getMutationState, maybe } from "../../misc";import { LanguageCodeEnum, TranslationInput } from "../../types/globalTypes";@@ -12,7 +13,11 @@ import TranslationsCollectionsPage, {import { TypedUpdateCollectionTranslations } from "../mutations";import { TypedCollectionTranslationDetails } from "../queries";import { UpdateCollectionTranslations } from "../types/UpdateCollectionTranslations";-import { languageEntitiesUrl, TranslatableEntities } from "../urls";+import {+ languageEntitiesUrl,+ languageEntityUrl,+ TranslatableEntities+} from "../urls";export interface TranslationsCollectionsQueryParams {activeField: string;@@ -30,6 +35,7 @@ const TranslationsCollections: React.FC<TranslationsCollectionsProps> = ({}) => {const navigate = useNavigator();const notify = useNotifier();+ const shop = useShop();const onEdit = (field: string) =>navigate(@@ -92,6 +98,7 @@ const TranslationsCollections: React.FC<TranslationsCollectionsProps> = ({updateTranslationsOpts.loading}languageCode={languageCode}+ languages={maybe(() => shop.languages, [])}saveButtonState={saveButtonState}onEdit={onEdit}onBack={() =>@@ -102,6 +109,15 @@ const TranslationsCollections: React.FC<TranslationsCollectionsProps> = ({))}+ onLanguageChange={lang =>+ navigate(+ languageEntityUrl(+ lang,+ TranslatableEntities.collections,+ id+ )+ )+ }onSubmit={handleSubmit}collection={maybe(() => collectionTranslations.data.collection)}/>diff --git a/saleor/static/dashboard-next/translations/views/TranslationsPages.tsx b/saleor/static/dashboard-next/translations/views/TranslationsPages.tsxindex 3b88d952ae..e09af3488c 100644--- a/saleor/static/dashboard-next/translations/views/TranslationsPages.tsx+++ b/saleor/static/dashboard-next/translations/views/TranslationsPages.tsx@@ -3,6 +3,7 @@ import * as React from "react";import useNavigator from "../../hooks/useNavigator";import useNotifier from "../../hooks/useNotifier";+import useShop from "../../hooks/useShop";import i18n from "../../i18n";import { getMutationState, maybe } from "../../misc";import {@@ -15,7 +16,11 @@ import TranslationsPagesPage, {import { TypedUpdatePageTranslations } from "../mutations";import { TypedPageTranslationDetails } from "../queries";import { UpdatePageTranslations } from "../types/UpdatePageTranslations";-import { languageEntitiesUrl, TranslatableEntities } from "../urls";+import {+ languageEntitiesUrl,+ languageEntityUrl,+ TranslatableEntities+} from "../urls";export interface TranslationsPagesQueryParams {activeField: string;@@ -33,6 +38,7 @@ const TranslationsPages: React.FC<TranslationsPagesProps> = ({}) => {const navigate = useNavigator();const notify = useNotifier();+ const shop = useShop();const onEdit = (field: string) =>navigate(@@ -89,6 +95,7 @@ const TranslationsPages: React.FC<TranslationsPagesProps> = ({pageTranslations.loading || updateTranslationsOpts.loading}languageCode={languageCode}+ languages={maybe(() => shop.languages, [])}saveButtonState={saveButtonState}onBack={() =>navigate(@@ -99,6 +106,11 @@ const TranslationsPages: React.FC<TranslationsPagesProps> = ({)}onEdit={onEdit}+ onLanguageChange={lang =>+ navigate(+ languageEntityUrl(lang, TranslatableEntities.pages, id)+ )+ }onSubmit={handleSubmit}page={maybe(() => pageTranslations.data.page)}/>diff --git a/saleor/static/dashboard-next/translations/views/TranslationsProductTypes.tsx b/saleor/static/dashboard-next/translations/views/TranslationsProductTypes.tsxindex abee6432c9..a035a3e2f1 100644--- a/saleor/static/dashboard-next/translations/views/TranslationsProductTypes.tsx+++ b/saleor/static/dashboard-next/translations/views/TranslationsProductTypes.tsx@@ -3,6 +3,7 @@ import * as React from "react";import useNavigator from "../../hooks/useNavigator";import useNotifier from "../../hooks/useNotifier";+import useShop from "../../hooks/useShop";import i18n from "../../i18n";import { getMutationState, maybe } from "../../misc";import {@@ -19,7 +20,11 @@ import {import { TypedProductTypeTranslationDetails } from "../queries";import { UpdateAttributeTranslations } from "../types/UpdateAttributeTranslations";import { UpdateAttributeValueTranslations } from "../types/UpdateAttributeValueTranslations";-import { languageEntitiesUrl, TranslatableEntities } from "../urls";+import {+ languageEntitiesUrl,+ languageEntityUrl,+ TranslatableEntities+} from "../urls";export interface TranslationsProductTypesQueryParams {activeField: string;@@ -37,6 +42,7 @@ const TranslationsProductTypes: React.FC<TranslationsProductTypesProps> = ({}) => {const navigate = useNavigator();const notify = useNotifier();+ const shop = useShop();const onEdit = (field: string) =>navigate(@@ -129,6 +135,7 @@ const TranslationsProductTypes: React.FC<TranslationsProductTypesProps> = ({updateAttributeValueTranslationsOpts.loading}languageCode={languageCode}+ languages={maybe(() => shop.languages, [])}saveButtonState={saveButtonState}onBack={() =>navigate(@@ -139,6 +146,15 @@ const TranslationsProductTypes: React.FC<TranslationsProductTypesProps> = ({)}onEdit={onEdit}+ onLanguageChange={lang =>+ navigate(+ languageEntityUrl(+ lang,+ TranslatableEntities.productTypes,+ id+ )+ )+ }onSubmit={handleSubmit}productType={maybe(() => collectionTranslations.data.productTypediff --git a/saleor/static/dashboard-next/translations/views/TranslationsProducts.tsx b/saleor/static/dashboard-next/translations/views/TranslationsProducts.tsxindex eb9ffeb634..4381a84b0f 100644--- a/saleor/static/dashboard-next/translations/views/TranslationsProducts.tsx+++ b/saleor/static/dashboard-next/translations/views/TranslationsProducts.tsx@@ -3,6 +3,7 @@ import * as React from "react";import useNavigator from "../../hooks/useNavigator";import useNotifier from "../../hooks/useNotifier";+import useShop from "../../hooks/useShop";import i18n from "../../i18n";import { getMutationState, maybe } from "../../misc";import { LanguageCodeEnum, TranslationInput } from "../../types/globalTypes";@@ -12,7 +13,11 @@ import TranslationsProductsPage, {import { TypedUpdateProductTranslations } from "../mutations";import { TypedProductTranslationDetails } from "../queries";import { UpdateProductTranslations } from "../types/UpdateProductTranslations";-import { languageEntitiesUrl, TranslatableEntities } from "../urls";+import {+ languageEntitiesUrl,+ languageEntityUrl,+ TranslatableEntities+} from "../urls";export interface TranslationsProductsQueryParams {activeField: string;@@ -30,6 +35,7 @@ const TranslationsProducts: React.FC<TranslationsProductsProps> = ({}) => {const navigate = useNavigator();const notify = useNotifier();+ const shop = useShop();const onEdit = (field: string) =>navigate(@@ -89,6 +95,7 @@ const TranslationsProducts: React.FC<TranslationsProductsProps> = ({productTranslations.loading || updateTranslationsOpts.loading}languageCode={languageCode}+ languages={maybe(() => shop.languages, [])}saveButtonState={saveButtonState}onBack={() =>navigate(@@ -99,6 +106,11 @@ const TranslationsProducts: React.FC<TranslationsProductsProps> = ({)}onEdit={onEdit}+ onLanguageChange={lang =>+ navigate(+ languageEntityUrl(lang, TranslatableEntities.products, id)+ )+ }onSubmit={handleSubmit}product={maybe(() => productTranslations.data.product)}/>diff --git a/saleor/static/dashboard-next/translations/views/TranslationsSales.tsx b/saleor/static/dashboard-next/translations/views/TranslationsSales.tsxindex 17a777c90f..5183947c0d 100644--- a/saleor/static/dashboard-next/translations/views/TranslationsSales.tsx+++ b/saleor/static/dashboard-next/translations/views/TranslationsSales.tsx@@ -3,6 +3,7 @@ import * as React from "react";import useNavigator from "../../hooks/useNavigator";import useNotifier from "../../hooks/useNotifier";+import useShop from "../../hooks/useShop";import i18n from "../../i18n";import { getMutationState, maybe } from "../../misc";import {@@ -15,7 +16,11 @@ import TranslationsSalesPage, {import { TypedUpdateSaleTranslations } from "../mutations";import { TypedSaleTranslationDetails } from "../queries";import { UpdateSaleTranslations } from "../types/UpdateSaleTranslations";-import { languageEntitiesUrl, TranslatableEntities } from "../urls";+import {+ languageEntitiesUrl,+ languageEntityUrl,+ TranslatableEntities+} from "../urls";export interface TranslationsSalesQueryParams {activeField: string;@@ -33,6 +38,7 @@ const TranslationsSales: React.FC<TranslationsSalesProps> = ({}) => {const navigate = useNavigator();const notify = useNotifier();+ const shop = useShop();const onEdit = (field: string) =>navigate(@@ -82,6 +88,7 @@ const TranslationsSales: React.FC<TranslationsSalesProps> = ({disabled={saleTranslations.loading || updateTranslationsOpts.loading}+ languages={maybe(() => shop.languages, [])}languageCode={languageCode}saveButtonState={saveButtonState}onBack={() =>@@ -94,6 +101,11 @@ const TranslationsSales: React.FC<TranslationsSalesProps> = ({}onEdit={onEdit}onSubmit={handleSubmit}+ onLanguageChange={lang =>+ navigate(+ languageEntityUrl(lang, TranslatableEntities.sales, id)+ )+ }sale={maybe(() => saleTranslations.data.sale)}/>);diff --git a/saleor/static/dashboard-next/translations/views/TranslationsVouchers.tsx b/saleor/static/dashboard-next/translations/views/TranslationsVouchers.tsxindex 2487a9b536..00270452b4 100644--- a/saleor/static/dashboard-next/translations/views/TranslationsVouchers.tsx+++ b/saleor/static/dashboard-next/translations/views/TranslationsVouchers.tsx@@ -3,6 +3,7 @@ import * as React from "react";import useNavigator from "../../hooks/useNavigator";import useNotifier from "../../hooks/useNotifier";+import useShop from "../../hooks/useShop";import i18n from "../../i18n";import { getMutationState, maybe } from "../../misc";import {@@ -15,7 +16,11 @@ import TranslationsVouchersPage, {import { TypedUpdateVoucherTranslations } from "../mutations";import { TypedVoucherTranslationDetails } from "../queries";import { UpdateVoucherTranslations } from "../types/UpdateVoucherTranslations";-import { languageEntitiesUrl, TranslatableEntities } from "../urls";+import {+ languageEntitiesUrl,+ languageEntityUrl,+ TranslatableEntities+} from "../urls";export interface TranslationsVouchersQueryParams {activeField: string;@@ -33,6 +38,7 @@ const TranslationsVouchers: React.FC<TranslationsVouchersProps> = ({}) => {const navigate = useNavigator();const notify = useNotifier();+ const shop = useShop();const onEdit = (field: string) =>navigate(@@ -85,6 +91,7 @@ const TranslationsVouchers: React.FC<TranslationsVouchersProps> = ({disabled={voucherTranslations.loading || updateTranslationsOpts.loading}+ languages={maybe(() => shop.languages, [])}languageCode={languageCode}saveButtonState={saveButtonState}onBack={() =>@@ -96,6 +103,11 @@ const TranslationsVouchers: React.FC<TranslationsVouchersProps> = ({)}onEdit={onEdit}+ onLanguageChange={lang =>+ navigate(+ languageEntityUrl(lang, TranslatableEntities.vouchers, id)+ )+ }onSubmit={handleSubmit}voucher={maybe(() => voucherTranslations.data.voucher)}/>