IO-747 Update CCC auto pagination

IO-751 Resolve job close hang with unsaved changes
This commit is contained in:
Patrick Fic
2021-03-09 17:57:14 +00:00
2 changed files with 18 additions and 10 deletions

View File

@@ -1,5 +1,5 @@
import { Input, Table } from "antd";
import React, { useState, useMemo } from "react";
import React, { useMemo, useState } from "react";
import { useTranslation } from "react-i18next";
import { alphaSort } from "../../utils/sorters";
import LoadingSkeleton from "../loading-skeleton/loading-skeleton.component";
@@ -160,11 +160,12 @@ export default function ContractsJobsComponent({
);
const defaultCurrent = useMemo(() => {
return (
Math.round(
((filteredData.findIndex((v) => v.id === selectedJob) || 0) + 1) / 10
) + 1
);
const page =
Math.floor(
(filteredData.findIndex((v) => v.id === selectedJob) || 0) / 3
) + 1;
return page;
}, [filteredData, selectedJob]);
if (loading) return <LoadingSkeleton />;
@@ -181,6 +182,7 @@ export default function ContractsJobsComponent({
size="small"
pagination={{
position: "top",
defaultPageSize: 3,
defaultCurrent: defaultCurrent,
}}
columns={columns}

View File

@@ -1,6 +1,6 @@
import { useApolloClient, useMutation } from "@apollo/client";
import { Button, Form, notification, Popconfirm, Space } from "antd";
import React, { useState } from "react";
import { useApolloClient, useMutation } from "@apollo/client";
import { useTranslation } from "react-i18next";
import { connect } from "react-redux";
import { useHistory } from "react-router-dom";
@@ -34,6 +34,8 @@ export function JobsCloseComponent({ job, bodyshop, jobRO }) {
setLoading(true);
const result = await client.mutate({
mutation: generateJobLinesUpdatesForInvoicing(values.joblines),
refetchQueries: ["QUERY_JOB_CLOSE_DETAILS"],
awaitRefetchQueries: true,
});
if (!!!result.errors) {
notification["success"]({ message: t("jobs.successes.save") });
@@ -45,8 +47,8 @@ export function JobsCloseComponent({ job, bodyshop, jobRO }) {
}),
});
}
// form.resetFields();
// form.resetFields();
form.resetFields();
form.resetFields();
setLoading(false);
};
@@ -63,7 +65,11 @@ export function JobsCloseComponent({ job, bodyshop, jobRO }) {
});
if (!!!result.errors) {
notification["success"]({ message: t("job.successes.closed") });
setLoading(false);
notification["success"]({
message: t("jobs.successes.closed"),
});
history.push(`/manage/jobs/${job.id}`);
} else {
setLoading(false);