From 27ea9f8eea17664a9882bef8f144a623ddd69919 Mon Sep 17 00:00:00 2001
From: Paul Adamsen <117673433+pauladamseniii@users.noreply.github.com>
Date: Thu, 16 Mar 2023 02:46:01 -0400
Subject: [PATCH 1/2] CEC-AddDebugMaskToPrd - allow DebugMask on prd (#290)
---
src/components/Cars/Status/Details/index.jsx | 2 +-
src/components/Cars/Update/index.jsx | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/components/Cars/Status/Details/index.jsx b/src/components/Cars/Status/Details/index.jsx
index 6307310..ac34a8a 100644
--- a/src/components/Cars/Status/Details/index.jsx
+++ b/src/components/Cars/Status/Details/index.jsx
@@ -33,7 +33,7 @@ const MainForm = ({ vin }) => {
} = useUserContext();
const ENV = process.env.REACT_APP_ENV;
- const showDebugMask = (ENV === 'local' || ENV === 'dev' || ENV === 'stg')
+ const showDebugMask = (ENV === 'local' || ENV === 'dev' || ENV === 'stg' || ENV === 'prd')
useEffect(() => {
(async () => {
diff --git a/src/components/Cars/Update/index.jsx b/src/components/Cars/Update/index.jsx
index 5302f33..cdbf11d 100644
--- a/src/components/Cars/Update/index.jsx
+++ b/src/components/Cars/Update/index.jsx
@@ -49,7 +49,7 @@ const MainForm = () => {
const debugMaskEl = useRef(null);
const ENV = process.env.REACT_APP_ENV;
- const showDebugMask = (ENV === 'local' || ENV === 'dev' || ENV === 'stg')
+ const showDebugMask = (ENV === 'local' || ENV === 'dev' || ENV === 'stg' || ENV === 'prd')
useEffect(() => {
setTitle("Update Vehicle");
From 19bc0543436ce9c771367489ac5663d5037f839b Mon Sep 17 00:00:00 2001
From: John Wu <76966357+jwu-fisker@users.noreply.github.com>
Date: Thu, 16 Mar 2023 15:13:47 -0700
Subject: [PATCH 2/2] CEC-3912 VIN input (#293)
* CEC-3912 VIN input
* Revert
---
src/components/Cars/Add/index.jsx | 24 ++++++++++---------
.../Certificates/Add/CreateForm.jsx | 15 ++++++++----
src/utils/strings.js | 2 +-
src/utils/vinValidation.js | 9 +++++++
4 files changed, 34 insertions(+), 16 deletions(-)
create mode 100644 src/utils/vinValidation.js
diff --git a/src/components/Cars/Add/index.jsx b/src/components/Cars/Add/index.jsx
index b3ce2e3..c5ea3d3 100644
--- a/src/components/Cars/Add/index.jsx
+++ b/src/components/Cars/Add/index.jsx
@@ -1,5 +1,3 @@
-import React, { useEffect, useRef, useState } from "react";
-import { Redirect } from "react-router";
import {
Button,
Checkbox,
@@ -10,15 +8,18 @@ import {
RadioGroup,
TextField
} from "@material-ui/core";
+import React, { useEffect, useState } from "react";
+import { Redirect } from "react-router";
-import useStyles from "../../useStyles";
-import {
- useVehicleContext,
- VehicleProvider,
-} from "../../Contexts/VehicleContext";
+import { logger } from "../../../services/monitoring";
+import { getVINOnChangeHandler } from "../../../utils/vinValidation";
import { useStatusContext } from "../../Contexts/StatusContext";
import { useUserContext } from "../../Contexts/UserContext";
-import { logger } from "../../../services/monitoring";
+import {
+ useVehicleContext,
+ VehicleProvider
+} from "../../Contexts/VehicleContext";
+import useStyles from "../../useStyles";
const MainForm = () => {
const { addVehicle, busy } = useVehicleContext();
@@ -31,7 +32,7 @@ const MainForm = () => {
const classes = useStyles();
const [redirect, setRedirect] = useState(null);
- const vinEl = useRef(null);
+ const [vin, setVIN] = useState("");
const [selectedLogLevel, setSelectedLogLevel] = useState("info");
const [canbusEnabled, setCANBusEnabled] = useState(true);
const [dataLoggerEnabled, setDataLoggerEnabled] = useState(false);
@@ -77,7 +78,7 @@ const MainForm = () => {
event.preventDefault();
const formData = {
- vin: vinEl.current.value,
+ vin,
log_level: selectedLogLevel,
canbus: {
enabled: canbusEnabled,
@@ -115,7 +116,8 @@ const MainForm = () => {
}}
required
fullWidth
- inputRef={vinEl}
+ value={vin}
+ onChange={getVINOnChangeHandler(setVIN)}
/>
Log Level
{
const CreateForm = ({ onCreate, busy }) => {
const classes = useStyles();
- const commonnameEl = useRef(null);
const {providers} = useUserContext();
+ const [commonName, setCommonName] = useState("");
const [certType, setCertType] = useState(CertTypes.TBOX);
+ const onVINChange = getVINOnChangeHandler(setCommonName);
+ const onAftersaleChange = (e) => {
+ const value = e.target.value ?? "";
+ setCommonName(value);
+ }
const onSubmit = async (event) => {
event.preventDefault();
if (onCreate)
onCreate({
- common_name: commonnameEl.current.value,
+ common_name: commonName,
type: certType,
});
};
@@ -63,7 +69,8 @@ const CreateForm = ({ onCreate, busy }) => {
}}
required
fullWidth
- inputRef={commonnameEl}
+ value={commonName}
+ onChange={certType === CertTypes.Aftersales ? onAftersaleChange : onVINChange}
/>
Type
{
+ return (e) => {
+ const value = e?.target?.value.toUpperCase() ?? "";
+ if (!value.match(regExVIN)) return;
+ setFn(value.toUpperCase());
+ }
+}
\ No newline at end of file