feat(dashboard,types,js-sdk,ui): Tax Regions UI (#7935)
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { AddressDTO } from "@medusajs/types"
|
||||
|
||||
import { countries } from "./countries"
|
||||
import { countries } from "./data/countries"
|
||||
|
||||
export const isSameAddress = (a: AddressDTO | null, b: AddressDTO | null) => {
|
||||
if (!a || !b) {
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,32 +0,0 @@
|
||||
import { Discount } from "@medusajs/medusa"
|
||||
import { end, parse } from "iso8601-duration"
|
||||
|
||||
export enum PromotionStatus {
|
||||
SCHEDULED = "SCHEDULED",
|
||||
EXPIRED = "EXPIRED",
|
||||
ACTIVE = "ACTIVE",
|
||||
DISABLED = "DISABLED",
|
||||
}
|
||||
|
||||
export const getDiscountStatus = (discount: Discount) => {
|
||||
if (discount.is_disabled) {
|
||||
return PromotionStatus.DISABLED
|
||||
}
|
||||
|
||||
const date = new Date()
|
||||
if (new Date(discount.starts_at) > date) {
|
||||
return PromotionStatus.SCHEDULED
|
||||
}
|
||||
|
||||
if (
|
||||
(discount.ends_at && new Date(discount.ends_at) < date) ||
|
||||
(discount.valid_duration &&
|
||||
date >
|
||||
end(parse(discount.valid_duration), new Date(discount.starts_at))) ||
|
||||
discount.usage_count === discount.usage_limit
|
||||
) {
|
||||
return PromotionStatus.EXPIRED
|
||||
}
|
||||
|
||||
return PromotionStatus.ACTIVE
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
import { currencies } from "./currencies"
|
||||
import { currencies } from "./data/currencies"
|
||||
|
||||
export const getDecimalDigits = (currency: string) => {
|
||||
return currencies[currency.toUpperCase()]?.decimal_digits ?? 0
|
||||
@@ -15,7 +15,7 @@ export const getDecimalDigits = (currency: string) => {
|
||||
* getFormattedAmount(10, "usd") // '10,00 $' if the browser's locale is fr-FR
|
||||
*/
|
||||
export const getLocaleAmount = (amount: number, currencyCode: string) => {
|
||||
const formatter = new Intl.NumberFormat(undefined, {
|
||||
const formatter = new Intl.NumberFormat([], {
|
||||
style: "currency",
|
||||
currencyDisplay: "narrowSymbol",
|
||||
currency: currencyCode,
|
||||
@@ -25,7 +25,7 @@ export const getLocaleAmount = (amount: number, currencyCode: string) => {
|
||||
}
|
||||
|
||||
export const getNativeSymbol = (currencyCode: string) => {
|
||||
const formatted = new Intl.NumberFormat(undefined, {
|
||||
const formatted = new Intl.NumberFormat([], {
|
||||
style: "currency",
|
||||
currency: currencyCode,
|
||||
currencyDisplay: "narrowSymbol",
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
const formatter = new Intl.NumberFormat(undefined, {
|
||||
const formatter = new Intl.NumberFormat([], {
|
||||
style: "percent",
|
||||
minimumFractionDigits: 2,
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user