BOD-61 Fixed invoice enter modal to simplify + follow new modal pattern.
This commit is contained in:
@@ -1,176 +1,116 @@
|
|||||||
import {
|
import { DatePicker, Form, Input, Switch } from "antd";
|
||||||
Button,
|
import React, { useState } from "react";
|
||||||
DatePicker,
|
|
||||||
Form,
|
|
||||||
Input,
|
|
||||||
Modal,
|
|
||||||
Select,
|
|
||||||
Switch,
|
|
||||||
Tag
|
|
||||||
} from "antd";
|
|
||||||
import React from "react";
|
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import CurrencyInput from "../form-items-formatted/currency-form-item.component";
|
import CurrencyInput from "../form-items-formatted/currency-form-item.component";
|
||||||
|
import JobSearchSelect from "../job-search-select/job-search-select.component";
|
||||||
|
import VendorSearchSelect from "../vendor-search-select/vendor-search-select.component";
|
||||||
import InvoiceEnterModalLinesComponent from "./invoice-enter-modal.lines.component";
|
import InvoiceEnterModalLinesComponent from "./invoice-enter-modal.lines.component";
|
||||||
|
|
||||||
export default function InvoiceEnterModalComponent({
|
export default function InvoiceEnterModalComponent({
|
||||||
visible,
|
form,
|
||||||
invoice,
|
|
||||||
handleCancel,
|
|
||||||
handleFinish,
|
|
||||||
handleRoSelect,
|
|
||||||
roAutoCompleteOptions,
|
roAutoCompleteOptions,
|
||||||
handleVendorSelect,
|
|
||||||
vendorAutoCompleteOptions,
|
vendorAutoCompleteOptions,
|
||||||
lineData,
|
lineData,
|
||||||
vendor,
|
responsibilityCenters,
|
||||||
job,
|
loadLines
|
||||||
responsibilityCenters
|
|
||||||
}) {
|
}) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const [form] = Form.useForm();
|
|
||||||
const { resetFields } = form;
|
const [discount, setDiscount] = useState(0);
|
||||||
|
|
||||||
|
const handleVendorSelect = (props, opt) => {
|
||||||
|
setDiscount(opt.discount);
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Form onFinish={handleFinish} autoComplete={"off"} form={form}>
|
<div>
|
||||||
<Modal
|
<div style={{ display: "flex" }}>
|
||||||
title={
|
<Form.Item
|
||||||
invoice && invoice.id
|
name="jobid"
|
||||||
? t("invoices.labels.edit")
|
label={t("invoices.fields.ro_number")}
|
||||||
: t("invoices.labels.new")
|
rules={[
|
||||||
}
|
{
|
||||||
width={"90%"}
|
required: true,
|
||||||
visible={visible}
|
message: t("general.validation.required")
|
||||||
okText={t("general.actions.save")}
|
}
|
||||||
onOk={() => form.submit()}
|
]}
|
||||||
okButtonProps={{ htmlType: "submit" }}
|
>
|
||||||
onCancel={handleCancel}
|
<JobSearchSelect
|
||||||
>
|
options={roAutoCompleteOptions}
|
||||||
<div style={{ display: "flex" }}>
|
onBlur={() => {
|
||||||
<Form.Item
|
if (form.getFieldValue("jobid") !== null) {
|
||||||
name="jobid"
|
loadLines({ variables: { id: form.getFieldValue("jobid") } });
|
||||||
label={t("invoices.fields.ro_number")}
|
|
||||||
rules={[
|
|
||||||
{
|
|
||||||
required: true,
|
|
||||||
message: t("general.validation.required")
|
|
||||||
}
|
}
|
||||||
]}
|
}}
|
||||||
>
|
/>
|
||||||
<Select
|
</Form.Item>
|
||||||
showSearch
|
<Form.Item
|
||||||
defaultValue={
|
label={t("invoices.fields.vendor")}
|
||||||
job ? (job.ro_number ? job.ro_number : job.est_number) : null
|
name="vendorid"
|
||||||
}
|
rules={[
|
||||||
autoFocus
|
{
|
||||||
defaultOpen
|
required: true,
|
||||||
style={{ width: "300px" }}
|
message: t("general.validation.required")
|
||||||
onSelect={handleRoSelect}
|
}
|
||||||
>
|
]}
|
||||||
{roAutoCompleteOptions
|
>
|
||||||
? roAutoCompleteOptions.map(o => (
|
<VendorSearchSelect
|
||||||
<Select.Option
|
options={vendorAutoCompleteOptions}
|
||||||
key={o.id}
|
onSelect={handleVendorSelect}
|
||||||
value={o.ro_number ? o.ro_number : o.est_number}
|
/>
|
||||||
>
|
</Form.Item>
|
||||||
{`${
|
</div>
|
||||||
o.ro_number ? o.ro_number : o.est_number
|
<div style={{ display: "flex" }}>
|
||||||
} | ${o.ownr_ln || ""} ${o.ownr_fn ||
|
<Form.Item
|
||||||
""} | ${o.v_model_yr || ""} ${o.v_make_desc ||
|
label={t("invoices.fields.invoice_number")}
|
||||||
""} ${o.v_model_desc || ""}`}
|
name="invoice_number"
|
||||||
</Select.Option>
|
rules={[
|
||||||
))
|
{
|
||||||
: null}
|
required: true,
|
||||||
</Select>
|
message: t("general.validation.required")
|
||||||
</Form.Item>
|
}
|
||||||
<Form.Item
|
]}
|
||||||
label={t("invoices.fields.vendor")}
|
>
|
||||||
name="vendorid"
|
<Input />
|
||||||
rules={[
|
</Form.Item>
|
||||||
{
|
<Form.Item
|
||||||
required: true,
|
label={t("invoices.fields.date")}
|
||||||
message: t("general.validation.required")
|
name="date"
|
||||||
}
|
rules={[
|
||||||
]}
|
{
|
||||||
>
|
required: true,
|
||||||
<Select
|
message: t("general.validation.required")
|
||||||
showSearch
|
}
|
||||||
onSelect={handleVendorSelect}
|
]}
|
||||||
style={{ width: "300px" }}
|
>
|
||||||
>
|
<DatePicker />
|
||||||
{vendorAutoCompleteOptions
|
</Form.Item>
|
||||||
? vendorAutoCompleteOptions.map(o => (
|
<Form.Item
|
||||||
<Select.Option key={o.id} value={o.name}>
|
label={t("invoices.fields.is_credit_memo")}
|
||||||
<div style={{ display: "flex" }}>
|
name="is_credit_memo"
|
||||||
{o.name}
|
valuePropName="checked"
|
||||||
<Tag color="green">{`${o.discount * 100}%`}</Tag>
|
>
|
||||||
</div>
|
<Switch />
|
||||||
</Select.Option>
|
</Form.Item>
|
||||||
))
|
<Form.Item
|
||||||
: null}
|
label={t("invoices.fields.total")}
|
||||||
</Select>
|
name="total"
|
||||||
</Form.Item>
|
rules={[
|
||||||
|
{
|
||||||
<Button onClick={() => resetFields()}>
|
required: true,
|
||||||
{t("general.actions.reset")}
|
message: t("general.validation.required")
|
||||||
</Button>
|
}
|
||||||
</div>
|
]}
|
||||||
<div style={{ display: "flex" }}>
|
>
|
||||||
<Form.Item
|
<CurrencyInput />
|
||||||
label={t("invoices.fields.invoice_number")}
|
</Form.Item>
|
||||||
name="invoice_number"
|
</div>
|
||||||
rules={[
|
<InvoiceEnterModalLinesComponent
|
||||||
{
|
lineData={lineData}
|
||||||
required: true,
|
discount={discount}
|
||||||
message: t("general.validation.required")
|
form={form}
|
||||||
}
|
responsibilityCenters={responsibilityCenters}
|
||||||
]}
|
/>
|
||||||
>
|
</div>
|
||||||
<Input />
|
|
||||||
</Form.Item>
|
|
||||||
<Form.Item
|
|
||||||
label={t("invoices.fields.date")}
|
|
||||||
name="date"
|
|
||||||
rules={[
|
|
||||||
{
|
|
||||||
required: true,
|
|
||||||
message: t("general.validation.required")
|
|
||||||
}
|
|
||||||
]}
|
|
||||||
>
|
|
||||||
<DatePicker />
|
|
||||||
</Form.Item>
|
|
||||||
<Form.Item
|
|
||||||
label={t("invoices.fields.is_credit_memo")}
|
|
||||||
name="is_credit_memo"
|
|
||||||
valuePropName="checked"
|
|
||||||
>
|
|
||||||
<Switch />
|
|
||||||
</Form.Item>
|
|
||||||
<Form.Item
|
|
||||||
label={t("invoices.fields.total")}
|
|
||||||
name="total"
|
|
||||||
rules={[
|
|
||||||
{
|
|
||||||
required: true,
|
|
||||||
message: t("general.validation.required")
|
|
||||||
}
|
|
||||||
]}
|
|
||||||
>
|
|
||||||
<CurrencyInput />
|
|
||||||
</Form.Item>
|
|
||||||
</div>
|
|
||||||
<InvoiceEnterModalLinesComponent
|
|
||||||
lineData={lineData}
|
|
||||||
discount={vendor && vendor.discount}
|
|
||||||
form={form}
|
|
||||||
responsibilityCenters={responsibilityCenters}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<Button onClick={() => console.log(form.getFieldsValue())}>
|
|
||||||
Field Values
|
|
||||||
</Button>
|
|
||||||
</Modal>
|
|
||||||
</Form>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
|
import { useLazyQuery, useMutation, useQuery } from "@apollo/react-hooks";
|
||||||
|
import { Form, Modal, notification } from "antd";
|
||||||
import React, { useState } from "react";
|
import React, { useState } from "react";
|
||||||
import { notification } from "antd";
|
import { useTranslation } from "react-i18next";
|
||||||
import { useLazyQuery, useQuery, useMutation } from "@apollo/react-hooks";
|
|
||||||
import { connect } from "react-redux";
|
import { connect } from "react-redux";
|
||||||
import { createStructuredSelector } from "reselect";
|
import { createStructuredSelector } from "reselect";
|
||||||
|
import { INSERT_NEW_INVOICE } from "../../graphql/invoices.queries";
|
||||||
import { GET_JOB_LINES_TO_ENTER_INVOICE } from "../../graphql/jobs-lines.queries";
|
import { GET_JOB_LINES_TO_ENTER_INVOICE } from "../../graphql/jobs-lines.queries";
|
||||||
import { ACTIVE_JOBS_FOR_AUTOCOMPLETE } from "../../graphql/jobs.queries";
|
import { ACTIVE_JOBS_FOR_AUTOCOMPLETE } from "../../graphql/jobs.queries";
|
||||||
import { SEARCH_VENDOR_AUTOCOMPLETE } from "../../graphql/vendors.queries";
|
import { SEARCH_VENDOR_AUTOCOMPLETE } from "../../graphql/vendors.queries";
|
||||||
@@ -10,8 +12,6 @@ import { toggleModalVisible } from "../../redux/modals/modals.actions";
|
|||||||
import { selectInvoiceEnterModal } from "../../redux/modals/modals.selectors";
|
import { selectInvoiceEnterModal } from "../../redux/modals/modals.selectors";
|
||||||
import { selectBodyshop } from "../../redux/user/user.selectors";
|
import { selectBodyshop } from "../../redux/user/user.selectors";
|
||||||
import InvoiceEnterModalComponent from "./invoice-enter-modal.component";
|
import InvoiceEnterModalComponent from "./invoice-enter-modal.component";
|
||||||
import { INSERT_NEW_INVOICE } from "../../graphql/invoices.queries";
|
|
||||||
import { useTranslation } from "react-i18next";
|
|
||||||
|
|
||||||
const mapStateToProps = createStructuredSelector({
|
const mapStateToProps = createStructuredSelector({
|
||||||
invoiceEnterModal: selectInvoiceEnterModal,
|
invoiceEnterModal: selectInvoiceEnterModal,
|
||||||
@@ -26,10 +26,9 @@ function InvoiceEnterModalContainer({
|
|||||||
toggleModalVisible,
|
toggleModalVisible,
|
||||||
bodyshop
|
bodyshop
|
||||||
}) {
|
}) {
|
||||||
|
const [form] = Form.useForm();
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const linesState = useState([]);
|
const linesState = useState([]);
|
||||||
const roSearchState = useState({ text: "", selectedId: null });
|
|
||||||
const [roSearch, setRoSearch] = roSearchState;
|
|
||||||
|
|
||||||
const [insertInvoice] = useMutation(INSERT_NEW_INVOICE);
|
const [insertInvoice] = useMutation(INSERT_NEW_INVOICE);
|
||||||
|
|
||||||
@@ -39,11 +38,6 @@ function InvoiceEnterModalContainer({
|
|||||||
skip: !invoiceEnterModal.visible
|
skip: !invoiceEnterModal.visible
|
||||||
});
|
});
|
||||||
|
|
||||||
const vendorSearchState = useState({
|
|
||||||
text: "",
|
|
||||||
selectedId: null
|
|
||||||
});
|
|
||||||
const [vendorSearch, setVendorSearch] = vendorSearchState;
|
|
||||||
const { data: VendorAutoCompleteData } = useQuery(
|
const { data: VendorAutoCompleteData } = useQuery(
|
||||||
SEARCH_VENDOR_AUTOCOMPLETE,
|
SEARCH_VENDOR_AUTOCOMPLETE,
|
||||||
{
|
{
|
||||||
@@ -52,53 +46,33 @@ function InvoiceEnterModalContainer({
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
const [loadLines, { called, data: lineData }] = useLazyQuery(
|
const [loadLines, { data: lineData }] = useLazyQuery(
|
||||||
GET_JOB_LINES_TO_ENTER_INVOICE,
|
GET_JOB_LINES_TO_ENTER_INVOICE,
|
||||||
{
|
{
|
||||||
fetchPolicy: "network-only",
|
fetchPolicy: "network-only"
|
||||||
variables: { id: roSearch.selectedId }
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
if (roSearch.selectedId) {
|
|
||||||
if (!called) loadLines();
|
|
||||||
}
|
|
||||||
const handleRoSelect = (value, obj) => {
|
|
||||||
setRoSearch({ ...roSearch, selectedId: obj.key });
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleVendorSelect = (value, obj) => {
|
|
||||||
setVendorSearch({ ...vendorSearch, selectedId: obj.key });
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleFinish = values => {
|
const handleFinish = values => {
|
||||||
insertInvoice({
|
insertInvoice({
|
||||||
variables: {
|
variables: {
|
||||||
invoice: [
|
invoice: [
|
||||||
Object.assign(
|
Object.assign({}, values, {
|
||||||
{},
|
invoicelines: { data: values.invoicelines }
|
||||||
values,
|
})
|
||||||
{ jobid: roSearch.selectedId },
|
|
||||||
{ vendorid: vendorSearch.selectedId },
|
|
||||||
{ invoicelines: { data: values.invoicelines } }
|
|
||||||
)
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.then(r => {
|
.then(r => {
|
||||||
// if (jobLineEditModal.actions.refetch)
|
|
||||||
// jobLineEditModal.actions.refetch();
|
|
||||||
// toggleModalVisible();
|
|
||||||
notification["success"]({
|
notification["success"]({
|
||||||
message: t("invoices.successes.created")
|
message: t("invoices.successes.created")
|
||||||
});
|
});
|
||||||
|
toggleModalVisible();
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
console.log("error", error);
|
|
||||||
|
|
||||||
notification["error"]({
|
notification["error"]({
|
||||||
message: t("invoices.errors.creating", {
|
message: t("invoices.errors.creating", {
|
||||||
message: error.message
|
message: JSON.stringify(error)
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -109,30 +83,33 @@ function InvoiceEnterModalContainer({
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<InvoiceEnterModalComponent
|
<Modal
|
||||||
|
title={
|
||||||
|
invoiceEnterModal.context && invoiceEnterModal.context.id
|
||||||
|
? t("invoices.labels.edit")
|
||||||
|
: t("invoices.labels.new")
|
||||||
|
}
|
||||||
|
width={"90%"}
|
||||||
visible={invoiceEnterModal.visible}
|
visible={invoiceEnterModal.visible}
|
||||||
invoice={invoiceEnterModal.context}
|
okText={t("general.actions.save")}
|
||||||
handleFinish={handleFinish}
|
onOk={() => form.submit()}
|
||||||
handleCancel={handleCancel}
|
onCancel={handleCancel}
|
||||||
handleRoSelect={handleRoSelect}
|
destroyOnClose
|
||||||
roAutoCompleteOptions={RoAutoCompleteData && RoAutoCompleteData.jobs}
|
>
|
||||||
handleVendorSelect={handleVendorSelect}
|
<Form onFinish={handleFinish} autoComplete={"off"} form={form}>
|
||||||
vendorAutoCompleteOptions={
|
<InvoiceEnterModalComponent
|
||||||
VendorAutoCompleteData && VendorAutoCompleteData.vendors
|
form={form}
|
||||||
}
|
roAutoCompleteOptions={RoAutoCompleteData && RoAutoCompleteData.jobs}
|
||||||
linesState={linesState}
|
vendorAutoCompleteOptions={
|
||||||
lineData={lineData ? lineData.joblines : null}
|
VendorAutoCompleteData && VendorAutoCompleteData.vendors
|
||||||
vendor={
|
}
|
||||||
vendorSearch.selectedId
|
loadLines={loadLines}
|
||||||
? VendorAutoCompleteData &&
|
linesState={linesState}
|
||||||
VendorAutoCompleteData.vendors.filter(
|
lineData={lineData ? lineData.joblines : null}
|
||||||
v => v.id === vendorSearch.selectedId
|
responsibilityCenters={bodyshop.md_responsibility_centers || null}
|
||||||
)[0]
|
/>
|
||||||
: null
|
</Form>
|
||||||
}
|
</Modal>
|
||||||
job={invoiceEnterModal.context.job || null}
|
|
||||||
responsibilityCenters={bodyshop.md_responsibility_centers || null}
|
|
||||||
/>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,19 @@ export default function InvoiceEnterModalLinesComponent({
|
|||||||
|
|
||||||
const [amounts, setAmounts] = useState({ invoiceTotal: 0, enteredAmount: 0 });
|
const [amounts, setAmounts] = useState({ invoiceTotal: 0, enteredAmount: 0 });
|
||||||
|
|
||||||
|
const calculateTotals = () => {
|
||||||
|
setAmounts({
|
||||||
|
invoiceTotal: getFieldsValue().total,
|
||||||
|
enteredTotal: getFieldsValue("invoicelines").invoicelines
|
||||||
|
? getFieldsValue("invoicelines").invoicelines.reduce(
|
||||||
|
(acc, value) =>
|
||||||
|
acc + (value && value.actual_cost ? value.actual_cost : 0),
|
||||||
|
0
|
||||||
|
)
|
||||||
|
: 0
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<Form.List name="invoicelines">
|
<Form.List name="invoicelines">
|
||||||
@@ -28,7 +41,6 @@ export default function InvoiceEnterModalLinesComponent({
|
|||||||
<Form.Item
|
<Form.Item
|
||||||
label={t("invoicelines.fields.line_desc")}
|
label={t("invoicelines.fields.line_desc")}
|
||||||
key={`${index}joblinename`}
|
key={`${index}joblinename`}
|
||||||
name={[field.name, "joblinename"]}
|
|
||||||
rules={[
|
rules={[
|
||||||
{
|
{
|
||||||
required: true,
|
required: true,
|
||||||
@@ -110,6 +122,13 @@ export default function InvoiceEnterModalLinesComponent({
|
|||||||
label={t("invoicelines.fields.line_desc")}
|
label={t("invoicelines.fields.line_desc")}
|
||||||
key={`${index}line_desc`}
|
key={`${index}line_desc`}
|
||||||
name={[field.name, "line_desc"]}
|
name={[field.name, "line_desc"]}
|
||||||
|
rules={[
|
||||||
|
{
|
||||||
|
required: !getFieldsValue("invoicelines")
|
||||||
|
.invoicelines[index].joblineid,
|
||||||
|
message: t("general.validation.required")
|
||||||
|
}
|
||||||
|
]}
|
||||||
>
|
>
|
||||||
<Input />
|
<Input />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
@@ -135,8 +154,10 @@ export default function InvoiceEnterModalLinesComponent({
|
|||||||
if (idx === index) {
|
if (idx === index) {
|
||||||
return {
|
return {
|
||||||
...item,
|
...item,
|
||||||
actual_cost:
|
actual_cost: !!item.actual_cost
|
||||||
parseFloat(e.target.value) * (1 - discount)
|
? item.actual_cost
|
||||||
|
: parseFloat(e.target.value) *
|
||||||
|
(1 - discount)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
return item;
|
return item;
|
||||||
@@ -156,26 +177,7 @@ export default function InvoiceEnterModalLinesComponent({
|
|||||||
}
|
}
|
||||||
]}
|
]}
|
||||||
>
|
>
|
||||||
<CurrencyInput
|
<CurrencyInput onBlur={() => calculateTotals()} />
|
||||||
onBlur={() =>
|
|
||||||
setAmounts({
|
|
||||||
invoiceTotal: getFieldsValue().total,
|
|
||||||
enteredTotal: getFieldsValue("invoicelines")
|
|
||||||
.invoicelines
|
|
||||||
? getFieldsValue(
|
|
||||||
"invoicelines"
|
|
||||||
).invoicelines.reduce(
|
|
||||||
(acc, value) =>
|
|
||||||
acc +
|
|
||||||
(value && value.actual_cost
|
|
||||||
? value.actual_cost
|
|
||||||
: 0),
|
|
||||||
0
|
|
||||||
)
|
|
||||||
: 0
|
|
||||||
})
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
<Form.Item
|
<Form.Item
|
||||||
label={t("invoicelines.fields.cost_center")}
|
label={t("invoicelines.fields.cost_center")}
|
||||||
@@ -198,6 +200,7 @@ export default function InvoiceEnterModalLinesComponent({
|
|||||||
<DeleteFilled
|
<DeleteFilled
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
remove(field.name);
|
remove(field.name);
|
||||||
|
calculateTotals();
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -0,0 +1,40 @@
|
|||||||
|
import { Select } from "antd";
|
||||||
|
import React, { useEffect, useState } from "react";
|
||||||
|
const { Option } = Select;
|
||||||
|
|
||||||
|
//To be used as a form element only.
|
||||||
|
|
||||||
|
const JobSearchSelect = ({ value, onChange, options, onBlur }) => {
|
||||||
|
const [option, setOption] = useState(value);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (onChange) {
|
||||||
|
onChange(option);
|
||||||
|
}
|
||||||
|
}, [option, onChange]);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Select
|
||||||
|
showSearch
|
||||||
|
autoFocus
|
||||||
|
value={option}
|
||||||
|
style={{
|
||||||
|
width: 300
|
||||||
|
}}
|
||||||
|
onChange={setOption}
|
||||||
|
optionFilterProp="children"
|
||||||
|
onBlur={onBlur}
|
||||||
|
>
|
||||||
|
{options
|
||||||
|
? options.map(o => (
|
||||||
|
<Option key={o.id} value={o.id}>
|
||||||
|
{`${o.ro_number ? o.ro_number : o.est_number} | ${o.ownr_ln ||
|
||||||
|
""} ${o.ownr_fn || ""} | ${o.v_model_yr ||
|
||||||
|
""} ${o.v_make_desc || ""} ${o.v_model_desc || ""}`}
|
||||||
|
</Option>
|
||||||
|
))
|
||||||
|
: null}
|
||||||
|
</Select>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
export default JobSearchSelect;
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
import { Select, Tag } from "antd";
|
||||||
|
import React, { useEffect, useState } from "react";
|
||||||
|
const { Option } = Select;
|
||||||
|
|
||||||
|
//To be used as a form element only.
|
||||||
|
|
||||||
|
const VendorSearchSelect = ({ value, onChange, options, onSelect }) => {
|
||||||
|
const [option, setOption] = useState(value);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (onChange) {
|
||||||
|
onChange(option);
|
||||||
|
}
|
||||||
|
}, [option, onChange]);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Select
|
||||||
|
showSearch
|
||||||
|
value={option}
|
||||||
|
style={{
|
||||||
|
width: 300
|
||||||
|
}}
|
||||||
|
onChange={setOption}
|
||||||
|
optionFilterProp="children"
|
||||||
|
onSelect={onSelect}
|
||||||
|
>
|
||||||
|
{options
|
||||||
|
? options.map(o => (
|
||||||
|
<Option key={o.id} value={o.id} discount={o.discount}>
|
||||||
|
<div style={{ display: "flex" }}>
|
||||||
|
{o.name}
|
||||||
|
<Tag color="green">{`${o.discount * 100}%`}</Tag>
|
||||||
|
</div>
|
||||||
|
</Option>
|
||||||
|
))
|
||||||
|
: null}
|
||||||
|
</Select>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
export default VendorSearchSelect;
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
import { Button, Typography } from "antd";
|
import { Button, Typography, Row, Col } from "antd";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { connect } from "react-redux";
|
import { connect } from "react-redux";
|
||||||
@@ -22,28 +22,38 @@ export function ContractDetailPage({
|
|||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<Typography.Title>{`Agreement ${(contract && contract.agreementnumber) ||
|
<Row align="middle">
|
||||||
""}`}</Typography.Title>
|
<Typography.Title>{`Agreement ${(contract &&
|
||||||
<Button type="primary" htmlType="submit">
|
contract.agreementnumber) ||
|
||||||
{t("general.actions.save")}
|
""} - ${t((contract && contract.status) || "")}`}</Typography.Title>
|
||||||
</Button>
|
<Button type="primary" htmlType="submit">
|
||||||
<Button
|
{t("general.actions.save")}
|
||||||
disabled={contract && contract.status !== "contracts.status.out"}
|
</Button>
|
||||||
onClick={() => {
|
<Button
|
||||||
setCourtesyCarReturnModalContext({
|
disabled={contract && contract.status !== "contracts.status.out"}
|
||||||
actions: { refetch },
|
onClick={() => {
|
||||||
context: {
|
setCourtesyCarReturnModalContext({
|
||||||
contractId: contract.id,
|
actions: { refetch },
|
||||||
courtesyCarId: courtesyCar.id
|
context: {
|
||||||
}
|
contractId: contract.id,
|
||||||
});
|
courtesyCarId: courtesyCar.id
|
||||||
}}
|
}
|
||||||
>
|
});
|
||||||
{t("courtesycars.actions.return")}
|
}}
|
||||||
</Button>
|
>
|
||||||
<ContractJobBlock job={job} />
|
{t("courtesycars.actions.return")}
|
||||||
<ContractCourtesyCarBlock courtesyCar={courtesyCar} />
|
</Button>
|
||||||
<ContractFormComponent />
|
</Row>
|
||||||
|
|
||||||
|
<Row>
|
||||||
|
<Col span={4} offset={1}>
|
||||||
|
<ContractJobBlock job={job} />
|
||||||
|
<ContractCourtesyCarBlock courtesyCar={courtesyCar} />
|
||||||
|
</Col>
|
||||||
|
<Col span={18} offset={1}>
|
||||||
|
<ContractFormComponent />
|
||||||
|
</Col>
|
||||||
|
</Row>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user