- Rough in front end / backend
Signed-off-by: Dave Richer <dave@imexsystems.ca>
This commit is contained in:
@@ -0,0 +1,77 @@
|
||||
import {createStructuredSelector} from "reselect";
|
||||
import {selectBodyshop} from "../../redux/user/user.selectors";
|
||||
import {connect} from "react-redux";
|
||||
import {useEffect, useState} from "react";
|
||||
import axios from "axios";
|
||||
import {Card, Space, Table, Timeline} from "antd";
|
||||
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
bodyshop: selectBodyshop,
|
||||
});
|
||||
const mapDispatchToProps = (dispatch) => ({
|
||||
//setUserLanguage: language => dispatch(setUserLanguage(language))
|
||||
});
|
||||
|
||||
export function JobLifecycleComponent({bodyshop, job, ...rest}) {
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [lifecycleData, setLifecycleData] = useState(null);
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
async function getLifecycleData() {
|
||||
if (job && job.id) {
|
||||
setLoading(true);
|
||||
const response = await axios.post("/job/lifecycle", {
|
||||
jobids: job.id,
|
||||
});
|
||||
console.dir(response.data.data.transitions, {depth: null});
|
||||
setLifecycleData(response.data.data.transitions);
|
||||
setLoading(false);
|
||||
}
|
||||
}
|
||||
|
||||
getLifecycleData().catch((err) => {
|
||||
console.log(`Something went wrong getting Job Lifecycle Data: ${err.message}`);
|
||||
setLoading(false);
|
||||
});
|
||||
}, [job]);
|
||||
|
||||
const columnKeys = [
|
||||
'start',
|
||||
'end',
|
||||
'value',
|
||||
'prev_value',
|
||||
'next_value',
|
||||
'duration',
|
||||
'type',
|
||||
'created_at',
|
||||
'updated_at'
|
||||
];
|
||||
|
||||
const columns = columnKeys.map(key => ({
|
||||
title: key.charAt(0).toUpperCase() + key.slice(1), // Capitalize the first letter for the title
|
||||
dataIndex: key,
|
||||
key: key,
|
||||
}));
|
||||
|
||||
return (
|
||||
<Card loading={loading} title='Job Lifecycle Component'>
|
||||
<Space direction='vertical' style={{width: '100%'}}>
|
||||
<Card type='inner' title='Table Format'>
|
||||
<Table loading={loading} columns={columns} dataSource={lifecycleData} />
|
||||
</Card>
|
||||
<Card type='inner' title='Timeline Format'>
|
||||
<Timeline loading={loading}>
|
||||
{lifecycleData.map((item, index) => (
|
||||
<Timeline.Item key={index} color={item.value === 'Open' ? 'green' : item.value === 'Scheduled' ? 'yellow' : 'red'}>
|
||||
{item.value} - {new Date(item.start).toLocaleString()}
|
||||
</Timeline.Item>
|
||||
))}
|
||||
</Timeline>
|
||||
</Card>
|
||||
</Space>
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
|
||||
export default connect(mapStateToProps, mapDispatchToProps)(JobLifecycleComponent);
|
||||
@@ -54,6 +54,7 @@ import { selectBodyshop } from "../../redux/user/user.selectors";
|
||||
import AuditTrailMapping from "../../utils/AuditTrailMappings";
|
||||
import UndefinedToNull from "../../utils/undefinedtonull";
|
||||
import { DateTimeFormat } from "./../../utils/DateFormatter";
|
||||
import JobLifecycleComponent from "../../components/job-lifecycle/job-lifecycle.component";
|
||||
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
bodyshop: selectBodyshop,
|
||||
@@ -288,6 +289,13 @@ export function JobsDetailPage({
|
||||
form={form}
|
||||
/>
|
||||
</Tabs.TabPane>
|
||||
<Tabs.TabPane
|
||||
forceRender
|
||||
tab={<span><BarsOutlined />Lifecycle</span>}
|
||||
key="lifecycle"
|
||||
>
|
||||
<JobLifecycleComponent job={job}/>
|
||||
</Tabs.TabPane>
|
||||
<Tabs.TabPane
|
||||
forceRender
|
||||
tab={
|
||||
|
||||
@@ -518,6 +518,20 @@ exports.QUERY_PAYMENTS_FOR_EXPORT = `
|
||||
}
|
||||
}`;
|
||||
|
||||
exports.QUERY_TRANSITIONS_BY_JOBID = `query QUERY_TRANSITIONS_BY_JOBID($jobid: uuid!) {
|
||||
transitions(where: {jobid: {_eq: $jobid}}, order_by: {id: asc}) {
|
||||
start
|
||||
end
|
||||
value
|
||||
prev_value
|
||||
next_value
|
||||
duration
|
||||
type
|
||||
created_at
|
||||
updated_at
|
||||
}
|
||||
}`;
|
||||
|
||||
exports.QUERY_UPCOMING_APPOINTMENTS = `query QUERY_UPCOMING_APPOINTMENTS($now: timestamptz!, $jobId: uuid!) {
|
||||
jobs_by_pk(id: $jobId) {
|
||||
bodyshop {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
const _ = require("lodash");
|
||||
const queries = require("../graphql-client/queries");
|
||||
const jobLifecycle = (req, res) => {
|
||||
const {jobids} = req.body;
|
||||
|
||||
@@ -11,11 +12,17 @@ const handleMultipleJobs = (jobIDs, req, res) => {
|
||||
return res.status(200).send(jobIDs);
|
||||
}
|
||||
|
||||
const handleSingleJob = (req, res) => {
|
||||
|
||||
const handleSingleJob = async (jobIds, req, res) => {
|
||||
const client = req.userGraphQLClient;
|
||||
|
||||
return res.status(200).send(req.body);
|
||||
const resp = await client.request(queries.QUERY_TRANSITIONS_BY_JOBID, {jobid: jobIds,});
|
||||
|
||||
const response = {
|
||||
jobIds,
|
||||
data: resp
|
||||
}
|
||||
|
||||
return res.status(200).json(response);
|
||||
}
|
||||
|
||||
module.exports = jobLifecycle;
|
||||
@@ -1,3 +1,11 @@
|
||||
const path = require("path");
|
||||
require("dotenv").config({
|
||||
path: path.resolve(
|
||||
process.cwd(),
|
||||
`.env.${process.env.NODE_ENV || "development"}`
|
||||
),
|
||||
});
|
||||
|
||||
/**
|
||||
* Checks if the event secret is correct
|
||||
* It adds the following properties to the request object:
|
||||
|
||||
@@ -7,14 +7,12 @@ const validateFirebaseIdTokenMiddleware = require("../middleware/validateFirebas
|
||||
const {totals, statustransition, totalsSsu, costing, lifecycle, costingmulti} = require("../job/job");
|
||||
const withUserGraphQLClientMiddleware = require("../middleware/withUserGraphQLClientMiddleware");
|
||||
|
||||
router.use(validateFirebaseIdTokenMiddleware);
|
||||
|
||||
router.post('/totals', withUserGraphQLClientMiddleware, totals);
|
||||
router.post('/totals', validateFirebaseIdTokenMiddleware, withUserGraphQLClientMiddleware, totals);
|
||||
router.post('/statustransition', eventAuthorizationMiddleware, statustransition);
|
||||
router.post('/totalsssu', withUserGraphQLClientMiddleware,totalsSsu);
|
||||
router.post('/costing', withUserGraphQLClientMiddleware,costing);
|
||||
router.get('/lifecycle', withUserGraphQLClientMiddleware, lifecycle);
|
||||
router.post('/costingmulti', withUserGraphQLClientMiddleware, costingmulti);
|
||||
router.post('/partsscan', withUserGraphQLClientMiddleware, partsScan);
|
||||
router.post('/totalsssu', validateFirebaseIdTokenMiddleware, withUserGraphQLClientMiddleware,totalsSsu);
|
||||
router.post('/costing', validateFirebaseIdTokenMiddleware, withUserGraphQLClientMiddleware,costing);
|
||||
router.post('/lifecycle', validateFirebaseIdTokenMiddleware, withUserGraphQLClientMiddleware, lifecycle);
|
||||
router.post('/costingmulti', validateFirebaseIdTokenMiddleware, withUserGraphQLClientMiddleware, costingmulti);
|
||||
router.post('/partsscan', validateFirebaseIdTokenMiddleware, withUserGraphQLClientMiddleware, partsScan);
|
||||
|
||||
module.exports = router;
|
||||
|
||||
Reference in New Issue
Block a user