diff --git a/client/src/components/header/header.component.jsx b/client/src/components/header/header.component.jsx index f0edf82d2..a360aca59 100644 --- a/client/src/components/header/header.component.jsx +++ b/client/src/components/header/header.component.jsx @@ -1,10 +1,9 @@ -import { useTreatments } from "@splitsoftware/splitio-react"; import Icon, { BankFilled, BarChartOutlined, CarFilled, - ClockCircleFilled, CheckCircleOutlined, + ClockCircleFilled, DashboardFilled, DollarCircleFilled, ExportOutlined, @@ -26,6 +25,7 @@ import Icon, { UnorderedListOutlined, UserOutlined, } from "@ant-design/icons"; +import { useTreatments } from "@splitsoftware/splitio-react"; import { Layout, Menu } from "antd"; import React from "react"; import { useTranslation } from "react-i18next"; @@ -252,7 +252,11 @@ function Header({ onClick={() => { setTimeTicketContext({ actions: {}, - context: {}, + context: { + created_by: currentUser.displayName + ? currentUser.email.concat(" | ", currentUser.displayName) + : currentUser.email, + }, }); }} > diff --git a/client/src/components/tech-job-clock-in-form/tech-job-clock-in-form.container.jsx b/client/src/components/tech-job-clock-in-form/tech-job-clock-in-form.container.jsx index 7754c07f2..139a30cbf 100644 --- a/client/src/components/tech-job-clock-in-form/tech-job-clock-in-form.container.jsx +++ b/client/src/components/tech-job-clock-in-form/tech-job-clock-in-form.container.jsx @@ -1,21 +1,25 @@ import { useMutation } from "@apollo/client"; import { Button, Card, Form, notification, Space } from "antd"; import axios from "axios"; +import moment from "moment"; import React, { useState } from "react"; import { useTranslation } from "react-i18next"; import { connect } from "react-redux"; import { createStructuredSelector } from "reselect"; import { INSERT_NEW_TIME_TICKET } from "../../graphql/timetickets.queries"; -import { selectTechnician } from "../../redux/tech/tech.selectors"; -import { selectBodyshop } from "../../redux/user/user.selectors"; -import TechClockInComponent from "./tech-job-clock-in-form.component"; -import TechJobPrintTickets from "../tech-job-print-tickets/tech-job-print-tickets.component"; -import moment from "moment"; import { setModalContext } from "../../redux/modals/modals.actions"; +import { selectTechnician } from "../../redux/tech/tech.selectors"; +import { + selectBodyshop, + selectCurrentUser, +} from "../../redux/user/user.selectors"; +import TechJobPrintTickets from "../tech-job-print-tickets/tech-job-print-tickets.component"; +import TechClockInComponent from "./tech-job-clock-in-form.component"; const mapStateToProps = createStructuredSelector({ technician: selectTechnician, bodyshop: selectBodyshop, + currentUser: selectCurrentUser, }); const mapDispatchToProps = (dispatch) => ({ setTimeTicketContext: (context) => @@ -25,6 +29,7 @@ export function TechClockInContainer({ setTimeTicketContext, technician, bodyshop, + currentUser, }) { console.log( "🚀 ~ file: tech-job-clock-in-form.container.jsx:29 ~ technician:", @@ -66,6 +71,12 @@ export function TechClockInContainer({ values.cost_center ); }), + created_by: currentUser.email.concat( + " | ", + technician.employee_number + .concat(" ", technician.first_name, " ", technician.last_name) + .trim() + ), }, ], }, @@ -100,6 +111,17 @@ export function TechClockInContainer({ employeeid: technician.id, flat_rate: emps.flat_rate, }, + created_by: currentUser.email.concat( + " | ", + technician.employee_number + .concat( + " ", + technician.first_name, + " ", + technician.last_name + ) + .trim() + ), }, }); }} diff --git a/client/src/components/time-ticket-list/time-ticket-list.component.jsx b/client/src/components/time-ticket-list/time-ticket-list.component.jsx index 7cebf2672..632238638 100644 --- a/client/src/components/time-ticket-list/time-ticket-list.component.jsx +++ b/client/src/components/time-ticket-list/time-ticket-list.component.jsx @@ -9,9 +9,10 @@ import { createStructuredSelector } from "reselect"; import { selectAuthLevel, selectBodyshop, + selectCurrentUser, } from "../../redux/user/user.selectors"; -import { onlyUnique } from "../../utils/arrayHelper"; import { DateFormatter, DateTimeFormatter } from "../../utils/DateFormatter"; +import { onlyUnique } from "../../utils/arrayHelper"; import { alphaSort, dateSort } from "../../utils/sorters"; import RbacWrapper, { HasRbacAccess, @@ -20,6 +21,7 @@ import TimeTicketEnterButton from "../time-ticket-enter-button/time-ticket-enter const mapStateToProps = createStructuredSelector({ bodyshop: selectBodyshop, authLevel: selectAuthLevel, + currentUser: selectCurrentUser, }); const mapDispatchToProps = (dispatch) => ({ //setUserLanguage: language => dispatch(setUserLanguage(language)) @@ -29,6 +31,7 @@ export default connect(mapStateToProps, mapDispatchToProps)(TimeTicketList); export function TimeTicketList({ bodyshop, authLevel, + currentUser, disabled, loading, timetickets, @@ -193,7 +196,15 @@ export function TimeTicketList({ } }, }, - + { + title: t("timetickets.fields.created_by"), + dataIndex: "created_by", + key: "created_by", + sorter: (a, b) => alphaSort(a.created_by, b.created_by), + sortOrder: + state.sortedInfo.columnKey === "created_by" && state.sortedInfo.order, + render: (text, record) => record.created_by, + }, { title: t("general.labels.actions"), dataIndex: "actions", @@ -254,7 +265,12 @@ export function TimeTicketList({ (techConsole ? null : ( {t("timetickets.actions.enter")} diff --git a/client/src/components/time-ticket-modal/time-ticket-modal.container.jsx b/client/src/components/time-ticket-modal/time-ticket-modal.container.jsx index 463b2a80c..3ca8c1f24 100644 --- a/client/src/components/time-ticket-modal/time-ticket-modal.container.jsx +++ b/client/src/components/time-ticket-modal/time-ticket-modal.container.jsx @@ -1,5 +1,5 @@ import { useMutation, useQuery } from "@apollo/client"; -import { Button, Form, Modal, notification, PageHeader, Space } from "antd"; +import { Button, Form, Modal, PageHeader, Space, notification } from "antd"; import moment from "moment"; import React, { useEffect, useState } from "react"; import { useTranslation } from "react-i18next"; @@ -77,6 +77,7 @@ export function TimeTicketModalContainer({ )[0].rate : null, bodyshopid: bodyshop.id, + created_by: timeTicketModal.context.created_by, }, ], }, diff --git a/client/src/graphql/jobs-lines.queries.js b/client/src/graphql/jobs-lines.queries.js index 05af1fba4..23bf59a6a 100644 --- a/client/src/graphql/jobs-lines.queries.js +++ b/client/src/graphql/jobs-lines.queries.js @@ -57,6 +57,7 @@ export const GET_LINE_TICKET_BY_PK = gql` actualhrs ciecacode cost_center + created_by date id jobid diff --git a/client/src/graphql/timetickets.queries.js b/client/src/graphql/timetickets.queries.js index e6f04868f..985e491cc 100644 --- a/client/src/graphql/timetickets.queries.js +++ b/client/src/graphql/timetickets.queries.js @@ -37,6 +37,7 @@ export const QUERY_TIME_TICKETS_IN_RANGE = gql` clockon cost_center created_at + created_by date id rate @@ -80,6 +81,7 @@ export const QUERY_TIME_TICKETS_TECHNICIAN_IN_RANGE = gql` clockon cost_center created_at + created_by date id rate @@ -112,6 +114,7 @@ export const QUERY_TIME_TICKETS_TECHNICIAN_IN_RANGE = gql` clockon cost_center created_at + created_by date id rate @@ -151,6 +154,7 @@ export const QUERY_TIME_TICKETS_IN_RANGE_SB = gql` clockon cost_center created_at + created_by date id rate @@ -181,6 +185,7 @@ export const QUERY_TIME_TICKETS_IN_RANGE_SB = gql` clockon cost_center created_at + created_by date id rate @@ -210,6 +215,7 @@ export const INSERT_NEW_TIME_TICKET = gql` insert_timetickets(objects: $timeTicketInput) { returning { id + created_by clockon clockoff employeeid diff --git a/client/src/translations/en_us/common.json b/client/src/translations/en_us/common.json index 37328df92..29e7fe2c2 100644 --- a/client/src/translations/en_us/common.json +++ b/client/src/translations/en_us/common.json @@ -2730,6 +2730,7 @@ "clockon": "Clocked In", "committed": "", "cost_center": "Cost Center", + "created_by": "Created By", "date": "Ticket Date", "efficiency": "Efficiency", "employee": "Employee", diff --git a/client/src/translations/es/common.json b/client/src/translations/es/common.json index e02f656f7..bc66d3d6e 100644 --- a/client/src/translations/es/common.json +++ b/client/src/translations/es/common.json @@ -2730,6 +2730,7 @@ "clockon": "", "committed": "", "cost_center": "", + "created_by": "", "date": "", "efficiency": "", "employee": "", diff --git a/client/src/translations/fr/common.json b/client/src/translations/fr/common.json index 782f51342..5c2766e5a 100644 --- a/client/src/translations/fr/common.json +++ b/client/src/translations/fr/common.json @@ -2730,6 +2730,7 @@ "clockon": "", "committed": "", "cost_center": "", + "created_by": "", "date": "", "efficiency": "", "employee": "", diff --git a/hasura/metadata/tables.yaml b/hasura/metadata/tables.yaml index cf189ea3f..2e44c4b14 100644 --- a/hasura/metadata/tables.yaml +++ b/hasura/metadata/tables.yaml @@ -4649,6 +4649,7 @@ _eq: X-Hasura-User-Id - active: _eq: true + allow_aggregations: true update_permissions: - role: user permission: @@ -4726,6 +4727,7 @@ _eq: X-Hasura-User-Id - active: _eq: true + allow_aggregations: true update_permissions: - role: user permission: @@ -5554,6 +5556,7 @@ - committed_at - cost_center - created_at + - created_by - date - employeeid - flat_rate @@ -5578,6 +5581,7 @@ - committed_at - cost_center - created_at + - created_by - date - employeeid - flat_rate @@ -5611,6 +5615,7 @@ - committed_at - cost_center - created_at + - created_by - date - employeeid - flat_rate diff --git a/hasura/migrations/1691614820968_alter_table_public_timetickets_add_column_created_by/down.sql b/hasura/migrations/1691614820968_alter_table_public_timetickets_add_column_created_by/down.sql new file mode 100644 index 000000000..1877b51f0 --- /dev/null +++ b/hasura/migrations/1691614820968_alter_table_public_timetickets_add_column_created_by/down.sql @@ -0,0 +1,4 @@ +-- Could not auto-generate a down migration. +-- Please write an appropriate down migration for the SQL below: +-- alter table "public"."timetickets" add column "created_by" text +-- null; diff --git a/hasura/migrations/1691614820968_alter_table_public_timetickets_add_column_created_by/up.sql b/hasura/migrations/1691614820968_alter_table_public_timetickets_add_column_created_by/up.sql new file mode 100644 index 000000000..927b24b87 --- /dev/null +++ b/hasura/migrations/1691614820968_alter_table_public_timetickets_add_column_created_by/up.sql @@ -0,0 +1,2 @@ +alter table "public"."timetickets" add column "created_by" text + null;