chore: remove getServerSideProps (#2130)

This commit is contained in:
Aaryan Khandelwal 2023-09-11 12:13:00 +05:30 committed by GitHub
parent 5b228bd1eb
commit 8de93d0081
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 49 deletions

View File

@ -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
@ -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;

View File

@ -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");
@ -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 = {
@ -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");
@ -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;
@ -99,10 +82,4 @@ const AppPostInstallation = ({
);
};
export async function getServerSideProps(context: any) {
return {
props: context.query,
};
}
export default AppPostInstallation;