From c783b3f31dca1bba9b2c0773cc991a3d12641ffb Mon Sep 17 00:00:00 2001 From: Patrick Fic Date: Mon, 13 Apr 2020 18:21:59 -0700 Subject: [PATCH] added firebase analytics --- bodyshop_translations.babel | 21 ++++ client/package.json | 1 + .../job-detail-lines/job-lines.component.jsx | 102 +++++++++--------- client/src/firebase/firebase.utils.js | 12 ++- .../manage-root.page.component.jsx | 12 +++ client/src/translations/en_us/common.json | 1 + client/src/translations/es/common.json | 1 + client/src/translations/fr/common.json | 1 + client/yarn.lock | 5 + 9 files changed, 97 insertions(+), 59 deletions(-) diff --git a/bodyshop_translations.babel b/bodyshop_translations.babel index da72360dc..07c9287db 100644 --- a/bodyshop_translations.babel +++ b/bodyshop_translations.babel @@ -5477,6 +5477,27 @@ + + total + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + unq_seq false diff --git a/client/package.json b/client/package.json index cb1c05a62..b71b41088 100644 --- a/client/package.json +++ b/client/package.json @@ -28,6 +28,7 @@ "react-barcode": "^1.4.0", "react-big-calendar": "^0.24.1", "react-dom": "^16.13.1", + "react-ga": "^2.7.0", "react-grid-gallery": "^0.5.5", "react-grid-layout": "^0.18.3", "react-html-email": "^3.0.0", diff --git a/client/src/components/job-detail-lines/job-lines.component.jsx b/client/src/components/job-detail-lines/job-lines.component.jsx index 60fa8faf5..e62b0d97d 100644 --- a/client/src/components/job-detail-lines/job-lines.component.jsx +++ b/client/src/components/job-detail-lines/job-lines.component.jsx @@ -11,9 +11,9 @@ import AllocationsBulkAssignmentContainer from "../allocations-bulk-assignment/a import AllocationsEmployeeLabelContainer from "../allocations-employee-label/allocations-employee-label.container"; import PartsOrderModalContainer from "../parts-order-modal/parts-order-modal.container"; -const mapDispatchToProps = dispatch => ({ - setPartsOrderContext: context => - dispatch(setModalContext({ context: context, modal: "partsOrder" })) +const mapDispatchToProps = (dispatch) => ({ + setPartsOrderContext: (context) => + dispatch(setModalContext({ context: context, modal: "partsOrder" })), }); export function JobLinesComponent({ @@ -25,10 +25,10 @@ export function JobLinesComponent({ selectedLines, setSelectedLines, jobId, - setJobLineEditContext + setJobLineEditContext, }) { const [state, setState] = useState({ - sortedInfo: {} + sortedInfo: {}, }); const { t } = useTranslation(); @@ -44,7 +44,7 @@ export function JobLinesComponent({ state.sortedInfo.columnKey === "unq_seq" && state.sortedInfo.order, //ellipsis: true, editable: true, - width: 75 + width: 75, }, { title: t("joblines.fields.line_desc"), @@ -55,7 +55,6 @@ export function JobLinesComponent({ state.sortedInfo.columnKey === "line_desc" && state.sortedInfo.order, ellipsis: true, editable: true, - width: "20%" }, { title: t("joblines.fields.oem_partno"), @@ -70,12 +69,12 @@ export function JobLinesComponent({ state.sortedInfo.columnKey === "oem_partno" && state.sortedInfo.order, ellipsis: true, editable: true, - width: "10%", + render: (text, record) => ( {record.oem_partno ? record.oem_partno : record.op_code_desc} - ) + ), }, { title: t("joblines.fields.part_type"), @@ -86,7 +85,6 @@ export function JobLinesComponent({ state.sortedInfo.columnKey === "part_type" && state.sortedInfo.order, ellipsis: true, editable: true, - width: "7%" }, { title: t("joblines.fields.line_ind"), @@ -94,20 +92,7 @@ export function JobLinesComponent({ key: "line_ind", sorter: (a, b) => alphaSort(a.line_ind, b.line_ind), sortOrder: - state.sortedInfo.columnKey === "line_ind" && state.sortedInfo.order - }, - { - title: t("joblines.fields.db_price"), - dataIndex: "db_price", - key: "db_price", - sorter: (a, b) => a.db_price - b.db_price, - sortOrder: - state.sortedInfo.columnKey === "db_price" && state.sortedInfo.order, - ellipsis: true, - width: "8%", - render: (text, record) => ( - {record.db_price} - ) + state.sortedInfo.columnKey === "line_ind" && state.sortedInfo.order, }, { title: t("joblines.fields.act_price"), @@ -117,10 +102,31 @@ export function JobLinesComponent({ sortOrder: state.sortedInfo.columnKey === "act_price" && state.sortedInfo.order, ellipsis: true, - width: "8%", + render: (text, record) => ( {record.act_price} - ) + ), + }, + { + title: t("joblines.fields.part_qty"), + dataIndex: "part_qty", + key: "part_qty", + ellipsis: true, + }, + { + title: t("joblines.fields.total"), + dataIndex: "total", + key: "total", + sorter: (a, b) => a.act_price * a.part_qty - b.act_price * b.part_qty, + sortOrder: + state.sortedInfo.columnKey === "act_price" && state.sortedInfo.order, + ellipsis: true, + + render: (text, record) => ( + + {record.act_price * record.part_qty} + + ), }, { title: t("joblines.fields.mod_lb_hrs"), @@ -128,7 +134,7 @@ export function JobLinesComponent({ key: "mod_lb_hrs", sorter: (a, b) => a.mod_lb_hrs - b.mod_lb_hrs, sortOrder: - state.sortedInfo.columnKey === "mod_lb_hrs" && state.sortedInfo.order + state.sortedInfo.columnKey === "mod_lb_hrs" && state.sortedInfo.order, }, { title: t("joblines.fields.status"), @@ -136,13 +142,13 @@ export function JobLinesComponent({ key: "status", sorter: (a, b) => alphaSort(a.status, b.status), sortOrder: - state.sortedInfo.columnKey === "status" && state.sortedInfo.order + state.sortedInfo.columnKey === "status" && state.sortedInfo.order, }, { title: t("allocations.fields.employee"), dataIndex: "employee", key: "employee", - width: "10%", + sorter: (a, b) => alphaSort( a.allocations[0] && @@ -157,7 +163,7 @@ export function JobLinesComponent({ render: (text, record) => ( {record.allocations && record.allocations.length > 0 - ? record.allocations.map(item => ( + ? record.allocations.map((item) => ( - ) + ), }, { title: t("general.labels.actions"), @@ -184,32 +190,21 @@ export function JobLinesComponent({ onClick={() => { setJobLineEditContext({ actions: { refetch: refetch }, - context: record + context: record, }); }} > {t("general.actions.edit")} - ) - } + ), + }, ]; const handleTableChange = (pagination, filters, sorter) => { setState({ ...state, filteredInfo: filters, sortedInfo: sorter }); }; - const formItemLayout = { - labelCol: { - xs: { span: 12 }, - sm: { span: 5 } - }, - wrapperCol: { - xs: { span: 24 }, - sm: { span: 12 } - } - }; - return (
@@ -219,7 +214,7 @@ export function JobLinesComponent({
{ + onChange={(e) => { e.preventDefault(); setSearchText(e.target.value); }} @@ -231,8 +226,8 @@ export function JobLinesComponent({ actions: { refetch: refetch }, context: { jobId: jobId, - linesToOrder: selectedLines - } + linesToOrder: selectedLines, + }, }); }} > @@ -246,7 +241,7 @@ export function JobLinesComponent({ onClick={() => { setJobLineEditContext({ actions: { refetch: refetch }, - context: { jobid: jobId } + context: { jobid: jobId }, }); }} > @@ -255,13 +250,12 @@ export function JobLinesComponent({
); }} - {...formItemLayout} loading={loading} size="small" - expandedRowRender={record => ( + expandedRowRender={(record) => (
{t("parts_orders.labels.orderhistory")} - {record.parts_order_lines.map(item => ( + {record.parts_order_lines.map((item) => (
{`${item.parts_order.order_number || ""} from `} @@ -279,9 +273,9 @@ export function JobLinesComponent({ setSelectedLines(selectedRows); }, onSelect: (record, selected, selectedRows, nativeEvent) => - setSelectedLines(selectedRows) + setSelectedLines(selectedRows), }} - columns={columns.map(item => ({ ...item }))} + columns={columns.map((item) => ({ ...item }))} rowKey="id" dataSource={jobLines} onChange={handleTableChange} diff --git a/client/src/firebase/firebase.utils.js b/client/src/firebase/firebase.utils.js index ed1b758d9..4b1cea785 100644 --- a/client/src/firebase/firebase.utils.js +++ b/client/src/firebase/firebase.utils.js @@ -2,28 +2,30 @@ import firebase from "firebase/app"; import "firebase/firestore"; import "firebase/auth"; import "firebase/database"; +import "firebase/analytics"; const config = JSON.parse(process.env.REACT_APP_FIREBASE_CONFIG); firebase.initializeApp(config); export const auth = firebase.auth(); export const firestore = firebase.firestore(); +export const analytics = firebase.analytics(); + export default firebase; export const getCurrentUser = () => { return new Promise((resolve, reject) => { - const unsubscribe = auth.onAuthStateChanged(userAuth => { + const unsubscribe = auth.onAuthStateChanged((userAuth) => { unsubscribe(); resolve(userAuth); }, reject); }); }; -export const updateCurrentUser = userDetails => { +export const updateCurrentUser = (userDetails) => { return new Promise((resolve, reject) => { - const unsubscribe = auth.onAuthStateChanged(userAuth => { - console.log("userDetails", userDetails); - userAuth.updateProfile(userDetails).then(r => { + const unsubscribe = auth.onAuthStateChanged((userAuth) => { + userAuth.updateProfile(userDetails).then((r) => { unsubscribe(); resolve(userAuth); }); diff --git a/client/src/pages/manage-root/manage-root.page.component.jsx b/client/src/pages/manage-root/manage-root.page.component.jsx index 75b4f4c43..9cecd0e9c 100644 --- a/client/src/pages/manage-root/manage-root.page.component.jsx +++ b/client/src/pages/manage-root/manage-root.page.component.jsx @@ -1,11 +1,23 @@ import React from "react"; import DashboardGridComponent from "../../components/dashboard-grid/dashboard-grid.component"; import Test from "../../components/_test/test.component"; +import { analytics } from "../../firebase/firebase.utils"; + export default function ManageRootPageComponent() { //const client = useApolloClient(); return (
+ { //