Renamed some owner fields to follow CIECA standard. Work on Owner Select modal.
This commit is contained in:
11
client/src/components/alert/alert.component.test.js
Normal file
11
client/src/components/alert/alert.component.test.js
Normal file
@@ -0,0 +1,11 @@
|
||||
import React from "react";
|
||||
import ReactDOM from "react-dom";
|
||||
import Alert from "./alert.component";
|
||||
import { MockedProvider } from "@apollo/react-testing";
|
||||
import { shallow } from "enzyme";
|
||||
|
||||
const div = document.createElement("div");
|
||||
|
||||
it("renders without crashing", () => {
|
||||
shallow(<Alert type="error" />);
|
||||
});
|
||||
@@ -1,22 +1,29 @@
|
||||
import { Input, Table, Button, Icon, notification } from "antd";
|
||||
import { Input, Table, Button, Icon, notification, Modal } from "antd";
|
||||
import React, { useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { alphaSort } from "../../utils/sorters";
|
||||
import { DateTimeFormatter } from "../../utils/DateFormatter";
|
||||
import OwnerFindModalContainer from "../owner-find-modal/owner-find-modal.container";
|
||||
export default function JobsAvailableComponent({
|
||||
loading,
|
||||
data,
|
||||
refetch,
|
||||
deleteJob,
|
||||
deleteAllNewJobs
|
||||
deleteAllNewJobs,
|
||||
insertNewJob,
|
||||
setJobId,
|
||||
estDataLazyLoad
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
const [loadEstData, estData] = estDataLazyLoad;
|
||||
|
||||
const [state, setState] = useState({
|
||||
sortedInfo: {},
|
||||
filteredInfo: { text: "" }
|
||||
});
|
||||
|
||||
const [modalVisible, setModalVisible] = useState(false);
|
||||
|
||||
const handleTableChange = (pagination, filters, sorter) => {
|
||||
setState({ ...state, filteredInfo: filters, sortedInfo: sorter });
|
||||
};
|
||||
@@ -114,7 +121,10 @@ export default function JobsAvailableComponent({
|
||||
</Button>
|
||||
<Button
|
||||
onClick={() => {
|
||||
alert("Add");
|
||||
console.log("record.id", record.id);
|
||||
|
||||
loadEstData({ variables: { id: record.id } });
|
||||
setModalVisible(true);
|
||||
}}
|
||||
>
|
||||
<Icon type="plus" />
|
||||
@@ -126,55 +136,88 @@ export default function JobsAvailableComponent({
|
||||
}
|
||||
];
|
||||
|
||||
console.log("estData", estData);
|
||||
|
||||
const owner =
|
||||
estData.data &&
|
||||
estData.data.available_jobs_by_pk &&
|
||||
estData.data.available_jobs_by_pk.est_data &&
|
||||
estData.data.available_jobs_by_pk.est_data.owner &&
|
||||
estData.data.available_jobs_by_pk.est_data.owner.data
|
||||
? estData.data.available_jobs_by_pk.est_data.owner.data
|
||||
: null;
|
||||
return (
|
||||
<Table
|
||||
loading={loading}
|
||||
title={() => {
|
||||
return (
|
||||
<div>
|
||||
<Input.Search
|
||||
placeholder="Search..."
|
||||
onSearch={value => {
|
||||
console.log(value);
|
||||
}}
|
||||
enterButton
|
||||
/>
|
||||
<Button
|
||||
onClick={() => {
|
||||
refetch();
|
||||
}}
|
||||
>
|
||||
<Icon type="sync" />
|
||||
</Button>
|
||||
<Button
|
||||
onClick={() => {
|
||||
deleteAllNewJobs()
|
||||
.then(r => {
|
||||
notification["success"]({
|
||||
message: t("jobs.successes.all_deleted", {
|
||||
count: r.data.delete_available_jobs.affected_rows
|
||||
})
|
||||
<div>
|
||||
<OwnerFindModalContainer
|
||||
loading={estData.loading}
|
||||
error={estData.error}
|
||||
owner={owner}
|
||||
visible={modalVisible}
|
||||
onOk={() => {
|
||||
setModalVisible(false);
|
||||
// insertNewJob({
|
||||
// variables: {
|
||||
// job: record.est_data
|
||||
// }
|
||||
// }).then(r => {
|
||||
// notification["success"]({
|
||||
// message: t("jobs.successes.created")
|
||||
// });
|
||||
// refetch();
|
||||
// });
|
||||
}}
|
||||
onCancel={() => setModalVisible(false)}
|
||||
/>
|
||||
|
||||
<Table
|
||||
loading={loading}
|
||||
title={() => {
|
||||
return (
|
||||
<div>
|
||||
<Input.Search
|
||||
placeholder="Search..."
|
||||
onSearch={value => {
|
||||
console.log(value);
|
||||
}}
|
||||
enterButton
|
||||
/>
|
||||
<Button
|
||||
onClick={() => {
|
||||
refetch();
|
||||
}}
|
||||
>
|
||||
<Icon type="sync" />
|
||||
</Button>
|
||||
<Button
|
||||
onClick={() => {
|
||||
deleteAllNewJobs()
|
||||
.then(r => {
|
||||
notification["success"]({
|
||||
message: t("jobs.successes.all_deleted", {
|
||||
count: r.data.delete_available_jobs.affected_rows
|
||||
})
|
||||
});
|
||||
refetch();
|
||||
})
|
||||
.catch(r => {
|
||||
notification["error"]({
|
||||
message: t("jobs.errors.deleted") + " " + r.message
|
||||
});
|
||||
});
|
||||
refetch();
|
||||
})
|
||||
.catch(r => {
|
||||
notification["error"]({
|
||||
message: t("jobs.errors.deleted") + " " + r.message
|
||||
});
|
||||
});
|
||||
}}
|
||||
>
|
||||
Delete All
|
||||
</Button>
|
||||
</div>
|
||||
);
|
||||
}}
|
||||
size="small"
|
||||
pagination={{ position: "top" }}
|
||||
columns={columns.map(item => ({ ...item }))}
|
||||
rowKey="id"
|
||||
dataSource={data && data.available_jobs}
|
||||
onChange={handleTableChange}
|
||||
/>
|
||||
}}
|
||||
>
|
||||
Delete All
|
||||
</Button>
|
||||
</div>
|
||||
);
|
||||
}}
|
||||
size="small"
|
||||
pagination={{ position: "top" }}
|
||||
columns={columns.map(item => ({ ...item }))}
|
||||
rowKey="id"
|
||||
dataSource={data && data.available_jobs}
|
||||
onChange={handleTableChange}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,19 +1,20 @@
|
||||
import React from "react";
|
||||
import { useQuery, useMutation } from "react-apollo";
|
||||
import { useMutation, useQuery } from "react-apollo";
|
||||
import {
|
||||
QUERY_AVAILABLE_NEW_JOBS,
|
||||
DELETE_AVAILABLE_JOB,
|
||||
DELETE_ALL_AVAILABLE_NEW_JOBS
|
||||
DELETE_ALL_AVAILABLE_NEW_JOBS,
|
||||
QUERY_AVAILABLE_NEW_JOBS
|
||||
} from "../../graphql/available-jobs.queries";
|
||||
import { INSERT_NEW_JOB } from "../../graphql/jobs.queries";
|
||||
import AlertComponent from "../alert/alert.component";
|
||||
import JobsAvailableComponent from "./jobs-available-new.component";
|
||||
|
||||
export default function JobsAvailableContainer() {
|
||||
export default function JobsAvailableContainer({ deleteJob, estDataLazyLoad }) {
|
||||
const { loading, error, data, refetch } = useQuery(QUERY_AVAILABLE_NEW_JOBS, {
|
||||
fetchPolicy: "network-only"
|
||||
});
|
||||
const [deleteJob] = useMutation(DELETE_AVAILABLE_JOB);
|
||||
|
||||
const [deleteAllNewJobs] = useMutation(DELETE_ALL_AVAILABLE_NEW_JOBS);
|
||||
const [insertNewJob] = useMutation(INSERT_NEW_JOB);
|
||||
|
||||
if (error) return <AlertComponent type="error" message={error.message} />;
|
||||
return (
|
||||
@@ -23,6 +24,8 @@ export default function JobsAvailableContainer() {
|
||||
refetch={refetch}
|
||||
deleteJob={deleteJob}
|
||||
deleteAllNewJobs={deleteAllNewJobs}
|
||||
insertNewJob={insertNewJob}
|
||||
estDataLazyLoad={estDataLazyLoad}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -8,7 +8,8 @@ export default function JobsAvailableSupplementComponent({
|
||||
data,
|
||||
refetch,
|
||||
deleteJob,
|
||||
deleteAllNewJobs
|
||||
deleteAllNewJobs,
|
||||
estDataLazyLoad
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
|
||||
|
||||
@@ -1,21 +1,19 @@
|
||||
import React from "react";
|
||||
import { useQuery, useMutation } from "react-apollo";
|
||||
import {
|
||||
QUERY_AVAILABLE_SUPPLEMENT_JOBS,
|
||||
DELETE_AVAILABLE_JOB,
|
||||
DELETE_ALL_AVAILABLE_SUPPLEMENT_JOBS
|
||||
} from "../../graphql/available-jobs.queries";
|
||||
import { useMutation, useQuery } from "react-apollo";
|
||||
import { DELETE_ALL_AVAILABLE_SUPPLEMENT_JOBS, QUERY_AVAILABLE_SUPPLEMENT_JOBS } from "../../graphql/available-jobs.queries";
|
||||
import AlertComponent from "../alert/alert.component";
|
||||
import JobsAvailableSupplementComponent from "./jobs-available-supplement.component";
|
||||
|
||||
export default function JobsAvailableSupplementContainer() {
|
||||
export default function JobsAvailableSupplementContainer({
|
||||
deleteJob,
|
||||
estDataLazyLoad
|
||||
}) {
|
||||
const { loading, error, data, refetch } = useQuery(
|
||||
QUERY_AVAILABLE_SUPPLEMENT_JOBS,
|
||||
{
|
||||
fetchPolicy: "network-only"
|
||||
}
|
||||
);
|
||||
const [deleteJob] = useMutation(DELETE_AVAILABLE_JOB);
|
||||
const [deleteAllNewJobs] = useMutation(DELETE_ALL_AVAILABLE_SUPPLEMENT_JOBS);
|
||||
|
||||
if (error) return <AlertComponent type="error" message={error.message} />;
|
||||
@@ -26,6 +24,7 @@ export default function JobsAvailableSupplementContainer() {
|
||||
refetch={refetch}
|
||||
deleteJob={deleteJob}
|
||||
deleteAllNewJobs={deleteAllNewJobs}
|
||||
estDataLazyLoad={estDataLazyLoad}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
import React from "react";
|
||||
export default function OwnerFindModalComponent() {
|
||||
return <div>Modal Componnentasdasd</div>;
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
import React from "react";
|
||||
import { Modal } from "antd";
|
||||
import OwnerFindModalComponent from "./owner-find-modal.component";
|
||||
import LoadingSpinner from "../loading-spinner/loading-spinner.component";
|
||||
import AlertComponent from "../alert/alert.component";
|
||||
import { json } from "body-parser";
|
||||
|
||||
export default function OwnerFindModalContainer({
|
||||
loading,
|
||||
error,
|
||||
owner,
|
||||
...modalProps
|
||||
}) {
|
||||
//use owner object to run query and find what possible owners there are.
|
||||
return (
|
||||
<Modal {...modalProps}>
|
||||
{loading ? <LoadingSpinner /> : null}
|
||||
{error ? <AlertComponent message={error.message} type="error" /> : null}
|
||||
{owner ? <OwnerFindModalComponent /> : null}
|
||||
{owner ? JSON.stringify(owner) : null}
|
||||
</Modal>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user