import rhf and reusable components from his v3
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
import React from "react";
|
||||
import { InputAttributes, NumericFormat, NumericFormatProps } from "react-number-format";
|
||||
|
||||
interface CustomProps {
|
||||
onChange: (event: { target: { name: string; value: string } }) => void;
|
||||
name: string;
|
||||
}
|
||||
|
||||
const DiscountPctFormat = React.forwardRef<
|
||||
NumericFormatProps<InputAttributes>,
|
||||
CustomProps
|
||||
>(function DiscountPctFormat(props, ref) {
|
||||
const { onChange, ...other } = props;
|
||||
|
||||
return (
|
||||
<NumericFormat
|
||||
{...other}
|
||||
getInputRef={ref}
|
||||
onValueChange={(values) => {
|
||||
onChange({
|
||||
target: {
|
||||
name: props.name,
|
||||
value: values.value,
|
||||
},
|
||||
});
|
||||
}}
|
||||
thousandSeparator
|
||||
valueIsNumericString
|
||||
allowLeadingZeros={false}
|
||||
/>
|
||||
);
|
||||
});
|
||||
|
||||
export default DiscountPctFormat;
|
||||
@@ -0,0 +1,34 @@
|
||||
import React from "react";
|
||||
import { InputAttributes, NumericFormat, NumericFormatProps } from "react-number-format";
|
||||
|
||||
interface CustomProps {
|
||||
onChange: (event: { target: { name: string; value: string } }) => void;
|
||||
name: string;
|
||||
}
|
||||
|
||||
const MoneyFormat = React.forwardRef<
|
||||
NumericFormatProps<InputAttributes>,
|
||||
CustomProps
|
||||
>(function MoneyFormat(props, ref) {
|
||||
const { onChange, ...other } = props;
|
||||
|
||||
return (
|
||||
<NumericFormat
|
||||
{...other}
|
||||
getInputRef={ref}
|
||||
onValueChange={(values) => {
|
||||
onChange({
|
||||
target: {
|
||||
name: props.name,
|
||||
value: values.value,
|
||||
},
|
||||
});
|
||||
}}
|
||||
thousandSeparator
|
||||
valueIsNumericString
|
||||
allowLeadingZeros={false}
|
||||
/>
|
||||
);
|
||||
});
|
||||
|
||||
export default MoneyFormat;
|
||||
Reference in New Issue
Block a user