Skip to content

Commit 1f2fadb

Browse files
authored
chore(examples): update dinero.js from v2.0.0-alpha.8 to v2.0.0 (#648)
1 parent 9d18c09 commit 1f2fadb

7 files changed

Lines changed: 30 additions & 41 deletions

File tree

examples/nextjs-response-streaming/package-lock.json

Lines changed: 17 additions & 29 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/nextjs-response-streaming/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"autoprefixer": "10.4.14",
1919
"clsx": "1.2.1",
2020
"date-fns": "2.29.3",
21-
"dinero.js": "2.0.0-alpha.8",
21+
"dinero.js": "2.0.0",
2222
"eslint": "8.37.0",
2323
"eslint-config-next": "14.2.2",
2424
"ms": "3.0.0-canary.1",

examples/nextjs-response-streaming/ui/product-card.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,4 @@ export const ProductCard = ({
5757
</div>
5858
</Link>
5959
)
60-
}
60+
}

examples/nextjs-response-streaming/ui/product-currency-symbol.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
import { toFormat, type Dinero } from 'dinero.js';
1+
import { toSnapshot, type Dinero } from 'dinero.js';
22

33
export const ProductCurrencySymbol = ({
44
dinero,
55
}: {
66
dinero: Dinero<number>;
77
}) => {
8+
const snapshot = toSnapshot(dinero);
89
let symbol = '';
9-
switch (toFormat(dinero, ({ currency }) => currency.code)) {
10+
switch (snapshot.currency.code) {
1011
case 'GBP': {
1112
symbol = '£';
1213
break;

examples/nextjs-response-streaming/ui/product-deal.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { ProductCurrencySymbol } from '@/ui/product-currency-symbol';
2-
import { toUnit, type Dinero } from 'dinero.js';
2+
import { toDecimal, type Dinero } from 'dinero.js';
33

44
export const ProductDeal = ({
55
price: priceRaw,
@@ -10,8 +10,8 @@ export const ProductDeal = ({
1010
amount: Dinero<number>;
1111
};
1212
}) => {
13-
const discount = toUnit(discountRaw.amount);
14-
const price = toUnit(priceRaw);
13+
const discount = Number(toDecimal(discountRaw.amount));
14+
const price = Number(toDecimal(priceRaw));
1515
const percent = Math.round(100 - (discount / price) * 100);
1616

1717
return (

examples/nextjs-response-streaming/ui/product-price.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Product } from "@/app/api/products/product";
2-
import { Dinero, multiply, toUnit } from "dinero.js";
2+
import { Dinero, multiply, toDecimal } from "dinero.js";
33
import { ProductCurrencySymbol } from "./product-currency-symbol";
44
import { ProductDeal } from "./product-deal";
55
import { ProductLighteningDeal } from "./product-lightening-deal";
@@ -45,8 +45,8 @@ export const ProductPrice = ({
4545
<ProductCurrencySymbol dinero={price} />
4646
</div>
4747
<div className="text-lg font-bold leading-snug text-white">
48-
{toUnit(price)}
48+
{Number(toDecimal(price))}
4949
</div>
5050
</div>
5151
);
52-
}
52+
}

examples/nextjs-response-streaming/ui/product-used-price.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Product } from '@/app/api/products/product';
2-
import { dinero, toUnit, up, type DineroSnapshot } from 'dinero.js';
2+
import { dinero, toDecimal, type DineroSnapshot } from 'dinero.js';
33

44
export const ProductUsedPrice = ({
55
usedPrice: usedPriceRaw,
@@ -12,7 +12,7 @@ export const ProductUsedPrice = ({
1212
<div className="text-sm">
1313
<div className="text-gray-400">More buying choices</div>
1414
<div className="text-gray-200">
15-
${toUnit(usedPrice, { digits: 0, round: up })} (used)
15+
${Math.ceil(Number(toDecimal(usedPrice)))} (used)
1616
</div>
1717
</div>
1818
);

0 commit comments

Comments
 (0)