IO-244 IOU Bug Fixes

This commit is contained in:
Patrick Fic
2021-12-14 09:48:11 -08:00
parent 273456d1fd
commit 91e70750d6
3 changed files with 10 additions and 12 deletions

View File

@@ -21,12 +21,7 @@ const mapDispatchToProps = (dispatch) => ({
}); });
export default connect(mapStateToProps, mapDispatchToProps)(JobCreateIOU); export default connect(mapStateToProps, mapDispatchToProps)(JobCreateIOU);
export function JobCreateIOU({ export function JobCreateIOU({ bodyshop, currentUser, job, selectedJobLines }) {
bodyshop,
currentUser,
jobid,
selectedJobLines,
}) {
const { t } = useTranslation(); const { t } = useTranslation();
const [loading, setLoading] = useState(false); const [loading, setLoading] = useState(false);
const client = useApolloClient(); const client = useApolloClient();
@@ -44,7 +39,7 @@ export function JobCreateIOU({
//Query all of the job details to recreate. //Query all of the job details to recreate.
const iouId = await CreateIouForJob( const iouId = await CreateIouForJob(
client, client,
jobid, job.id,
{ {
status: bodyshop.md_ro_statuses.default_open, status: bodyshop.md_ro_statuses.default_open,
bodyshopid: bodyshop.id, bodyshopid: bodyshop.id,
@@ -63,7 +58,7 @@ export function JobCreateIOU({
variables: { ids: selectedJobLinesIds }, variables: { ids: selectedJobLinesIds },
update(cache) { update(cache) {
cache.modify({ cache.modify({
id: cache.identify(jobid), id: cache.identify(job.id),
fields: { fields: {
joblines(existingJobLines, { readField }) { joblines(existingJobLines, { readField }) {
return existingJobLines.map((a) => { return existingJobLines.map((a) => {
@@ -86,7 +81,9 @@ export function JobCreateIOU({
> >
<Button <Button
loading={loading} loading={loading}
disabled={!selectedJobLines || selectedJobLines.length === 0} disabled={
!selectedJobLines || selectedJobLines.length === 0 || !job.converted
}
> >
{t("jobs.actions.createiou")} {t("jobs.actions.createiou")}
</Button> </Button>

View File

@@ -428,7 +428,7 @@ export function JobLinesComponent({
> >
{t("joblines.actions.new")} {t("joblines.actions.new")}
</Button> </Button>
<JobCreateIOU jobid={job.id} selectedJobLines={selectedLines} /> <JobCreateIOU job={job} selectedJobLines={selectedLines} />
<Input.Search <Input.Search
placeholder={t("general.labels.search")} placeholder={t("general.labels.search")}
onChange={(e) => { onChange={(e) => {

View File

@@ -108,8 +108,9 @@ export async function CreateIouForJob(
_tempLines.forEach((line) => { _tempLines.forEach((line) => {
delete line.id; delete line.id;
delete line.__typename; delete line.__typename;
line.oem_partno = `line.oem_partno - IOU Price $${line.act_price}` line.oem_partno = `${line.oem_partno} - IOU $${line.act_price}/${line.mod_lb_hrs}hrs`;
delete line.act_price; line.act_price = 0;
line.mod_lb_hrs = 0;
line.manual_line = true; line.manual_line = true;
}); });