Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 4 additions & 11 deletions space/pages/[workspace_slug]/[project_slug]/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import useSWR from "swr";
import type { GetServerSideProps } from "next";
import { useRouter } from "next/router";
import Head from "next/head";
import { useRouter } from "next/router";

import useSWR from "swr";

/// layouts
import ProjectLayout from "layouts/project-layout";
// components
Expand Down Expand Up @@ -39,12 +40,4 @@ const WorkspaceProjectPage = (props: any) => {
);
};

// export const getServerSideProps: GetServerSideProps<any> = async ({ query: { workspace_slug, project_slug } }) => {
// const res = await fetch(
// `${process.env.NEXT_PUBLIC_API_BASE_URL}/api/public/workspaces/${workspace_slug}/project-boards/${project_slug}/settings/`
// );
// const project_settings = await res.json();
// return { props: { project_settings } };
// };

export default WorkspaceProjectPage;
53 changes: 15 additions & 38 deletions web/pages/installations/[provider]/index.tsx
Original file line number Diff line number Diff line change
@@ -1,37 +1,20 @@
import React, { useEffect } from "react";

// services
import appinstallationsService from "services/app-installations.service";

import useToast from "hooks/use-toast";

// components
import { Spinner } from "components/ui";

import { useRouter } from "next/router";

interface IGithuPostInstallationProps {
installation_id: string;
setup_action: string;
state: string;
provider: string;
code: string;
}
// services
import appInstallationsService from "services/app-installations.service";
// ui
import { Spinner } from "components/ui";

// TODO:Change getServerSideProps to router.query
const AppPostInstallation = ({
installation_id,
setup_action,
state,
provider,
code,
}: IGithuPostInstallationProps) => {
const { setToastAlert } = useToast();
const AppPostInstallation = () => {
const router = useRouter();
const { installation_id, setup_action, state, provider, code } = router.query;

useEffect(() => {
if (provider === "github" && state && installation_id) {
appinstallationsService
.addInstallationApp(state, provider, { installation_id })
appInstallationsService
.addInstallationApp(state.toString(), provider, { installation_id })
.then(() => {
window.opener = null;
window.open("", "_self");
Expand All @@ -41,10 +24,10 @@ const AppPostInstallation = ({
console.log(err);
});
} else if (provider === "slack" && state && code) {
appinstallationsService
.getSlackAuthDetails(code)
appInstallationsService
.getSlackAuthDetails(code.toString())
.then((res) => {
const [workspaceSlug, projectId, integrationId] = state.split(",");
const [workspaceSlug, projectId, integrationId] = state.toString().split(",");

if (!projectId) {
const payload = {
Expand All @@ -53,8 +36,8 @@ const AppPostInstallation = ({
},
};

appinstallationsService
.addInstallationApp(state, provider, payload)
appInstallationsService
.addInstallationApp(state.toString(), provider, payload)
.then((r) => {
window.opener = null;
window.open("", "_self");
Expand All @@ -73,7 +56,7 @@ const AppPostInstallation = ({
team_name: res.team.name,
scopes: res.scope,
};
appinstallationsService
appInstallationsService
.addSlackChannel(workspaceSlug, projectId, integrationId, payload)
.then((r) => {
window.opener = null;
Expand All @@ -99,10 +82,4 @@ const AppPostInstallation = ({
);
};

export async function getServerSideProps(context: any) {
return {
props: context.query,
};
}

export default AppPostInstallation;