@legenki/print2medusa 0.9.2 → 0.9.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -2,8 +2,48 @@
|
|
|
2
2
|
const jsxRuntime = require("react/jsx-runtime");
|
|
3
3
|
const adminSdk = require("@medusajs/admin-sdk");
|
|
4
4
|
const ui = require("@medusajs/ui");
|
|
5
|
-
const utils = require("@medusajs/framework/utils");
|
|
6
5
|
const react = require("react");
|
|
6
|
+
const ZERO_DECIMAL_CURRENCIES = /* @__PURE__ */ new Set([
|
|
7
|
+
"AFN",
|
|
8
|
+
"ALL",
|
|
9
|
+
"AMD",
|
|
10
|
+
"BIF",
|
|
11
|
+
"CLP",
|
|
12
|
+
"COP",
|
|
13
|
+
"CRC",
|
|
14
|
+
"DJF",
|
|
15
|
+
"GNF",
|
|
16
|
+
"HUF",
|
|
17
|
+
"IDR",
|
|
18
|
+
"IQD",
|
|
19
|
+
"IRR",
|
|
20
|
+
"IRT",
|
|
21
|
+
"ISK",
|
|
22
|
+
"JPY",
|
|
23
|
+
"KMF",
|
|
24
|
+
"KRW",
|
|
25
|
+
"LBP",
|
|
26
|
+
"MGA",
|
|
27
|
+
"MMK",
|
|
28
|
+
"MNT",
|
|
29
|
+
"MUR",
|
|
30
|
+
"PKR",
|
|
31
|
+
"PYG",
|
|
32
|
+
"RSD",
|
|
33
|
+
"RWF",
|
|
34
|
+
"SOS",
|
|
35
|
+
"SYP",
|
|
36
|
+
"TZS",
|
|
37
|
+
"UGX",
|
|
38
|
+
"UZS",
|
|
39
|
+
"VND",
|
|
40
|
+
"XAF",
|
|
41
|
+
"XOF",
|
|
42
|
+
"XPF",
|
|
43
|
+
"YER",
|
|
44
|
+
"ZMK",
|
|
45
|
+
"ZWL"
|
|
46
|
+
]);
|
|
7
47
|
function minorUnitFactor(currencyCode) {
|
|
8
48
|
return isZeroDecimalCurrency(currencyCode) ? 1 : 100;
|
|
9
49
|
}
|
|
@@ -11,8 +51,7 @@ function isZeroDecimalCurrency(currencyCode) {
|
|
|
11
51
|
if (!currencyCode) {
|
|
12
52
|
return false;
|
|
13
53
|
}
|
|
14
|
-
|
|
15
|
-
return (entry == null ? void 0 : entry.decimal_digits) === 0;
|
|
54
|
+
return ZERO_DECIMAL_CURRENCIES.has(currencyCode.toUpperCase());
|
|
16
55
|
}
|
|
17
56
|
const MONEY_SCALE_VERSION = 2;
|
|
18
57
|
const ATTENTION_STATES = /* @__PURE__ */ new Set(["failed", "canceled", "onhold"]);
|
|
@@ -1,8 +1,48 @@
|
|
|
1
1
|
import { jsxs, jsx, Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { defineWidgetConfig, defineRouteConfig } from "@medusajs/admin-sdk";
|
|
3
3
|
import { Container, Heading, Badge, Text, Button, toast, Prompt, Select, Input, Copy, Table } from "@medusajs/ui";
|
|
4
|
-
import { defaultCurrencies } from "@medusajs/framework/utils";
|
|
5
4
|
import { useState, useEffect, useCallback } from "react";
|
|
5
|
+
const ZERO_DECIMAL_CURRENCIES = /* @__PURE__ */ new Set([
|
|
6
|
+
"AFN",
|
|
7
|
+
"ALL",
|
|
8
|
+
"AMD",
|
|
9
|
+
"BIF",
|
|
10
|
+
"CLP",
|
|
11
|
+
"COP",
|
|
12
|
+
"CRC",
|
|
13
|
+
"DJF",
|
|
14
|
+
"GNF",
|
|
15
|
+
"HUF",
|
|
16
|
+
"IDR",
|
|
17
|
+
"IQD",
|
|
18
|
+
"IRR",
|
|
19
|
+
"IRT",
|
|
20
|
+
"ISK",
|
|
21
|
+
"JPY",
|
|
22
|
+
"KMF",
|
|
23
|
+
"KRW",
|
|
24
|
+
"LBP",
|
|
25
|
+
"MGA",
|
|
26
|
+
"MMK",
|
|
27
|
+
"MNT",
|
|
28
|
+
"MUR",
|
|
29
|
+
"PKR",
|
|
30
|
+
"PYG",
|
|
31
|
+
"RSD",
|
|
32
|
+
"RWF",
|
|
33
|
+
"SOS",
|
|
34
|
+
"SYP",
|
|
35
|
+
"TZS",
|
|
36
|
+
"UGX",
|
|
37
|
+
"UZS",
|
|
38
|
+
"VND",
|
|
39
|
+
"XAF",
|
|
40
|
+
"XOF",
|
|
41
|
+
"XPF",
|
|
42
|
+
"YER",
|
|
43
|
+
"ZMK",
|
|
44
|
+
"ZWL"
|
|
45
|
+
]);
|
|
6
46
|
function minorUnitFactor(currencyCode) {
|
|
7
47
|
return isZeroDecimalCurrency(currencyCode) ? 1 : 100;
|
|
8
48
|
}
|
|
@@ -10,8 +50,7 @@ function isZeroDecimalCurrency(currencyCode) {
|
|
|
10
50
|
if (!currencyCode) {
|
|
11
51
|
return false;
|
|
12
52
|
}
|
|
13
|
-
|
|
14
|
-
return (entry == null ? void 0 : entry.decimal_digits) === 0;
|
|
53
|
+
return ZERO_DECIMAL_CURRENCIES.has(currencyCode.toUpperCase());
|
|
15
54
|
}
|
|
16
55
|
const MONEY_SCALE_VERSION = 2;
|
|
17
56
|
const ATTENTION_STATES = /* @__PURE__ */ new Set(["failed", "canceled", "onhold"]);
|
|
@@ -1,8 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.minorUnitFactor = minorUnitFactor;
|
|
4
|
-
exports.isZeroDecimalCurrency = isZeroDecimalCurrency;
|
|
5
|
-
const utils_1 = require("@medusajs/framework/utils");
|
|
6
2
|
/**
|
|
7
3
|
* How many minor units make one major unit of a currency.
|
|
8
4
|
*
|
|
@@ -11,13 +7,73 @@ const utils_1 = require("@medusajs/framework/utils");
|
|
|
11
7
|
* Scaling those by 100 anyway produces a value a hundredfold too large for
|
|
12
8
|
* anything reading it back with Medusa's own conventions.
|
|
13
9
|
*
|
|
14
|
-
*
|
|
15
|
-
* `
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
10
|
+
* **Why the list is written out here rather than imported.** It used to come
|
|
11
|
+
* from `defaultCurrencies` in `@medusajs/framework/utils`, which is correct for
|
|
12
|
+
* server code and fatal for the browser: this file is also imported by the
|
|
13
|
+
* admin order widget, and `@medusajs/framework/utils` reaches
|
|
14
|
+
* `@medusajs/utils/dist/auth/token.js` → `jsonwebtoken` → `jws`, which calls
|
|
15
|
+
* `util.inherits`. That does not exist in a browser, so the whole Medusa admin
|
|
16
|
+
* failed to load with `chr.inherits is not a function` — not a broken widget,
|
|
17
|
+
* a blank admin.
|
|
18
|
+
*
|
|
19
|
+
* The usual objection to a hand-kept list is that HUF, ISK and CLP get missed.
|
|
20
|
+
* That is answered by a test rather than by discipline: `currency.test.ts`
|
|
21
|
+
* compares this set against Medusa's own table and fails if they diverge, so
|
|
22
|
+
* the data stays Medusa's while the import stays server-side.
|
|
23
|
+
*/
|
|
24
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
+
exports.ZERO_DECIMAL_CURRENCIES = void 0;
|
|
26
|
+
exports.minorUnitFactor = minorUnitFactor;
|
|
27
|
+
exports.isZeroDecimalCurrency = isZeroDecimalCurrency;
|
|
28
|
+
/**
|
|
29
|
+
* Currencies with no subunit, from Medusa's `defaultCurrencies`
|
|
30
|
+
* (`decimal_digits === 0`). Kept in sync by test, not by hand.
|
|
31
|
+
*
|
|
32
|
+
* Exported so `currency.test.ts` can compare the set itself against Medusa's
|
|
33
|
+
* table in both directions — a code invented here is invisible to any check
|
|
34
|
+
* that only walks Medusa's side.
|
|
20
35
|
*/
|
|
36
|
+
exports.ZERO_DECIMAL_CURRENCIES = new Set([
|
|
37
|
+
"AFN",
|
|
38
|
+
"ALL",
|
|
39
|
+
"AMD",
|
|
40
|
+
"BIF",
|
|
41
|
+
"CLP",
|
|
42
|
+
"COP",
|
|
43
|
+
"CRC",
|
|
44
|
+
"DJF",
|
|
45
|
+
"GNF",
|
|
46
|
+
"HUF",
|
|
47
|
+
"IDR",
|
|
48
|
+
"IQD",
|
|
49
|
+
"IRR",
|
|
50
|
+
"IRT",
|
|
51
|
+
"ISK",
|
|
52
|
+
"JPY",
|
|
53
|
+
"KMF",
|
|
54
|
+
"KRW",
|
|
55
|
+
"LBP",
|
|
56
|
+
"MGA",
|
|
57
|
+
"MMK",
|
|
58
|
+
"MNT",
|
|
59
|
+
"MUR",
|
|
60
|
+
"PKR",
|
|
61
|
+
"PYG",
|
|
62
|
+
"RSD",
|
|
63
|
+
"RWF",
|
|
64
|
+
"SOS",
|
|
65
|
+
"SYP",
|
|
66
|
+
"TZS",
|
|
67
|
+
"UGX",
|
|
68
|
+
"UZS",
|
|
69
|
+
"VND",
|
|
70
|
+
"XAF",
|
|
71
|
+
"XOF",
|
|
72
|
+
"XPF",
|
|
73
|
+
"YER",
|
|
74
|
+
"ZMK",
|
|
75
|
+
"ZWL",
|
|
76
|
+
]);
|
|
21
77
|
function minorUnitFactor(currencyCode) {
|
|
22
78
|
return isZeroDecimalCurrency(currencyCode) ? 1 : 100;
|
|
23
79
|
}
|
|
@@ -36,7 +92,6 @@ function isZeroDecimalCurrency(currencyCode) {
|
|
|
36
92
|
return false;
|
|
37
93
|
}
|
|
38
94
|
// Printful sends "USD", Medusa stores "usd", and both reach this.
|
|
39
|
-
|
|
40
|
-
return entry?.decimal_digits === 0;
|
|
95
|
+
return exports.ZERO_DECIMAL_CURRENCIES.has(currencyCode.toUpperCase());
|
|
41
96
|
}
|
|
42
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
97
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY3VycmVuY3kuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi9zcmMvdXRpbHMvY3VycmVuY3kudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBOzs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7R0FxQkc7OztBQW9ESCwwQ0FJQztBQVlELHNEQVFDO0FBMUVEOzs7Ozs7O0dBT0c7QUFDVSxRQUFBLHVCQUF1QixHQUFHLElBQUksR0FBRy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