CEC-2281 Fix cert name
This commit is contained in:
@@ -6031,57 +6031,6 @@ exports[`App Route /tools/certificates/add authenticated 1`] = `
|
|||||||
Charging
|
Charging
|
||||||
</span>
|
</span>
|
||||||
</label>
|
</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>
|
</div>
|
||||||
<button
|
<button
|
||||||
class="MuiButtonBase-root MuiButton-root MuiButton-contained makeStyles-submit-0 MuiButton-containedPrimary MuiButton-fullWidth"
|
class="MuiButtonBase-root MuiButton-root MuiButton-contained makeStyles-submit-0 MuiButton-containedPrimary MuiButton-fullWidth"
|
||||||
|
|||||||
@@ -75,11 +75,6 @@ const CreateForm = ({ onCreate, busy }) => {
|
|||||||
control={<Radio />}
|
control={<Radio />}
|
||||||
label="Charging"
|
label="Charging"
|
||||||
/>
|
/>
|
||||||
<FormControlLabel
|
|
||||||
value={CertTypes.Aftersales}
|
|
||||||
control={<Radio />}
|
|
||||||
label="Aftersales"
|
|
||||||
/>
|
|
||||||
</RadioGroup>
|
</RadioGroup>
|
||||||
<Button
|
<Button
|
||||||
type="submit"
|
type="submit"
|
||||||
|
|||||||
@@ -6,7 +6,12 @@ import useStyles from "../../useStyles";
|
|||||||
|
|
||||||
const CertMimeType = "application/x-pem-file";
|
const CertMimeType = "application/x-pem-file";
|
||||||
|
|
||||||
const DownloadCerts = ({ vin, publicCert, privateCert, onChangeView }) => {
|
const DownloadCerts = ({
|
||||||
|
commonName,
|
||||||
|
publicCert,
|
||||||
|
privateCert,
|
||||||
|
onChangeView,
|
||||||
|
}) => {
|
||||||
const classes = useStyles();
|
const classes = useStyles();
|
||||||
|
|
||||||
const onNewCert = (event) => {
|
const onNewCert = (event) => {
|
||||||
@@ -21,14 +26,14 @@ const DownloadCerts = ({ vin, publicCert, privateCert, onChangeView }) => {
|
|||||||
<li>
|
<li>
|
||||||
<DownloadFileLink
|
<DownloadFileLink
|
||||||
data={publicCert}
|
data={publicCert}
|
||||||
filename={`${vin}_cert.pem`}
|
filename={`${commonName}_cert.pem`}
|
||||||
mimetype={CertMimeType}
|
mimetype={CertMimeType}
|
||||||
/>
|
/>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<DownloadFileLink
|
<DownloadFileLink
|
||||||
data={privateCert}
|
data={privateCert}
|
||||||
filename={`${vin}_key.pem`}
|
filename={`${commonName}_key.pem`}
|
||||||
mimetype={CertMimeType}
|
mimetype={CertMimeType}
|
||||||
/>
|
/>
|
||||||
</li>
|
</li>
|
||||||
|
|||||||
@@ -9,16 +9,16 @@ exports[`DownloadCerts Render 1`] = `
|
|||||||
<ul>
|
<ul>
|
||||||
<li>
|
<li>
|
||||||
<a
|
<a
|
||||||
download="TESTVIN_cert.pem"
|
download="undefined_cert.pem"
|
||||||
>
|
>
|
||||||
TESTVIN_cert.pem
|
undefined_cert.pem
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a
|
<a
|
||||||
download="TESTVIN_key.pem"
|
download="undefined_key.pem"
|
||||||
>
|
>
|
||||||
TESTVIN_key.pem
|
undefined_key.pem
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ const MainForm = () => {
|
|||||||
const [view, setView] = useState(VIEW_FORM);
|
const [view, setView] = useState(VIEW_FORM);
|
||||||
const [pubCert, setPubCert] = useState(null);
|
const [pubCert, setPubCert] = useState(null);
|
||||||
const [privCert, setPrivCert] = useState(null);
|
const [privCert, setPrivCert] = useState(null);
|
||||||
const [vin, setVIN] = useState(null);
|
const [commonName, setCommonName] = useState(null);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setTitle("Create Certificate");
|
setTitle("Create Certificate");
|
||||||
@@ -46,8 +46,8 @@ const MainForm = () => {
|
|||||||
|
|
||||||
setPubCert(result.public_key);
|
setPubCert(result.public_key);
|
||||||
setPrivCert(result.private_key);
|
setPrivCert(result.private_key);
|
||||||
setVIN(data.vin);
|
setCommonName(data.common_name);
|
||||||
setMessage(`Created ${data.vin} certificate`);
|
setMessage(`Created ${data.common_name} certificate`);
|
||||||
setView(VIEW_DOWNLOAD);
|
setView(VIEW_DOWNLOAD);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
setMessage(e.message);
|
setMessage(e.message);
|
||||||
@@ -58,7 +58,7 @@ const MainForm = () => {
|
|||||||
const onChangeView = () => {
|
const onChangeView = () => {
|
||||||
setPubCert(null);
|
setPubCert(null);
|
||||||
setPrivCert(null);
|
setPrivCert(null);
|
||||||
setVIN(null);
|
setCommonName(null);
|
||||||
|
|
||||||
setView(VIEW_FORM);
|
setView(VIEW_FORM);
|
||||||
};
|
};
|
||||||
@@ -66,7 +66,7 @@ const MainForm = () => {
|
|||||||
if (view === VIEW_DOWNLOAD)
|
if (view === VIEW_DOWNLOAD)
|
||||||
return (
|
return (
|
||||||
<DownloadCerts
|
<DownloadCerts
|
||||||
vin={vin}
|
commonName={commonName}
|
||||||
publicCert={pubCert}
|
publicCert={pubCert}
|
||||||
privateCert={privCert}
|
privateCert={privCert}
|
||||||
onChangeView={onChangeView}
|
onChangeView={onChangeView}
|
||||||
|
|||||||
@@ -18,6 +18,18 @@ const certificatesAPI = {
|
|||||||
})
|
})
|
||||||
.then(fetchRespHandler)
|
.then(fetchRespHandler)
|
||||||
.catch(errorHandler),
|
.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;
|
export default certificatesAPI;
|
||||||
|
|||||||
Reference in New Issue
Block a user