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);

View File

@@ -1,6 +1,6 @@
import { Button, Form, notification, Popover, Select } from "antd";
import React, { useState } from "react";
import { useMutation } from "@apollo/client";
import { Button, Form, notification, Popover, Select, Switch } from "antd";
import React, { useState } from "react";
import { useTranslation } from "react-i18next";
import { connect } from "react-redux";
import { createStructuredSelector } from "reselect";
@@ -38,7 +38,11 @@ export function JobsConvertButton({ bodyshop, job, refetch, jobRO }) {
const popMenu = (
<div>
<Form layout="vertical" onFinish={handleConvert}>
<Form
layout="vertical"
onFinish={handleConvert}
initialValues={{ driveable: true, towin: false }}
>
<Form.Item
name={["ins_co_nm"]}
label={t("jobs.fields.ins_co_nm")}
@@ -75,6 +79,27 @@ export function JobsConvertButton({ bodyshop, job, refetch, jobRO }) {
))}
</Select>
</Form.Item>
<Form.Item
label={t("jobs.fields.ca_gst_registrant")}
name="ca_gst_registrant"
valuePropName="checked"
>
<Switch />
</Form.Item>
<Form.Item
label={t("jobs.fields.driveable")}
name="driveable"
valuePropName="checked"
>
<Switch />
</Form.Item>
<Form.Item
label={t("jobs.fields.towin")}
name="towin"
valuePropName="checked"
>
<Switch />
</Form.Item>
<Button type="danger" htmlType="submit">
{t("jobs.actions.convert")}
</Button>

View File

@@ -140,6 +140,20 @@ export function JobsDetailGeneral({ bodyshop, jobRO, job, form }) {
>
<Input disabled={jobRO} />
</Form.Item>
<Form.Item
label={t("jobs.fields.driveable")}
name="driveable"
valuePropName="checked"
>
<Switch disabled={jobRO} />
</Form.Item>
<Form.Item
label={t("jobs.fields.towin")}
name="towin"
valuePropName="checked"
>
<Switch disabled={jobRO} />
</Form.Item>
</FormRow>
</Col>
<Col {...lossColDamage}>