feature/IO-3357-Reynolds-and-Reynolds-DMS-API-Integration / Merges and adjustments
This commit is contained in:
@@ -4,6 +4,7 @@ import { useCallback, useEffect, useMemo, useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { connect } from "react-redux";
|
||||
import { createStructuredSelector } from "reselect";
|
||||
import { resolveRROpCodeFromBodyshop } from "../../utils/dmsUtils.js";
|
||||
|
||||
import { selectBodyshop } from "../../redux/user/user.selectors";
|
||||
|
||||
@@ -97,7 +98,7 @@ export function RrAllocationsSummary({ socket, bodyshop, jobId, title }) {
|
||||
fetchAllocations();
|
||||
}, [fetchAllocations]);
|
||||
|
||||
const opCode = bodyshop?.rr_configuration?.baseOpCode || "28TOZ";
|
||||
const opCode = resolveRROpCodeFromBodyshop(bodyshop);
|
||||
|
||||
const segmentLabelMap = {
|
||||
partsExtras: "Parts/Extras",
|
||||
|
||||
@@ -49,8 +49,8 @@ import {
|
||||
validatePasswordResetSuccess
|
||||
} from "./user.actions";
|
||||
import UserActionTypes from "./user.types";
|
||||
//import * as amplitude from '@amplitude/analytics-browser';
|
||||
import posthog from "posthog-js";
|
||||
import { bodyshopHasDmsKey, determineDMSTypeByBodyshop, DMS_MAP } from "../../utils/dmsUtils";
|
||||
|
||||
const fpPromise = FingerprintJS.load();
|
||||
|
||||
@@ -387,16 +387,15 @@ export function* SetAuthLevelFromShopDetails({ payload }) {
|
||||
)
|
||||
];
|
||||
|
||||
const hasDmsKey = bodyshopHasDmsKey(payload);
|
||||
const dmsType = hasDmsKey ? determineDMSTypeByBodyshop(payload) : null;
|
||||
|
||||
const additionalSegments = [
|
||||
payload.cdk_dealerid && "CDK",
|
||||
payload.pbs_serialnumber && "PBS",
|
||||
// payload.rr_dealerid && "Reynolds",
|
||||
payload.accountingconfig.qbo === true && "QBO",
|
||||
payload.accountingconfig.qbo === false &&
|
||||
!payload.cdk_dealerid &&
|
||||
!payload.pbs_serialnumber &&
|
||||
// !payload.rr_dealerid &&
|
||||
"QBD"
|
||||
dmsType === DMS_MAP.cdk && DMS_MAP.cdk.toUpperCase(),
|
||||
dmsType === DMS_MAP.pbs && DMS_MAP.pbs.toUpperCase(),
|
||||
dmsType === DMS_MAP.reynolds && DMS_MAP.reynolds.toUpperCase(),
|
||||
payload.accountingconfig?.qbo === true && "QBO",
|
||||
payload.accountingconfig?.qbo === false && !hasDmsKey && "QBD"
|
||||
].filter(Boolean);
|
||||
|
||||
featureSegments.push(...additionalSegments);
|
||||
|
||||
@@ -70,3 +70,26 @@ export const isWssMode = (mode) => {
|
||||
*/
|
||||
export const bodyshopHasDmsKey = (bodyshop) =>
|
||||
bodyshop.cdk_dealerid || bodyshop.pbs_serialnumber || bodyshop.rr_dealerid;
|
||||
|
||||
/**
|
||||
* Resolve RR OpCode from bodyshop.rr_configuration.defaults
|
||||
* Is Duplicated on server/rr/rr-utils.js
|
||||
* @param bodyshop
|
||||
* @returns {`${string}${string}${string}`}
|
||||
*/
|
||||
export const resolveRROpCodeFromBodyshop = (bodyshop) => {
|
||||
if (!bodyshop) throw new Error("bodyshop is required");
|
||||
|
||||
const cfg = bodyshop?.rr_configuration || {};
|
||||
const defaults = cfg?.defaults || {};
|
||||
|
||||
const prefix = (defaults.prefix ?? "").toString().trim();
|
||||
const base = (defaults.base ?? "").toString().trim();
|
||||
const suffix = (defaults.suffix ?? "").toString().trim();
|
||||
|
||||
if (!prefix && !base && !suffix) {
|
||||
throw new Error("No RR OpCode parts found in bodyshop configuration");
|
||||
}
|
||||
|
||||
return `${prefix}${base}${suffix}`;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user