CEC-2920 Aftersales certificates (#225)
* CEC-2920 aftersales certificates * smells * smells
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
import React, { useRef, useState } from "react";
|
||||
import {
|
||||
Button,
|
||||
FormControlLabel,
|
||||
@@ -7,13 +6,15 @@ import {
|
||||
RadioGroup,
|
||||
TextField,
|
||||
} from "@material-ui/core";
|
||||
import React, { useRef, useState } from "react";
|
||||
|
||||
import { CertTypeData, CertTypes } from "../../../utils/certificates";
|
||||
import useStyles from "../../useStyles";
|
||||
import { CertTypes } from "../../Contexts/CertificateContext";
|
||||
|
||||
const getCertTypeLabel = (certtype) => {
|
||||
if (certtype === CertTypes.Aftersales) return "Service Tool ID";
|
||||
return "VIN";
|
||||
const item = CertTypeData.find((item) => certtype === item.value);
|
||||
if (item !== null) return item.inputlabel;
|
||||
return "ID";
|
||||
};
|
||||
|
||||
const CreateForm = ({ onCreate, busy }) => {
|
||||
@@ -60,21 +61,16 @@ const CreateForm = ({ onCreate, busy }) => {
|
||||
onChange={onCertTypeChange}
|
||||
margin="normal"
|
||||
>
|
||||
<FormControlLabel
|
||||
value={CertTypes.TBOX}
|
||||
control={<Radio />}
|
||||
label="TBOX"
|
||||
/>
|
||||
<FormControlLabel
|
||||
value={CertTypes.ICC}
|
||||
control={<Radio />}
|
||||
label="ICC"
|
||||
/>
|
||||
<FormControlLabel
|
||||
value={CertTypes.Charging}
|
||||
control={<Radio />}
|
||||
label="Charging"
|
||||
/>
|
||||
{CertTypeData.map((item, i) => {
|
||||
return (
|
||||
<FormControlLabel
|
||||
key={i}
|
||||
value={item.value}
|
||||
label={item.label}
|
||||
control={<Radio />}
|
||||
/>
|
||||
);
|
||||
})}
|
||||
</RadioGroup>
|
||||
<Button
|
||||
type="submit"
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import React, { useEffect, useState } from "react";
|
||||
|
||||
import { logger } from "../../../services/monitoring";
|
||||
import {
|
||||
useCertificateContext,
|
||||
CertificateProvider,
|
||||
useCertificateContext,
|
||||
} from "../../Contexts/CertificateContext";
|
||||
import { useStatusContext } from "../../Contexts/StatusContext";
|
||||
import { useUserContext } from "../../Contexts/UserContext";
|
||||
import { logger } from "../../../services/monitoring";
|
||||
import CreateForm from "./CreateForm";
|
||||
import DownloadCerts from "./DownloadCerts";
|
||||
|
||||
@@ -43,11 +43,12 @@ const MainForm = () => {
|
||||
const onCreate = async (data) => {
|
||||
try {
|
||||
const result = await createCert(data, token);
|
||||
const name = data.common_name || data.tool_id;
|
||||
|
||||
setCommonName(name);
|
||||
setPubCert(result.public_key);
|
||||
setPrivCert(result.private_key);
|
||||
setCommonName(data.common_name);
|
||||
setMessage(`Created ${data.common_name} certificate`);
|
||||
setMessage(`Created ${name} certificate`);
|
||||
setView(VIEW_DOWNLOAD);
|
||||
} catch (e) {
|
||||
setMessage(e.message);
|
||||
|
||||
Reference in New Issue
Block a user