Added driveable and tow in flags. IO-719

This commit is contained in:
Patrick Fic
2021-03-02 11:54:24 -08:00
parent 904dc4e29e
commit a026cd0163
19 changed files with 1771 additions and 13 deletions

View File

@@ -1,18 +1,62 @@
import { InputNumber } from "antd";
import React, { forwardRef } from "react";
function FormItemCurrency(props, ref) {
import React from "react";
// const locale = "en-us";
// const currencyFormatter = (value) => {
// return new Intl.NumberFormat(locale, {
// style: "currency",
// currency: "CAD",
// }).format(value);
// };
// const currencyParser = (val) => {
// try {
// // for when the input gets clears
// if (typeof val === "string" && !val.length) {
// val = "0.0";
// }
// // detecting and parsing between comma and dot
// var group = new Intl.NumberFormat(locale).format(1111).replace(/1/g, "");
// var decimal = new Intl.NumberFormat(locale).format(1.1).replace(/1/g, "");
// var reversedVal = val.replace(new RegExp("\\" + group, "g"), "");
// reversedVal = reversedVal.replace(new RegExp("\\" + decimal, "g"), ".");
// // => 1232.21 €
// // removing everything except the digits and dot
// reversedVal = reversedVal.replace(/[^0-9.]/g, "");
// // => 1232.21
// // appending digits properly
// const digitsAfterDecimalCount = (reversedVal.split(".")[1] || []).length;
// const needsDigitsAppended = digitsAfterDecimalCount > 2;
// if (needsDigitsAppended) {
// reversedVal = reversedVal * Math.pow(10, digitsAfterDecimalCount - 2);
// }
// return Number.isNaN(reversedVal) ? 0 : reversedVal;
// } catch (error) {
// console.error(error);
// }
// };
export default function FormItemCurrency(props) {
return (
<InputNumber
{...props}
ref={ref}
style={{ width: "initial" }}
formatter={(value) => `$ ${value}`.replace(/\B(?=(\d{3})+(?!\d))/g, ",")}
parser={(value) => value.replace(/\$\s?|(,*)/g, "")}
precision={2}
// formatter={currencyFormatter}
// parser={currencyParser}
// formatter={(value) =>
// "$" +
// parseFloat(value)
// .toFixed(2)
// .replace(/(\d)(?=(\d{3})+\.)/g, "$1,")
// }
// parser={(value) => value.replace(/\$\s?|(,*)/g, "")}
// formatter={(value) => `$ ${value}`.replace(/\B(?=(\d{3})+(?!\d))/g, ",")}
// parser={(value) => value.replace(/\$\s?|(,*)/g, "")}
precision={2}
/>
);
}
export default forwardRef(FormItemCurrency);