CEC-3119 Magna Create Certs (#236)

* CEC-3119 FiskerQA
Give Magna access to create certs

* Comment
This commit is contained in:
John Wu
2022-11-15 12:19:43 -08:00
committed by GitHub
parent b7e13382c4
commit aa585bebc3
4 changed files with 32 additions and 7 deletions

View File

@@ -4,11 +4,13 @@ import {
FormLabel,
Radio,
RadioGroup,
TextField,
TextField
} from "@material-ui/core";
import React, { useRef, useState } from "react";
import { CertTypeData, CertTypes } from "../../../utils/certificates";
import { Providers } from "../../../utils/roles";
import { useUserContext } from "../../Contexts/UserContext";
import useStyles from "../../useStyles";
const getCertTypeLabel = (certtype) => {
@@ -17,9 +19,20 @@ const getCertTypeLabel = (certtype) => {
return "ID";
};
const getCertsTypes = (providers) => {
if (providers.length === 0) return [];
if (providers[0] === Providers.MAGNA) {
return CertTypeData.filter((item) => {
return (item.label === CertTypes.TBOX || item.label === CertTypes.ICC);
})
}
return CertTypeData;
}
const CreateForm = ({ onCreate, busy }) => {
const classes = useStyles();
const commonnameEl = useRef(null);
const {providers} = useUserContext();
const [certType, setCertType] = useState(CertTypes.TBOX);
const onSubmit = async (event) => {
@@ -61,7 +74,7 @@ const CreateForm = ({ onCreate, busy }) => {
onChange={onCertTypeChange}
margin="normal"
>
{CertTypeData.map((item, i) => {
{getCertsTypes(providers).map((item, i) => {
return (
<FormControlLabel
key={i}