CEC-3301, CEC-3317 Magna security dll and remote commands (#249)

* CEC-3301, CEC-3317 Magna security dll and remote commands

* Fix test
This commit is contained in:
John Wu
2022-12-12 10:59:30 -08:00
committed by GitHub
parent 8e1b01b651
commit 2ec340efc5
28 changed files with 644 additions and 71 deletions

View File

@@ -0,0 +1,38 @@
import React, { useContext, useState } from "react";
import api from "../../services/suppliersAPI";
const KeygenContext = React.createContext();
export const KeygenProvider = ({ children }) => {
const [busy, setBusy] = useState(false);
const [securityCerts, setSecurityCerts] = useState(null);
const generateSecurityCerts = async (token) => {
setBusy(true);
try {
const data = await api.getManufactureCert(token);
if (data.error) throw new Error(data.message);
setSecurityCerts(data);
} finally {
setBusy(false);
}
};
return (
<KeygenContext.Provider
value={{
busy,
securityCerts,
generateSecurityCerts,
}}
>
{children}
</KeygenContext.Provider>
);
};
export const useKeygenContext = () => useContext(KeygenContext);