CEC-3119 Magna Create Certs (#236)
* CEC-3119 FiskerQA Give Magna access to create certs * Comment
This commit is contained in:
@@ -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}
|
||||
|
||||
Reference in New Issue
Block a user