Continue integration frontend refactor

This commit is contained in:
Tuan Dang
2022-12-12 08:26:09 -05:00
parent 9e3ac6c31d
commit 397c15d61e
2 changed files with 16 additions and 19 deletions
+1 -1
View File
@@ -21,7 +21,7 @@ const getBot = async ({ workspaceId }: Props) => {
} }
).then(async (res) => { ).then(async (res) => {
if (res && res.status == 200) { if (res && res.status == 200) {
return await res.json(); return (await res.json()).bot;
} else { } else {
console.log("Failed to get bot for project"); console.log("Failed to get bot for project");
} }
+15 -18
View File
@@ -23,8 +23,8 @@ const {
const crypto = require("crypto"); const crypto = require("crypto");
export default function Integrations() { export default function Integrations() {
const [projectIntegrations, setProjectIntegrations] = useState([]); const [integrationAuths, setIntegrationAuths] = useState([]);
const [authorizations, setAuthorizations] = useState(); const [integrations, setIntegrations] = useState([]);
const [bot, setBot] = useState(null); const [bot, setBot] = useState(null);
const [isActivateBotOpen, setIsActivateBotOpen] = useState(false); const [isActivateBotOpen, setIsActivateBotOpen] = useState(false);
const [selectedIntegrationOption, setSelectedIntegrationOption] = useState(null); const [selectedIntegrationOption, setSelectedIntegrationOption] = useState(null);
@@ -33,23 +33,20 @@ export default function Integrations() {
useEffect(async () => { useEffect(async () => {
try { try {
// get integrations authorized for project // get project integration authorizations
let projectAuthorizations = await getWorkspaceAuthorizations({ setIntegrationAuths(await getWorkspaceAuthorizations({
workspaceId: router.query.id, workspaceId: router.query.id,
}); }));
setAuthorizations(projectAuthorizations);
// get active/inactive (cloud) integrations for project // get project integrations
const projectIntegrations = await getWorkspaceIntegrations({ setIntegrations(await getWorkspaceIntegrations({
workspaceId: router.query.id, workspaceId: router.query.id,
}); }));
setProjectIntegrations(projectIntegrations);
// get bot for project // get project bot
const bot = await getBot({ setBot(await getBot({
workspaceId: router.query.id workspaceId: router.query.id
}); }));
setBot(bot.bot);
} catch (err) { } catch (err) {
console.log(err); console.log(err);
@@ -170,18 +167,18 @@ export default function Integrations() {
handleBotActivate={handleBotActivate} handleBotActivate={handleBotActivate}
handleIntegrationOption={handleIntegrationOption} handleIntegrationOption={handleIntegrationOption}
/> />
{projectIntegrations.length > 0 && ( {integrations.length > 0 && ( // shouldn't need to check for length
<ProjectIntegrationSection <ProjectIntegrationSection
projectIntegrations={projectIntegrations} projectIntegrations={integrations}
/> />
)} )}
<CloudIntegrationSection <CloudIntegrationSection
projectIntegrations={projectIntegrations} projectIntegrations={integrations}
integrations={cloudIntegrations} integrations={cloudIntegrations}
setSelectedIntegrationOption={setSelectedIntegrationOption} setSelectedIntegrationOption={setSelectedIntegrationOption}
integrationOptionPress={integrationOptionPress} integrationOptionPress={integrationOptionPress}
deleteIntegrationAuth={deleteIntegrationAuth} deleteIntegrationAuth={deleteIntegrationAuth}
authorizations={authorizations} authorizations={integrationAuths}
/> />
<FrameworkIntegrationSection <FrameworkIntegrationSection
frameworks={frameworkIntegrations} frameworks={frameworkIntegrations}