fix misc
This commit is contained in:
parent
9c6932d050
commit
11827c30c1
@ -9,7 +9,7 @@ export async function getConfig(context: TwilioContext, buzzer: string): Promise
|
||||
.then(res => res.json())
|
||||
.catch(err => {
|
||||
return undefined;
|
||||
});
|
||||
}) as InfoResponseClient;
|
||||
}
|
||||
|
||||
export async function notifyDiscord(context: TwilioContext, msg: string[], u: string[], optionalJsonStr: string[], metricsRegistry: Registry){
|
||||
|
||||
@ -6,6 +6,7 @@ import { InputTokenGroup } from "../components/InputTokenGroup";
|
||||
import { ReactNode, useState } from "react";
|
||||
import CInput from "react-hook-form-cloudscape/components/input";
|
||||
import CTextArea from "react-hook-form-cloudscape/components/textarea";
|
||||
import { fetchUrlEncoded } from "../helpers/FetchHelper";
|
||||
|
||||
export type DoorEditForm = DoorResponse & { pin: string, fallbackNumber: string, discordUser: string, isConfirmed: boolean };
|
||||
|
||||
@ -107,25 +108,30 @@ export const EditPage = ({ isOnboarding }: EditPageProps) => {
|
||||
timeout: parseInt("" + getValues("timeout"))
|
||||
};
|
||||
|
||||
fetch(apiRoute + `?door=${door}&newConfig=${encodeURIComponent(JSON.stringify(form))}`)
|
||||
.then(res => res.json())
|
||||
.then(res => {
|
||||
if (res.err) {
|
||||
addAlert("error", res.err);
|
||||
return;
|
||||
}
|
||||
if (!isOnboarding) {
|
||||
addAlert("success", `Created approval, check Discord notifcation from Doorman to confirm and approve the changes`);
|
||||
} else if (res.redirect) {
|
||||
// redirect for discord login
|
||||
addAlert("in-progress", `Created Door, you will now be redirected to Discord login to complete the onboarding`);
|
||||
const body = {
|
||||
door,
|
||||
newConfig: JSON.stringify(form),
|
||||
};
|
||||
|
||||
// redirect in 2 seconds
|
||||
setTimeout(() => {
|
||||
window.location = res.redirect;
|
||||
}, 2_000);
|
||||
}
|
||||
})
|
||||
fetchUrlEncoded(apiRoute, body)
|
||||
.then(res => res.json())
|
||||
.then(res => {
|
||||
if (res.err) {
|
||||
addAlert("error", res.err);
|
||||
return;
|
||||
}
|
||||
if (!isOnboarding) {
|
||||
addAlert("success", `Created approval, check Discord notifcation from Doorman to confirm and approve the changes`);
|
||||
} else if (res.redirect) {
|
||||
// redirect for discord login
|
||||
addAlert("in-progress", `Created Door, you will now be redirected to Discord login to complete the onboarding`);
|
||||
|
||||
// redirect in 2 seconds
|
||||
setTimeout(() => {
|
||||
window.location = res.redirect;
|
||||
}, 2_000);
|
||||
}
|
||||
});
|
||||
}}
|
||||
>
|
||||
Submit
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user