Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
wip
Lukasz Szewczyk8416bc5d4a32
diff --git a/saleor/static/dashboard-next/components/Money/Money.tsx b/saleor/static/dashboard-next/components/Money/Money.tsxindex bd3f560c81..5935737871 100644--- a/saleor/static/dashboard-next/components/Money/Money.tsx+++ b/saleor/static/dashboard-next/components/Money/Money.tsx@@ -3,21 +3,23 @@ import * as React from "react";import { LocaleConsumer } from "../Locale";-interface MoneyProps {+export interface MoneyProp {amount: number;currency: string;+}+interface MoneyProps {+ moneyDetalis: MoneyProp;typographyProps?: TypographyProps;}export const Money: React.StatelessComponent<MoneyProps> = ({- amount,- currency,+ moneyDetalis,typographyProps}) => (<LocaleConsumer>{locale => {- const money = amount.toLocaleString(locale, {- currency,+ const money = moneyDetalis.amount.toLocaleString(locale, {+ currency: moneyDetalis.currency,style: "currency"});if (typographyProps) {diff --git a/saleor/static/dashboard-next/components/Money/index.ts b/saleor/static/dashboard-next/components/Money/index.tsindex ace2118caa..3c9e8c2077 100644--- a/saleor/static/dashboard-next/components/Money/index.ts+++ b/saleor/static/dashboard-next/components/Money/index.ts@@ -1,2 +1,3 @@export { default } from "./Money";export * from "./Money";+export { MoneyProp } from "./Money";diff --git a/saleor/static/dashboard-next/orders/components/OrderUnfulfilledItems/OrderUnfulfilledItems.tsx b/saleor/static/dashboard-next/orders/components/OrderUnfulfilledItems/OrderUnfulfilledItems.tsxindex c0df576897..4d15f1cf0c 100644--- a/saleor/static/dashboard-next/orders/components/OrderUnfulfilledItems/OrderUnfulfilledItems.tsx+++ b/saleor/static/dashboard-next/orders/components/OrderUnfulfilledItems/OrderUnfulfilledItems.tsx@@ -88,10 +88,7 @@ const OrderUnfulfilledItems = decorate<OrderUnfulfilledItemsProps>(</TableCell><TableCell className={classes.textRight}>{maybe(() => line.unitPrice.gross) ? (- <Money- amount={line.unitPrice.gross.amount}- currency={line.unitPrice.gross.currency}- />+ <Money moneyDetalis={line.unitPrice.gross} />) : (<Skeleton />)}@@ -103,11 +100,12 @@ const OrderUnfulfilledItems = decorate<OrderUnfulfilledItemsProps>(line.unitPrice.gross.amount) ? (<Money- amount={- (line.quantity - line.quantityFulfilled) *- line.unitPrice.gross.amount- }- currency={line.unitPrice.gross.currency}+ moneyDetalis={{+ amount:+ (line.quantity - line.quantityFulfilled) *+ line.unitPrice.gross.amount,+ currency: line.unitPrice.gross.currency+ }}/>) : (<Skeleton />diff --git a/saleor/static/dashboard-next/products/components/ProductVariants/ProductVariants.tsx b/saleor/static/dashboard-next/products/components/ProductVariants/ProductVariants.tsxindex 64e658ce51..6ea506ce84 100644--- a/saleor/static/dashboard-next/products/components/ProductVariants/ProductVariants.tsx+++ b/saleor/static/dashboard-next/products/components/ProductVariants/ProductVariants.tsx@@ -131,15 +131,9 @@ export const ProductVariants = decorate<ProductVariantsProps>(<TableCell className={classes.textRight}>{variant ? (variant.priceOverride ? (- <Money- amount={variant.priceOverride.amount}- currency={variant.priceOverride.currency}- />+ <Money moneyDetalis={variant.priceOverride} />) : fallbackPrice ? (- <Money- amount={fallbackPrice.amount}- currency={fallbackPrice.currency}- />+ <Money moneyDetalis={fallbackPrice} />) : (<Skeleton />)diff --git a/saleor/static/dashboard-next/storybook/stories/components/Money.tsx b/saleor/static/dashboard-next/storybook/stories/components/Money.tsxindex 39c8d385cd..b72e3b7bac 100644--- a/saleor/static/dashboard-next/storybook/stories/components/Money.tsx+++ b/saleor/static/dashboard-next/storybook/stories/components/Money.tsx@@ -1,9 +1,14 @@import { storiesOf } from "@storybook/react";import * as React from "react";-import Money from "../../../components/Money";+import Money, { MoneyProp } from "../../../components/Money";import Decorator from "../../Decorator";+const moneyDetalis: MoneyProp = {+ amount: 12,+ currency: "EUR"+};+storiesOf("Generics / Money formatting", module).addDecorator(Decorator)- .add("default", () => <Money amount={14} currency="EUR" />);+ .add("default", () => <Money moneyDetalis={moneyDetalis} />);diff --git a/saleor/static/dashboard-next/vouchers/components/VoucherList/VoucherList.tsx b/saleor/static/dashboard-next/vouchers/components/VoucherList/VoucherList.tsxindex 74e796b90b..f686d539d5 100644--- a/saleor/static/dashboard-next/vouchers/components/VoucherList/VoucherList.tsx+++ b/saleor/static/dashboard-next/vouchers/components/VoucherList/VoucherList.tsx@@ -11,7 +11,7 @@ import * as React from "react";import { createVoucherName, VoucherType } from "../..";import { ListProps } from "../../..";import DateFormatter from "../../../components/DateFormatter";-import Money from "../../../components/Money";+import Money, { MoneyProp } from "../../../components/Money";import Percent from "../../../components/Percent";import Skeleton from "../../../components/Skeleton";import TablePagination from "../../../components/TablePagination";@@ -28,7 +28,7 @@ interface VoucherListProps extends ListProps {endDate: string | null;discountValueType: "PERCENTAGE" | "FIXED" | string;discountValue: number;- limit: { amount: number; currency: string } | null;+ limit: MoneyProp | null;product: {name: string;} | null;@@ -144,8 +144,10 @@ const VoucherList = decorate<VoucherListProps>(/>) : (<Money- amount={voucher.discountValue}- currency={currency}+ moneyDetalis={{+ amount: voucher.discountValue,+ currency+ }}typographyProps={{ className: classes.tableCellFont }}/>)@@ -157,8 +159,7 @@ const VoucherList = decorate<VoucherListProps>({voucher ? (voucher.limit !== null ? (<Money- amount={voucher.limit.amount}- currency={voucher.limit.currency}+ moneyDetalis={voucher.limit}typographyProps={{ className: classes.tableCellFont }}/>) : (