fix(admin): Price input (#4530)
* initial fix for number inputs * add changeset
This commit is contained in:
1 parent
43427b8893
commit
55db914151
4 files changed
+22
-13
No files matched your search
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
"@medusajs/admin-ui": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
fix(admin-ui): number input setting
|
||||||
@@ -1,14 +1,15 @@
|
|||||||
import clsx from "clsx"
|
|
||||||
import { Controller } from "react-hook-form"
|
|
||||||
import { NestedPriceObject, PricesFormType } from "."
|
import { NestedPriceObject, PricesFormType } from "."
|
||||||
import useToggleState from "../../../../hooks/use-toggle-state"
|
|
||||||
import { currencies } from "../../../../utils/currencies"
|
|
||||||
import { NestedForm } from "../../../../utils/nested-form"
|
|
||||||
import IncludesTaxTooltip from "../../../atoms/includes-tax-tooltip"
|
|
||||||
import CoinsIcon from "../../../fundamentals/icons/coins-icon"
|
import CoinsIcon from "../../../fundamentals/icons/coins-icon"
|
||||||
|
import { Controller } from "react-hook-form"
|
||||||
|
import IncludesTaxTooltip from "../../../atoms/includes-tax-tooltip"
|
||||||
import MapPinIcon from "../../../fundamentals/icons/map-pin-icon"
|
import MapPinIcon from "../../../fundamentals/icons/map-pin-icon"
|
||||||
import TriangleRightIcon from "../../../fundamentals/icons/triangle-right-icon"
|
import { NestedForm } from "../../../../utils/nested-form"
|
||||||
import PriceFormInput from "./price-form-input"
|
import PriceFormInput from "./price-form-input"
|
||||||
|
import TriangleRightIcon from "../../../fundamentals/icons/triangle-right-icon"
|
||||||
|
import clsx from "clsx"
|
||||||
|
import { currencies } from "../../../../utils/currencies"
|
||||||
|
import useToggleState from "../../../../hooks/use-toggle-state"
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
form: NestedForm<PricesFormType>
|
form: NestedForm<PricesFormType>
|
||||||
|
|||||||
@@ -1,14 +1,15 @@
|
|||||||
import clsx from "clsx"
|
|
||||||
import { useCallback, useEffect, useState } from "react"
|
import { useCallback, useEffect, useState } from "react"
|
||||||
|
|
||||||
import AmountField from "react-currency-input-field"
|
import AmountField from "react-currency-input-field"
|
||||||
import { currencies } from "../../../../utils/currencies"
|
|
||||||
import InputError from "../../../atoms/input-error"
|
import InputError from "../../../atoms/input-error"
|
||||||
import InputHeader from "../../../fundamentals/input-header"
|
import InputHeader from "../../../fundamentals/input-header"
|
||||||
|
import clsx from "clsx"
|
||||||
|
import { currencies } from "../../../../utils/currencies"
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
currencyCode: string
|
currencyCode: string
|
||||||
amount?: number | null
|
amount?: number | null
|
||||||
onChange: (amount?: number) => void
|
onChange: (amount?: number | null) => void
|
||||||
errors?: { [x: string]: unknown }
|
errors?: { [x: string]: unknown }
|
||||||
name?: string
|
name?: string
|
||||||
label?: string
|
label?: string
|
||||||
@@ -51,7 +52,7 @@ const PriceFormInput = ({
|
|||||||
const numericalValue = Math.round(floatValue * 10 ** decimal_digits)
|
const numericalValue = Math.round(floatValue * 10 ** decimal_digits)
|
||||||
onChange(numericalValue)
|
onChange(numericalValue)
|
||||||
} else {
|
} else {
|
||||||
onChange(undefined)
|
onChange(null)
|
||||||
}
|
}
|
||||||
setFormattedValue(value)
|
setFormattedValue(value)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
import * as React from "react"
|
import * as React from "react"
|
||||||
import { CurrencyType } from "../../../utils/currencies"
|
|
||||||
import PriceInput, { PriceInputProps } from "../price-input"
|
import PriceInput, { PriceInputProps } from "../price-input"
|
||||||
|
|
||||||
|
import { CurrencyType } from "../../../utils/currencies"
|
||||||
|
|
||||||
type MedusaPriceInputProps = {
|
type MedusaPriceInputProps = {
|
||||||
amount: number
|
amount: number
|
||||||
currency: CurrencyType
|
currency: CurrencyType
|
||||||
@@ -34,7 +36,7 @@ function MedusaPriceInput(props: MedusaPriceInputProps) {
|
|||||||
const numericalValue = Math.round(floatValue * 10 ** decimal_digits)
|
const numericalValue = Math.round(floatValue * 10 ** decimal_digits)
|
||||||
onChange(numericalValue)
|
onChange(numericalValue)
|
||||||
} else {
|
} else {
|
||||||
onChange(undefined)
|
onChange(null)
|
||||||
}
|
}
|
||||||
setRawValue(value)
|
setRawValue(value)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user