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 Head from "next/head";
import { useRouter } from "next/router";
import useSWR from "swr";
/// layouts /// layouts
import ProjectLayout from "layouts/project-layout"; import ProjectLayout from "layouts/project-layout";
// components // 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; export default WorkspaceProjectPage;

View File

@ -1,37 +1,20 @@
import React, { useEffect } from "react"; 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"; import { useRouter } from "next/router";
interface IGithuPostInstallationProps { // services
installation_id: string; import appInstallationsService from "services/app-installations.service";
setup_action: string; // ui
state: string; import { Spinner } from "components/ui";
provider: string;
code: string;
}
// TODO:Change getServerSideProps to router.query const AppPostInstallation = () => {
const AppPostInstallation = ({ const router = useRouter();
installation_id, const { installation_id, setup_action, state, provider, code } = router.query;
setup_action,
state,
provider,
code,
}: IGithuPostInstallationProps) => {
const { setToastAlert } = useToast();
useEffect(() => { useEffect(() => {
if (provider === "github" && state && installation_id) { if (provider === "github" && state && installation_id) {
appinstallationsService appInstallationsService
.addInstallationApp(state, provider, { installation_id }) .addInstallationApp(state.toString(), provider, { installation_id })
.then(() => { .then(() => {
window.opener = null; window.opener = null;
window.open("", "_self"); window.open("", "_self");
@ -41,10 +24,10 @@ const AppPostInstallation = ({
console.log(err); console.log(err);
}); });
} else if (provider === "slack" && state && code) { } else if (provider === "slack" && state && code) {
appinstallationsService appInstallationsService
.getSlackAuthDetails(code) .getSlackAuthDetails(code.toString())
.then((res) => { .then((res) => {
const [workspaceSlug, projectId, integrationId] = state.split(","); const [workspaceSlug, projectId, integrationId] = state.toString().split(",");
if (!projectId) { if (!projectId) {
const payload = { const payload = {
@ -53,8 +36,8 @@ const AppPostInstallation = ({
}, },
}; };
appinstallationsService appInstallationsService
.addInstallationApp(state, provider, payload) .addInstallationApp(state.toString(), provider, payload)
.then((r) => { .then((r) => {
window.opener = null; window.opener = null;
window.open("", "_self"); window.open("", "_self");
@ -73,7 +56,7 @@ const AppPostInstallation = ({
team_name: res.team.name, team_name: res.team.name,
scopes: res.scope, scopes: res.scope,
}; };
appinstallationsService appInstallationsService
.addSlackChannel(workspaceSlug, projectId, integrationId, payload) .addSlackChannel(workspaceSlug, projectId, integrationId, payload)
.then((r) => { .then((r) => {
window.opener = null; window.opener = null;
@ -99,10 +82,4 @@ const AppPostInstallation = ({
); );
}; };
export async function getServerSideProps(context: any) {
return {
props: context.query,
};
}
export default AppPostInstallation; export default AppPostInstallation;