make some params optional

This commit is contained in:
Mohammed
2023-02-03 22:34:18 +01:00
parent 1781b71399
commit 16883cf168
@@ -29,8 +29,8 @@ interface SecretProps {
interface FunctionProps { interface FunctionProps {
env: string; env: string;
setIsKeyAvailable: any; setIsKeyAvailable?: any;
setData: any; setData?: any;
workspaceId: string; workspaceId: string;
} }
@@ -58,7 +58,9 @@ const getSecretsForProject = async ({
const latestKey = await getLatestFileKey({ workspaceId }); const latestKey = await getLatestFileKey({ workspaceId });
// This is called isKeyAvailable but what it really means is if a person is able to create new key pairs // This is called isKeyAvailable but what it really means is if a person is able to create new key pairs
setIsKeyAvailable(!latestKey ? encryptedSecrets.length === 0 : true); if (typeof setIsKeyAvailable === 'function') {
setIsKeyAvailable(!latestKey ? encryptedSecrets.length === 0 : true);
}
const PRIVATE_KEY = localStorage.getItem('PRIVATE_KEY') as string; const PRIVATE_KEY = localStorage.getItem('PRIVATE_KEY') as string;
@@ -131,7 +133,10 @@ const getSecretsForProject = async ({
)[0]?.comment )[0]?.comment
})); }));
setData(result); if (typeof setData === 'function') {
setData(result);
}
return result; return result;
} catch (error) { } catch (error) {
console.log('Something went wrong during accessing or decripting secrets.'); console.log('Something went wrong during accessing or decripting secrets.');