Improve code consistency
This commit is contained in:
parent
47dc872eeb
commit
b4da5edb7a
5 changed files with 149 additions and 194 deletions
|
@ -1,4 +1,5 @@
|
||||||
import { defineMessages, IntlShape } from "react-intl";
|
import { defineMessages, IntlShape } from "react-intl";
|
||||||
|
import { TaxRateType } from "./types/globalTypes";
|
||||||
|
|
||||||
export const commonMessages = defineMessages({
|
export const commonMessages = defineMessages({
|
||||||
availability: {
|
availability: {
|
||||||
|
|
157
src/misc.ts
157
src/misc.ts
|
@ -1,8 +1,8 @@
|
||||||
import moment from "moment-timezone";
|
import moment from "moment-timezone";
|
||||||
import { MutationFunction, MutationResult } from "react-apollo";
|
import { MutationFunction, MutationResult } from "react-apollo";
|
||||||
|
import { defineMessages, IntlShape } from "react-intl";
|
||||||
import urlJoin from "url-join";
|
import urlJoin from "url-join";
|
||||||
|
|
||||||
import { defineMessages, IntlShape } from "react-intl";
|
|
||||||
import { ConfirmButtonTransitionState } from "./components/ConfirmButton/ConfirmButton";
|
import { ConfirmButtonTransitionState } from "./components/ConfirmButton/ConfirmButton";
|
||||||
import { APP_MOUNT_URI } from "./config";
|
import { APP_MOUNT_URI } from "./config";
|
||||||
import { AddressType } from "./customers/types";
|
import { AddressType } from "./customers/types";
|
||||||
|
@ -10,8 +10,7 @@ import { PartialMutationProviderOutput, UserError } from "./types";
|
||||||
import {
|
import {
|
||||||
AuthorizationKeyType,
|
AuthorizationKeyType,
|
||||||
OrderStatus,
|
OrderStatus,
|
||||||
PaymentChargeStatusEnum,
|
PaymentChargeStatusEnum
|
||||||
TaxRateType
|
|
||||||
} from "./types/globalTypes";
|
} from "./types/globalTypes";
|
||||||
|
|
||||||
export type RequireAtLeastOne<T, Keys extends keyof T = keyof T> = Pick<
|
export type RequireAtLeastOne<T, Keys extends keyof T = keyof T> = Pick<
|
||||||
|
@ -181,158 +180,6 @@ export const transformAddressToForm = (data: AddressType) => ({
|
||||||
streetAddress2: maybe(() => data.streetAddress2, "")
|
streetAddress2: maybe(() => data.streetAddress2, "")
|
||||||
});
|
});
|
||||||
|
|
||||||
const taxRatesMessages = defineMessages({
|
|
||||||
accommodation: {
|
|
||||||
defaultMessage: "Accommodation",
|
|
||||||
description: "tax rate"
|
|
||||||
},
|
|
||||||
admissionToCulturalEvents: {
|
|
||||||
defaultMessage: "Admission to cultural events",
|
|
||||||
description: "tax rate"
|
|
||||||
},
|
|
||||||
admissionToEntertainmentEvents: {
|
|
||||||
defaultMessage: "Admission to entertainment events",
|
|
||||||
description: "tax rate"
|
|
||||||
},
|
|
||||||
admissionToSportingEvents: {
|
|
||||||
defaultMessage: "Admission to sporting events",
|
|
||||||
description: "tax rate"
|
|
||||||
},
|
|
||||||
advertising: {
|
|
||||||
defaultMessage: "Advertising",
|
|
||||||
description: "tax rate"
|
|
||||||
},
|
|
||||||
agriculturalSupplies: {
|
|
||||||
defaultMessage: "Agricultural supplies",
|
|
||||||
description: "tax rate"
|
|
||||||
},
|
|
||||||
babyFoodstuffs: {
|
|
||||||
defaultMessage: "Baby foodstuffs",
|
|
||||||
description: "tax rate"
|
|
||||||
},
|
|
||||||
bikes: {
|
|
||||||
defaultMessage: "Bikes",
|
|
||||||
description: "tax rate"
|
|
||||||
},
|
|
||||||
books: {
|
|
||||||
defaultMessage: "Books",
|
|
||||||
description: "tax rate"
|
|
||||||
},
|
|
||||||
childrensClothing: {
|
|
||||||
defaultMessage: "Children's clothing",
|
|
||||||
description: "tax rate"
|
|
||||||
},
|
|
||||||
domesticFuel: {
|
|
||||||
defaultMessage: "Domestic fuel",
|
|
||||||
description: "tax rate"
|
|
||||||
},
|
|
||||||
domesticServices: {
|
|
||||||
defaultMessage: "Domestic services",
|
|
||||||
description: "tax rate"
|
|
||||||
},
|
|
||||||
ebooks: {
|
|
||||||
defaultMessage: "E-books",
|
|
||||||
description: "tax rate"
|
|
||||||
},
|
|
||||||
foodstuffs: {
|
|
||||||
defaultMessage: "Foodstuffs",
|
|
||||||
description: "tax rate"
|
|
||||||
},
|
|
||||||
hotels: {
|
|
||||||
defaultMessage: "Hotels",
|
|
||||||
description: "tax rate"
|
|
||||||
},
|
|
||||||
medical: {
|
|
||||||
defaultMessage: "Medical",
|
|
||||||
description: "tax rate"
|
|
||||||
},
|
|
||||||
newspapers: {
|
|
||||||
defaultMessage: "Newspapers",
|
|
||||||
description: "tax rate"
|
|
||||||
},
|
|
||||||
passengerTransport: {
|
|
||||||
defaultMessage: "Passenger transport",
|
|
||||||
description: "tax rate"
|
|
||||||
},
|
|
||||||
pharmaceuticals: {
|
|
||||||
defaultMessage: "Pharmaceuticals",
|
|
||||||
description: "tax rate"
|
|
||||||
},
|
|
||||||
propertyRenovations: {
|
|
||||||
defaultMessage: "Property renovations",
|
|
||||||
description: "tax rate"
|
|
||||||
},
|
|
||||||
restaurants: {
|
|
||||||
defaultMessage: "Restaurants",
|
|
||||||
description: "tax rate"
|
|
||||||
},
|
|
||||||
socialHousing: {
|
|
||||||
defaultMessage: "Social housing",
|
|
||||||
description: "tax rate"
|
|
||||||
},
|
|
||||||
standard: {
|
|
||||||
defaultMessage: "Standard",
|
|
||||||
description: "tax rate"
|
|
||||||
},
|
|
||||||
water: {
|
|
||||||
defaultMessage: "Water",
|
|
||||||
description: "tax rate"
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
export const translatedTaxRates = (intl: IntlShape) => ({
|
|
||||||
[TaxRateType.ACCOMMODATION]: intl.formatMessage(
|
|
||||||
taxRatesMessages.accommodation
|
|
||||||
),
|
|
||||||
[TaxRateType.ADMISSION_TO_CULTURAL_EVENTS]: intl.formatMessage(
|
|
||||||
taxRatesMessages.admissionToCulturalEvents
|
|
||||||
),
|
|
||||||
[TaxRateType.ADMISSION_TO_ENTERTAINMENT_EVENTS]: intl.formatMessage(
|
|
||||||
taxRatesMessages.admissionToEntertainmentEvents
|
|
||||||
),
|
|
||||||
[TaxRateType.ADMISSION_TO_SPORTING_EVENTS]: intl.formatMessage(
|
|
||||||
taxRatesMessages.admissionToSportingEvents
|
|
||||||
),
|
|
||||||
[TaxRateType.ADVERTISING]: intl.formatMessage(taxRatesMessages.advertising),
|
|
||||||
[TaxRateType.AGRICULTURAL_SUPPLIES]: intl.formatMessage(
|
|
||||||
taxRatesMessages.agriculturalSupplies
|
|
||||||
),
|
|
||||||
[TaxRateType.BABY_FOODSTUFFS]: intl.formatMessage(
|
|
||||||
taxRatesMessages.babyFoodstuffs
|
|
||||||
),
|
|
||||||
[TaxRateType.BIKES]: intl.formatMessage(taxRatesMessages.bikes),
|
|
||||||
[TaxRateType.BOOKS]: intl.formatMessage(taxRatesMessages.books),
|
|
||||||
[TaxRateType.CHILDRENS_CLOTHING]: intl.formatMessage(
|
|
||||||
taxRatesMessages.childrensClothing
|
|
||||||
),
|
|
||||||
[TaxRateType.DOMESTIC_FUEL]: intl.formatMessage(
|
|
||||||
taxRatesMessages.domesticFuel
|
|
||||||
),
|
|
||||||
[TaxRateType.DOMESTIC_SERVICES]: intl.formatMessage(
|
|
||||||
taxRatesMessages.domesticServices
|
|
||||||
),
|
|
||||||
[TaxRateType.E_BOOKS]: intl.formatMessage(taxRatesMessages.ebooks),
|
|
||||||
[TaxRateType.FOODSTUFFS]: intl.formatMessage(taxRatesMessages.foodstuffs),
|
|
||||||
[TaxRateType.HOTELS]: intl.formatMessage(taxRatesMessages.hotels),
|
|
||||||
[TaxRateType.MEDICAL]: intl.formatMessage(taxRatesMessages.medical),
|
|
||||||
[TaxRateType.NEWSPAPERS]: intl.formatMessage(taxRatesMessages.newspapers),
|
|
||||||
[TaxRateType.PASSENGER_TRANSPORT]: intl.formatMessage(
|
|
||||||
taxRatesMessages.passengerTransport
|
|
||||||
),
|
|
||||||
[TaxRateType.PHARMACEUTICALS]: intl.formatMessage(
|
|
||||||
taxRatesMessages.pharmaceuticals
|
|
||||||
),
|
|
||||||
[TaxRateType.PROPERTY_RENOVATIONS]: intl.formatMessage(
|
|
||||||
taxRatesMessages.propertyRenovations
|
|
||||||
),
|
|
||||||
[TaxRateType.RESTAURANTS]: intl.formatMessage(taxRatesMessages.restaurants),
|
|
||||||
[TaxRateType.SOCIAL_HOUSING]: intl.formatMessage(
|
|
||||||
taxRatesMessages.socialHousing
|
|
||||||
),
|
|
||||||
[TaxRateType.STANDARD]: intl.formatMessage(taxRatesMessages.standard),
|
|
||||||
[TaxRateType.WATER]: intl.formatMessage(taxRatesMessages.water)
|
|
||||||
});
|
|
||||||
|
|
||||||
export const authorizationKeyTypes = {
|
export const authorizationKeyTypes = {
|
||||||
[AuthorizationKeyType.FACEBOOK]: "Facebook",
|
[AuthorizationKeyType.FACEBOOK]: "Facebook",
|
||||||
[AuthorizationKeyType.GOOGLE_OAUTH2]: "Google OAuth2"
|
[AuthorizationKeyType.GOOGLE_OAUTH2]: "Google OAuth2"
|
||||||
|
|
|
@ -5,12 +5,13 @@ import { FormattedMessage, IntlShape, useIntl } from "react-intl";
|
||||||
import ActionDialog from "@saleor/components/ActionDialog";
|
import ActionDialog from "@saleor/components/ActionDialog";
|
||||||
import { ConfirmButtonTransitionState } from "@saleor/components/ConfirmButton";
|
import { ConfirmButtonTransitionState } from "@saleor/components/ConfirmButton";
|
||||||
|
|
||||||
export type OrderDraftFinalizeWarning =
|
export enum OrderDraftFinalizeWarning {
|
||||||
| "no-shipping"
|
NO_SHIPPING,
|
||||||
| "no-billing"
|
NO_BILLING,
|
||||||
| "no-user"
|
NO_USER,
|
||||||
| "no-shipping-method"
|
NO_SHIPPING_METHOD,
|
||||||
| "unnecessary-shipping-method";
|
UNNECESSARY_SHIPPING_METHOD
|
||||||
|
}
|
||||||
|
|
||||||
export interface OrderDraftFinalizeDialogProps {
|
export interface OrderDraftFinalizeDialogProps {
|
||||||
confirmButtonState: ConfirmButtonTransitionState;
|
confirmButtonState: ConfirmButtonTransitionState;
|
||||||
|
@ -21,30 +22,29 @@ export interface OrderDraftFinalizeDialogProps {
|
||||||
onConfirm: () => void;
|
onConfirm: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
const warningToText = (warning: OrderDraftFinalizeWarning, intl: IntlShape) => {
|
function translateWarnings(
|
||||||
switch (warning) {
|
intl: IntlShape
|
||||||
case "no-shipping":
|
): Record<OrderDraftFinalizeWarning, string> {
|
||||||
return intl.formatMessage({
|
return {
|
||||||
defaultMessage: "No shipping address"
|
[OrderDraftFinalizeWarning.NO_BILLING]: intl.formatMessage({
|
||||||
});
|
defaultMessage: "No billing address"
|
||||||
case "no-billing":
|
}),
|
||||||
return intl.formatMessage({
|
[OrderDraftFinalizeWarning.NO_SHIPPING]: intl.formatMessage({
|
||||||
defaultMessage: "No billing address"
|
defaultMessage: "No shipping address"
|
||||||
});
|
}),
|
||||||
case "no-user":
|
[OrderDraftFinalizeWarning.NO_SHIPPING_METHOD]: intl.formatMessage({
|
||||||
return intl.formatMessage({
|
defaultMessage: "Some products require shipping, but no method provided"
|
||||||
defaultMessage: "No user information"
|
}),
|
||||||
});
|
[OrderDraftFinalizeWarning.NO_USER]: intl.formatMessage({
|
||||||
case "no-shipping-method":
|
defaultMessage: "No user information"
|
||||||
return intl.formatMessage({
|
}),
|
||||||
defaultMessage: "Some products require shipping, but no method provided"
|
[OrderDraftFinalizeWarning.UNNECESSARY_SHIPPING_METHOD]: intl.formatMessage(
|
||||||
});
|
{
|
||||||
case "unnecessary-shipping-method":
|
|
||||||
return intl.formatMessage({
|
|
||||||
defaultMessage: "Shipping method provided, but no product requires it"
|
defaultMessage: "Shipping method provided, but no product requires it"
|
||||||
});
|
}
|
||||||
}
|
)
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
const OrderDraftFinalizeDialog: React.StatelessComponent<
|
const OrderDraftFinalizeDialog: React.StatelessComponent<
|
||||||
OrderDraftFinalizeDialogProps
|
OrderDraftFinalizeDialogProps
|
||||||
|
@ -57,6 +57,7 @@ const OrderDraftFinalizeDialog: React.StatelessComponent<
|
||||||
orderNumber
|
orderNumber
|
||||||
}) => {
|
}) => {
|
||||||
const intl = useIntl();
|
const intl = useIntl();
|
||||||
|
const translatedWarnings = translateWarnings(intl);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ActionDialog
|
<ActionDialog
|
||||||
|
@ -89,7 +90,7 @@ const OrderDraftFinalizeDialog: React.StatelessComponent<
|
||||||
</p>
|
</p>
|
||||||
<ul>
|
<ul>
|
||||||
{warnings.map(warning => (
|
{warnings.map(warning => (
|
||||||
<li key={warning}>{warningToText(warning, intl)}</li>
|
<li key={warning}>{translatedWarnings[warning]}</li>
|
||||||
))}
|
))}
|
||||||
</ul>
|
</ul>
|
||||||
</>
|
</>
|
||||||
|
|
|
@ -38,13 +38,13 @@ import { OrderDetailsMessages } from "./OrderDetailsMessages";
|
||||||
const orderDraftFinalizeWarnings = (order: OrderDetails_order) => {
|
const orderDraftFinalizeWarnings = (order: OrderDetails_order) => {
|
||||||
const warnings = [] as OrderDraftFinalizeWarning[];
|
const warnings = [] as OrderDraftFinalizeWarning[];
|
||||||
if (!(order && order.shippingAddress)) {
|
if (!(order && order.shippingAddress)) {
|
||||||
warnings.push("no-shipping");
|
warnings.push(OrderDraftFinalizeWarning.NO_SHIPPING);
|
||||||
}
|
}
|
||||||
if (!(order && order.billingAddress)) {
|
if (!(order && order.billingAddress)) {
|
||||||
warnings.push("no-billing");
|
warnings.push(OrderDraftFinalizeWarning.NO_BILLING);
|
||||||
}
|
}
|
||||||
if (!(order && (order.user || order.userEmail))) {
|
if (!(order && (order.user || order.userEmail))) {
|
||||||
warnings.push("no-user");
|
warnings.push(OrderDraftFinalizeWarning.NO_USER);
|
||||||
}
|
}
|
||||||
if (
|
if (
|
||||||
order &&
|
order &&
|
||||||
|
@ -52,7 +52,7 @@ const orderDraftFinalizeWarnings = (order: OrderDetails_order) => {
|
||||||
order.lines.filter(line => line.isShippingRequired).length > 0 &&
|
order.lines.filter(line => line.isShippingRequired).length > 0 &&
|
||||||
order.shippingMethod === null
|
order.shippingMethod === null
|
||||||
) {
|
) {
|
||||||
warnings.push("no-shipping-method");
|
warnings.push(OrderDraftFinalizeWarning.NO_SHIPPING_METHOD);
|
||||||
}
|
}
|
||||||
if (
|
if (
|
||||||
order &&
|
order &&
|
||||||
|
@ -60,7 +60,7 @@ const orderDraftFinalizeWarnings = (order: OrderDetails_order) => {
|
||||||
order.lines.filter(line => line.isShippingRequired).length === 0 &&
|
order.lines.filter(line => line.isShippingRequired).length === 0 &&
|
||||||
order.shippingMethod !== null
|
order.shippingMethod !== null
|
||||||
) {
|
) {
|
||||||
warnings.push("unnecessary-shipping-method");
|
warnings.push(OrderDraftFinalizeWarning.UNNECESSARY_SHIPPING_METHOD);
|
||||||
}
|
}
|
||||||
return warnings;
|
return warnings;
|
||||||
};
|
};
|
||||||
|
|
|
@ -6,7 +6,7 @@ import TableCell from "@material-ui/core/TableCell";
|
||||||
import TableHead from "@material-ui/core/TableHead";
|
import TableHead from "@material-ui/core/TableHead";
|
||||||
import TableRow from "@material-ui/core/TableRow";
|
import TableRow from "@material-ui/core/TableRow";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { FormattedMessage, useIntl } from "react-intl";
|
import { FormattedMessage, IntlShape, useIntl } from "react-intl";
|
||||||
|
|
||||||
import AppHeader from "@saleor/components/AppHeader";
|
import AppHeader from "@saleor/components/AppHeader";
|
||||||
import { Container } from "@saleor/components/Container";
|
import { Container } from "@saleor/components/Container";
|
||||||
|
@ -14,7 +14,8 @@ import Grid from "@saleor/components/Grid";
|
||||||
import PageHeader from "@saleor/components/PageHeader";
|
import PageHeader from "@saleor/components/PageHeader";
|
||||||
import Skeleton from "@saleor/components/Skeleton";
|
import Skeleton from "@saleor/components/Skeleton";
|
||||||
import { sectionNames } from "@saleor/intl";
|
import { sectionNames } from "@saleor/intl";
|
||||||
import { maybe, renderCollection, translatedTaxRates } from "../../../misc";
|
import { TaxRateType } from "@saleor/types/globalTypes";
|
||||||
|
import { maybe, renderCollection } from "../../../misc";
|
||||||
import { CountryList_shop_countries_vat_reducedRates } from "../../types/CountryList";
|
import { CountryList_shop_countries_vat_reducedRates } from "../../types/CountryList";
|
||||||
|
|
||||||
const styles = createStyles({
|
const styles = createStyles({
|
||||||
|
@ -23,6 +24,111 @@ const styles = createStyles({
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function translateTaxRates(intl: IntlShape): Record<TaxRateType, string> {
|
||||||
|
return {
|
||||||
|
[TaxRateType.ACCOMMODATION]: intl.formatMessage({
|
||||||
|
defaultMessage: "Accommodation",
|
||||||
|
description: "tax rate"
|
||||||
|
}),
|
||||||
|
[TaxRateType.ADMISSION_TO_CULTURAL_EVENTS]: intl.formatMessage({
|
||||||
|
defaultMessage: "Admission to cultural events",
|
||||||
|
description: "tax rate"
|
||||||
|
}),
|
||||||
|
[TaxRateType.ADMISSION_TO_ENTERTAINMENT_EVENTS]: intl.formatMessage({
|
||||||
|
defaultMessage: "Admission to entertainment events",
|
||||||
|
description: "tax rate"
|
||||||
|
}),
|
||||||
|
[TaxRateType.ADMISSION_TO_SPORTING_EVENTS]: intl.formatMessage({
|
||||||
|
defaultMessage: "Admission to sporting events",
|
||||||
|
description: "tax rate"
|
||||||
|
}),
|
||||||
|
[TaxRateType.ADVERTISING]: intl.formatMessage({
|
||||||
|
defaultMessage: "Advertising",
|
||||||
|
description: "tax rate"
|
||||||
|
}),
|
||||||
|
[TaxRateType.AGRICULTURAL_SUPPLIES]: intl.formatMessage({
|
||||||
|
defaultMessage: "Agricultural supplies",
|
||||||
|
description: "tax rate"
|
||||||
|
}),
|
||||||
|
[TaxRateType.BABY_FOODSTUFFS]: intl.formatMessage({
|
||||||
|
defaultMessage: "Baby foodstuffs",
|
||||||
|
description: "tax rate"
|
||||||
|
}),
|
||||||
|
[TaxRateType.BIKES]: intl.formatMessage({
|
||||||
|
defaultMessage: "Bikes",
|
||||||
|
description: "tax rate"
|
||||||
|
}),
|
||||||
|
[TaxRateType.BOOKS]: intl.formatMessage({
|
||||||
|
defaultMessage: "Books",
|
||||||
|
description: "tax rate"
|
||||||
|
}),
|
||||||
|
[TaxRateType.CHILDRENS_CLOTHING]: intl.formatMessage({
|
||||||
|
defaultMessage: "Children's clothing",
|
||||||
|
description: "tax rate"
|
||||||
|
}),
|
||||||
|
[TaxRateType.DOMESTIC_FUEL]: intl.formatMessage({
|
||||||
|
defaultMessage: "Domestic fuel",
|
||||||
|
description: "tax rate"
|
||||||
|
}),
|
||||||
|
[TaxRateType.DOMESTIC_SERVICES]: intl.formatMessage({
|
||||||
|
defaultMessage: "Domestic services",
|
||||||
|
description: "tax rate"
|
||||||
|
}),
|
||||||
|
[TaxRateType.E_BOOKS]: intl.formatMessage({
|
||||||
|
defaultMessage: "E-books",
|
||||||
|
description: "tax rate"
|
||||||
|
}),
|
||||||
|
[TaxRateType.FOODSTUFFS]: intl.formatMessage({
|
||||||
|
defaultMessage: "Foodstuffs",
|
||||||
|
description: "tax rate"
|
||||||
|
}),
|
||||||
|
[TaxRateType.HOTELS]: intl.formatMessage({
|
||||||
|
defaultMessage: "Hotels",
|
||||||
|
description: "tax rate"
|
||||||
|
}),
|
||||||
|
[TaxRateType.MEDICAL]: intl.formatMessage({
|
||||||
|
defaultMessage: "Medical",
|
||||||
|
description: "tax rate"
|
||||||
|
}),
|
||||||
|
[TaxRateType.NEWSPAPERS]: intl.formatMessage({
|
||||||
|
defaultMessage: "Newspapers",
|
||||||
|
description: "tax rate"
|
||||||
|
}),
|
||||||
|
[TaxRateType.PASSENGER_TRANSPORT]: intl.formatMessage({
|
||||||
|
defaultMessage: "Passenger transport",
|
||||||
|
description: "tax rate"
|
||||||
|
}),
|
||||||
|
[TaxRateType.PHARMACEUTICALS]: intl.formatMessage({
|
||||||
|
defaultMessage: "Pharmaceuticals",
|
||||||
|
description: "tax rate"
|
||||||
|
}),
|
||||||
|
[TaxRateType.PROPERTY_RENOVATIONS]: intl.formatMessage({
|
||||||
|
defaultMessage: "Property renovations",
|
||||||
|
description: "tax rate"
|
||||||
|
}),
|
||||||
|
[TaxRateType.RESTAURANTS]: intl.formatMessage({
|
||||||
|
defaultMessage: "Restaurants",
|
||||||
|
description: "tax rate"
|
||||||
|
}),
|
||||||
|
[TaxRateType.SOCIAL_HOUSING]: intl.formatMessage({
|
||||||
|
defaultMessage: "Social housing",
|
||||||
|
description: "tax rate"
|
||||||
|
}),
|
||||||
|
[TaxRateType.STANDARD]: intl.formatMessage({
|
||||||
|
defaultMessage: "Standard",
|
||||||
|
description: "tax rate"
|
||||||
|
}),
|
||||||
|
[TaxRateType.WATER]: intl.formatMessage({
|
||||||
|
defaultMessage: "Water",
|
||||||
|
description: "tax rate"
|
||||||
|
}),
|
||||||
|
[TaxRateType.WINE]: intl.formatMessage({
|
||||||
|
defaultMessage: "Wine",
|
||||||
|
description: "tax rate"
|
||||||
|
})
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
export interface CountryTaxesPageProps {
|
export interface CountryTaxesPageProps {
|
||||||
countryName: string;
|
countryName: string;
|
||||||
taxCategories: CountryList_shop_countries_vat_reducedRates[];
|
taxCategories: CountryList_shop_countries_vat_reducedRates[];
|
||||||
|
@ -37,8 +143,8 @@ const CountryTaxesPage = withStyles(styles, { name: "CountryTaxesPage" })(
|
||||||
onBack
|
onBack
|
||||||
}: CountryTaxesPageProps & WithStyles<typeof styles>) => {
|
}: CountryTaxesPageProps & WithStyles<typeof styles>) => {
|
||||||
const intl = useIntl();
|
const intl = useIntl();
|
||||||
|
const translatedTaxRates = translateTaxRates(intl);
|
||||||
|
|
||||||
const taxRates = translatedTaxRates(intl);
|
|
||||||
return (
|
return (
|
||||||
<Container>
|
<Container>
|
||||||
<AppHeader onBack={onBack}>
|
<AppHeader onBack={onBack}>
|
||||||
|
@ -82,7 +188,7 @@ const CountryTaxesPage = withStyles(styles, { name: "CountryTaxesPage" })(
|
||||||
>
|
>
|
||||||
<TableCell>
|
<TableCell>
|
||||||
{maybe<React.ReactNode>(
|
{maybe<React.ReactNode>(
|
||||||
() => taxRates[taxCategory.rateType],
|
() => translatedTaxRates[taxCategory.rateType],
|
||||||
<Skeleton />
|
<Skeleton />
|
||||||
)}
|
)}
|
||||||
</TableCell>
|
</TableCell>
|
||||||
|
|
Loading…
Reference in a new issue