CEC-2281 Fix cert name
This commit is contained in:
@@ -6031,57 +6031,6 @@ exports[`App Route /tools/certificates/add authenticated 1`] = `
|
||||
Charging
|
||||
</span>
|
||||
</label>
|
||||
<label
|
||||
class="MuiFormControlLabel-root"
|
||||
>
|
||||
<span
|
||||
aria-disabled="false"
|
||||
class="MuiButtonBase-root MuiIconButton-root PrivateSwitchBase-root-0 MuiRadio-root MuiRadio-colorSecondary MuiIconButton-colorSecondary"
|
||||
>
|
||||
<span
|
||||
class="MuiIconButton-label"
|
||||
>
|
||||
<input
|
||||
class="PrivateSwitchBase-input-0"
|
||||
name="cert-type"
|
||||
type="radio"
|
||||
value="Aftersales"
|
||||
/>
|
||||
<div
|
||||
class="PrivateRadioButtonIcon-root-0"
|
||||
>
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
class="MuiSvgIcon-root"
|
||||
focusable="false"
|
||||
viewBox="0 0 24 24"
|
||||
>
|
||||
<path
|
||||
d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"
|
||||
/>
|
||||
</svg>
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
class="MuiSvgIcon-root PrivateRadioButtonIcon-layer-0"
|
||||
focusable="false"
|
||||
viewBox="0 0 24 24"
|
||||
>
|
||||
<path
|
||||
d="M8.465 8.465C9.37 7.56 10.62 7 12 7C14.76 7 17 9.24 17 12C17 13.38 16.44 14.63 15.535 15.535C14.63 16.44 13.38 17 12 17C9.24 17 7 14.76 7 12C7 10.62 7.56 9.37 8.465 8.465Z"
|
||||
/>
|
||||
</svg>
|
||||
</div>
|
||||
</span>
|
||||
<span
|
||||
class="MuiTouchRipple-root"
|
||||
/>
|
||||
</span>
|
||||
<span
|
||||
class="MuiTypography-root MuiFormControlLabel-label MuiTypography-body1"
|
||||
>
|
||||
Aftersales
|
||||
</span>
|
||||
</label>
|
||||
</div>
|
||||
<button
|
||||
class="MuiButtonBase-root MuiButton-root MuiButton-contained makeStyles-submit-0 MuiButton-containedPrimary MuiButton-fullWidth"
|
||||
|
||||
@@ -75,11 +75,6 @@ const CreateForm = ({ onCreate, busy }) => {
|
||||
control={<Radio />}
|
||||
label="Charging"
|
||||
/>
|
||||
<FormControlLabel
|
||||
value={CertTypes.Aftersales}
|
||||
control={<Radio />}
|
||||
label="Aftersales"
|
||||
/>
|
||||
</RadioGroup>
|
||||
<Button
|
||||
type="submit"
|
||||
|
||||
@@ -6,7 +6,12 @@ import useStyles from "../../useStyles";
|
||||
|
||||
const CertMimeType = "application/x-pem-file";
|
||||
|
||||
const DownloadCerts = ({ vin, publicCert, privateCert, onChangeView }) => {
|
||||
const DownloadCerts = ({
|
||||
commonName,
|
||||
publicCert,
|
||||
privateCert,
|
||||
onChangeView,
|
||||
}) => {
|
||||
const classes = useStyles();
|
||||
|
||||
const onNewCert = (event) => {
|
||||
@@ -21,14 +26,14 @@ const DownloadCerts = ({ vin, publicCert, privateCert, onChangeView }) => {
|
||||
<li>
|
||||
<DownloadFileLink
|
||||
data={publicCert}
|
||||
filename={`${vin}_cert.pem`}
|
||||
filename={`${commonName}_cert.pem`}
|
||||
mimetype={CertMimeType}
|
||||
/>
|
||||
</li>
|
||||
<li>
|
||||
<DownloadFileLink
|
||||
data={privateCert}
|
||||
filename={`${vin}_key.pem`}
|
||||
filename={`${commonName}_key.pem`}
|
||||
mimetype={CertMimeType}
|
||||
/>
|
||||
</li>
|
||||
|
||||
@@ -9,16 +9,16 @@ exports[`DownloadCerts Render 1`] = `
|
||||
<ul>
|
||||
<li>
|
||||
<a
|
||||
download="TESTVIN_cert.pem"
|
||||
download="undefined_cert.pem"
|
||||
>
|
||||
TESTVIN_cert.pem
|
||||
undefined_cert.pem
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a
|
||||
download="TESTVIN_key.pem"
|
||||
download="undefined_key.pem"
|
||||
>
|
||||
TESTVIN_key.pem
|
||||
undefined_key.pem
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
@@ -24,7 +24,7 @@ const MainForm = () => {
|
||||
const [view, setView] = useState(VIEW_FORM);
|
||||
const [pubCert, setPubCert] = useState(null);
|
||||
const [privCert, setPrivCert] = useState(null);
|
||||
const [vin, setVIN] = useState(null);
|
||||
const [commonName, setCommonName] = useState(null);
|
||||
|
||||
useEffect(() => {
|
||||
setTitle("Create Certificate");
|
||||
@@ -46,19 +46,19 @@ const MainForm = () => {
|
||||
|
||||
setPubCert(result.public_key);
|
||||
setPrivCert(result.private_key);
|
||||
setVIN(data.vin);
|
||||
setMessage(`Created ${data.vin} certificate`);
|
||||
setCommonName(data.common_name);
|
||||
setMessage(`Created ${data.common_name} certificate`);
|
||||
setView(VIEW_DOWNLOAD);
|
||||
} catch (e) {
|
||||
setMessage(e.message);
|
||||
logger.warn(e.stack);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
const onChangeView = () => {
|
||||
setPubCert(null);
|
||||
setPrivCert(null);
|
||||
setVIN(null);
|
||||
setCommonName(null);
|
||||
|
||||
setView(VIEW_FORM);
|
||||
};
|
||||
@@ -66,7 +66,7 @@ const MainForm = () => {
|
||||
if (view === VIEW_DOWNLOAD)
|
||||
return (
|
||||
<DownloadCerts
|
||||
vin={vin}
|
||||
commonName={commonName}
|
||||
publicCert={pubCert}
|
||||
privateCert={privCert}
|
||||
onChangeView={onChangeView}
|
||||
|
||||
@@ -18,6 +18,18 @@ const certificatesAPI = {
|
||||
})
|
||||
.then(fetchRespHandler)
|
||||
.catch(errorHandler),
|
||||
|
||||
createAftersales: async (data, token) =>
|
||||
fetch(`${API_ENDPOINT}/create-aftersales`, {
|
||||
method: "POST",
|
||||
headers: Object.assign(
|
||||
{ "Content-Type": "application/json" },
|
||||
getAuthHeaderOptions(token)
|
||||
),
|
||||
body: JSON.stringify(data),
|
||||
})
|
||||
.then(fetchRespHandler)
|
||||
.catch(errorHandler),
|
||||
};
|
||||
|
||||
export default certificatesAPI;
|
||||
|
||||
Reference in New Issue
Block a user