From 43c771b4f6147dfc3436fe6b359a99bfb719a8ca Mon Sep 17 00:00:00 2001 From: Patrick Fic <> Date: Mon, 8 Mar 2021 17:05:06 -0800 Subject: [PATCH] IO-747 CCC Scroll to Job in Table on create --- .../contract-cars/contract-cars.component.jsx | 7 +++++ .../contract-jobs/contract-jobs.component.jsx | 28 ++++++++++++++++--- server/job/job-totals.js | 8 ++---- 3 files changed, 34 insertions(+), 9 deletions(-) diff --git a/client/src/components/contract-cars/contract-cars.component.jsx b/client/src/components/contract-cars/contract-cars.component.jsx index b0388db95..64853af8f 100644 --- a/client/src/components/contract-cars/contract-cars.component.jsx +++ b/client/src/components/contract-cars/contract-cars.component.jsx @@ -117,6 +117,13 @@ export default function ContractsCarsComponent({ type: "radio", selectedRowKeys: [selectedCar], }} + onRow={(record, rowIndex) => { + return { + onClick: (event) => { + handleSelect(record); + }, + }; + }} /> ); } diff --git a/client/src/components/contract-jobs/contract-jobs.component.jsx b/client/src/components/contract-jobs/contract-jobs.component.jsx index 1d6e3b272..8558109f9 100644 --- a/client/src/components/contract-jobs/contract-jobs.component.jsx +++ b/client/src/components/contract-jobs/contract-jobs.component.jsx @@ -1,7 +1,8 @@ -import { Table, Input } from "antd"; -import React, { useState } from "react"; +import { Input, Table } from "antd"; +import React, { useState, useMemo } from "react"; import { useTranslation } from "react-i18next"; import { alphaSort } from "../../utils/sorters"; +import LoadingSkeleton from "../loading-skeleton/loading-skeleton.component"; export default function ContractsJobsComponent({ loading, @@ -158,6 +159,15 @@ export default function ContractsJobsComponent({ .includes(state.search.toLowerCase()) ); + const defaultCurrent = useMemo(() => { + return ( + Math.round( + ((filteredData.findIndex((v) => v.id === selectedJob) || 0) + 1) / 10 + ) + 1 + ); + }, [filteredData, selectedJob]); + + if (loading) return ; return ( )} size="small" - pagination={{ position: "top" }} - columns={columns.map((item) => ({ ...item }))} + pagination={{ + position: "top", + defaultCurrent: defaultCurrent, + }} + columns={columns} rowKey="id" dataSource={filteredData} onChange={handleTableChange} @@ -179,6 +192,13 @@ export default function ContractsJobsComponent({ type: "radio", selectedRowKeys: [selectedJob], }} + onRow={(record, rowIndex) => { + return { + onClick: (event) => { + handleSelect(record); + }, + }; + }} /> ); } diff --git a/server/job/job-totals.js b/server/job/job-totals.js index b2e28522c..6d07d7073 100644 --- a/server/job/job-totals.js +++ b/server/job/job-totals.js @@ -173,9 +173,9 @@ function CalculateRatesTotals(ratesList, shoprates) { let subtotal = Dinero({ amount: 0 }); let rates_subtotal = Dinero({ amount: 0 }); for (const property in ret) { - ret[property].total = Dinero({ amount: ret[property].rate * 100 }).multiply( - ret[property].hours - ); + ret[property].total = Dinero({ + amount: Math.round((ret[property].rate || 0) * 100), + }).multiply(ret[property].hours); subtotal = subtotal.add(ret[property].total); if (property !== "mapa" && property !== "mash") rates_subtotal = rates_subtotal.add(ret[property].total); @@ -336,7 +336,6 @@ function CalculateTaxesTotals(job, otherTotals) { 0) * 100 ) ); - console.log("A", additionalItemsTax.toJSON()); } else { statePartsTax = statePartsTax.add( Dinero({ amount: Math.round((val.act_price || 0) * 100) }) @@ -348,7 +347,6 @@ function CalculateTaxesTotals(job, otherTotals) { 0) * 100 ) ); - console.log("S", statePartsTax.toJSON()); } });