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;
|
||||
}
|
||||
|
||||
export async function registerGlobalVariable(
|
||||
name: string,
|
||||
value: string,
|
||||
provider?: string
|
||||
) {
|
||||
export async function registerGlobalVariable({
|
||||
name,
|
||||
value,
|
||||
provider,
|
||||
}: {
|
||||
name: string;
|
||||
value: string;
|
||||
provider?: string;
|
||||
}) {
|
||||
return await api.post(`${BASE_URL_API}credentials/`, {
|
||||
name,
|
||||
value,
|
||||
|
|
|
|||
|
|
@ -19,7 +19,12 @@ export default function AddNewVariableButton(): JSX.Element {
|
|||
(state) => state.addGlobalVariable
|
||||
);
|
||||
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);
|
||||
setKey("");
|
||||
setValue("");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue