Refactor registerGlobalVariable function signature
This commit is contained in:
parent
021612f5ae
commit
c724d1131a
2 changed files with 15 additions and 6 deletions
|
|
@ -864,11 +864,15 @@ export async function getGlobalVariables(): Promise<{
|
||||||
return globalVariables;
|
return globalVariables;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function registerGlobalVariable(
|
export async function registerGlobalVariable({
|
||||||
name: string,
|
name,
|
||||||
value: string,
|
value,
|
||||||
provider?: string
|
provider,
|
||||||
) {
|
}: {
|
||||||
|
name: string;
|
||||||
|
value: string;
|
||||||
|
provider?: string;
|
||||||
|
}) {
|
||||||
return await api.post(`${BASE_URL_API}credentials/`, {
|
return await api.post(`${BASE_URL_API}credentials/`, {
|
||||||
name,
|
name,
|
||||||
value,
|
value,
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,12 @@ export default function AddNewVariableButton(): JSX.Element {
|
||||||
(state) => state.addGlobalVariable
|
(state) => state.addGlobalVariable
|
||||||
);
|
);
|
||||||
function handleSaveVariable() {
|
function handleSaveVariable() {
|
||||||
registerGlobalVariable(key, value, provider).then((_) => {
|
let data: { name: string; value: string; provider?: string } = {
|
||||||
|
name: key,
|
||||||
|
value,
|
||||||
|
};
|
||||||
|
if (provider) data = { ...data, provider };
|
||||||
|
registerGlobalVariable(data).then((_) => {
|
||||||
addGlobalVariable(key, value, provider);
|
addGlobalVariable(key, value, provider);
|
||||||
setKey("");
|
setKey("");
|
||||||
setValue("");
|
setValue("");
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue