Reformat all project files to use the prettier config file.
This commit is contained in:
@@ -9,96 +9,89 @@ import InstanceRenderManager from "../../utils/instanceRenderMgr";
|
||||
import CurrencyFormItemComponent from "../form-items-formatted/currency-form-item.component";
|
||||
import JobLineConvertToLabor from "../job-line-convert-to-labor/job-line-convert-to-labor.component";
|
||||
|
||||
export default function JobLinesPartPriceChange({job, line, refetch}) {
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [updatePartPrice] = useMutation(UPDATE_LINE_PPC);
|
||||
export default function JobLinesPartPriceChange({ job, line, refetch }) {
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [updatePartPrice] = useMutation(UPDATE_LINE_PPC);
|
||||
|
||||
const handleFinish = async (values) => {
|
||||
try {
|
||||
setLoading(true);
|
||||
const result = await updatePartPrice({
|
||||
variables: {
|
||||
id: line.id,
|
||||
jobline: {
|
||||
act_price_before_ppc: line.act_price_before_ppc
|
||||
? line.act_price_before_ppc
|
||||
: line.act_price,
|
||||
act_price: values.act_price,
|
||||
},
|
||||
},
|
||||
});
|
||||
await axios.post("/job/totalsssu", {
|
||||
id: job.id,
|
||||
});
|
||||
if (result.errors) {
|
||||
notification.open({
|
||||
type: "error",
|
||||
message: t("joblines.errors.saving", {
|
||||
error: JSON.stringify(result.errors),
|
||||
}),
|
||||
});
|
||||
if (refetch) refetch();
|
||||
} else {
|
||||
notification.open({
|
||||
type: "success",
|
||||
message: t("joblines.successes.saved"),
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
notification.open({
|
||||
type: "error",
|
||||
message: t("joblines.errors.saving", {error: JSON.stringify(error)}),
|
||||
});
|
||||
} finally {
|
||||
setLoading(false);
|
||||
const handleFinish = async (values) => {
|
||||
try {
|
||||
setLoading(true);
|
||||
const result = await updatePartPrice({
|
||||
variables: {
|
||||
id: line.id,
|
||||
jobline: {
|
||||
act_price_before_ppc: line.act_price_before_ppc ? line.act_price_before_ppc : line.act_price,
|
||||
act_price: values.act_price
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
||||
await axios.post("/job/totalsssu", {
|
||||
id: job.id
|
||||
});
|
||||
if (result.errors) {
|
||||
notification.open({
|
||||
type: "error",
|
||||
message: t("joblines.errors.saving", {
|
||||
error: JSON.stringify(result.errors)
|
||||
})
|
||||
});
|
||||
if (refetch) refetch();
|
||||
} else {
|
||||
notification.open({
|
||||
type: "success",
|
||||
message: t("joblines.successes.saved")
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
notification.open({
|
||||
type: "error",
|
||||
message: t("joblines.errors.saving", { error: JSON.stringify(error) })
|
||||
});
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
const popcontent = InstanceRenderManager({
|
||||
imex: null,
|
||||
rome: (
|
||||
<Form layout="vertical" onFinish={handleFinish} initialValues={{act_price: line.act_price}}>
|
||||
<Form.Item
|
||||
name="act_price"
|
||||
label={t("jobs.labels.act_price_ppc")}
|
||||
rules={[{required: true}]}
|
||||
>
|
||||
<CurrencyFormItemComponent/>
|
||||
</Form.Item>
|
||||
<Button disabled={InstanceRenderManager({imex:true, rome: false, promanager: true})} loading={loading} htmlType="primary">
|
||||
{t("general.actions.save")}
|
||||
</Button>
|
||||
</Form>
|
||||
const popcontent = InstanceRenderManager({
|
||||
imex: null,
|
||||
rome: (
|
||||
<Form layout="vertical" onFinish={handleFinish} initialValues={{ act_price: line.act_price }}>
|
||||
<Form.Item name="act_price" label={t("jobs.labels.act_price_ppc")} rules={[{ required: true }]}>
|
||||
<CurrencyFormItemComponent />
|
||||
</Form.Item>
|
||||
<Button
|
||||
disabled={InstanceRenderManager({ imex: true, rome: false, promanager: true })}
|
||||
loading={loading}
|
||||
htmlType="primary"
|
||||
>
|
||||
{t("general.actions.save")}
|
||||
</Button>
|
||||
</Form>
|
||||
),
|
||||
promanager: null
|
||||
}) ;
|
||||
promanager: null
|
||||
});
|
||||
|
||||
return (
|
||||
<JobLineConvertToLabor jobline={line} job={job}>
|
||||
<Popover trigger="click"
|
||||
disabled={true || line.manual_line} content={popcontent}>
|
||||
<CurrencyFormatter>
|
||||
{line.db_ref === "900510" || line.db_ref === "900511"
|
||||
? line.prt_dsmk_m
|
||||
: line.act_price}
|
||||
</CurrencyFormatter>
|
||||
{line.prt_dsmk_p && line.prt_dsmk_p !== 0 ? (
|
||||
<span style={{marginLeft: ".2rem"}}>{`(${line.prt_dsmk_p}%)`}</span>
|
||||
) : (
|
||||
<></>
|
||||
)}
|
||||
{line.act_price_before_ppc && line.act_price_before_ppc !== 0 ? (
|
||||
<Tooltip title={t("jobs.labels.ppc")}>
|
||||
<span style={{marginLeft: ".2rem", color: "tomato"}}>
|
||||
(
|
||||
<CurrencyFormatter>{line.act_price_before_ppc}</CurrencyFormatter>
|
||||
)
|
||||
return (
|
||||
<JobLineConvertToLabor jobline={line} job={job}>
|
||||
<Popover trigger="click" disabled={true || line.manual_line} content={popcontent}>
|
||||
<CurrencyFormatter>
|
||||
{line.db_ref === "900510" || line.db_ref === "900511" ? line.prt_dsmk_m : line.act_price}
|
||||
</CurrencyFormatter>
|
||||
{line.prt_dsmk_p && line.prt_dsmk_p !== 0 ? (
|
||||
<span style={{ marginLeft: ".2rem" }}>{`(${line.prt_dsmk_p}%)`}</span>
|
||||
) : (
|
||||
<></>
|
||||
)}
|
||||
{line.act_price_before_ppc && line.act_price_before_ppc !== 0 ? (
|
||||
<Tooltip title={t("jobs.labels.ppc")}>
|
||||
<span style={{ marginLeft: ".2rem", color: "tomato" }}>
|
||||
(<CurrencyFormatter>{line.act_price_before_ppc}</CurrencyFormatter>)
|
||||
</span>
|
||||
</Tooltip>
|
||||
) : (
|
||||
<></>
|
||||
)}
|
||||
</Popover>
|
||||
</JobLineConvertToLabor>
|
||||
);
|
||||
</Tooltip>
|
||||
) : (
|
||||
<></>
|
||||
)}
|
||||
</Popover>
|
||||
</JobLineConvertToLabor>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user