From c1a78cc2303717b2c52905476be0ce426f1b88b2 Mon Sep 17 00:00:00 2001 From: Dakshesh Jain <65905942+dakshesh14@users.noreply.github.com> Date: Wed, 22 Feb 2023 17:54:27 +0530 Subject: [PATCH] fix: redirection after login (#320) --- apps/app/pages/[workspaceSlug]/index.tsx | 6 +++--- apps/app/pages/[workspaceSlug]/me/profile.tsx | 6 +++--- .../projects/[projectId]/cycles/[cycleId].tsx | 7 ++++--- .../[workspaceSlug]/projects/[projectId]/cycles/index.tsx | 6 +++--- .../projects/[projectId]/issues/[issueId].tsx | 6 +++--- .../[workspaceSlug]/projects/[projectId]/issues/index.tsx | 7 ++++--- .../projects/[projectId]/modules/[moduleId].tsx | 7 ++++--- .../[workspaceSlug]/projects/[projectId]/modules/index.tsx | 6 +++--- apps/app/pages/onboarding/index.tsx | 6 +++--- 9 files changed, 30 insertions(+), 27 deletions(-) diff --git a/apps/app/pages/[workspaceSlug]/index.tsx b/apps/app/pages/[workspaceSlug]/index.tsx index 9c3407b5e..ef0fb9d88 100644 --- a/apps/app/pages/[workspaceSlug]/index.tsx +++ b/apps/app/pages/[workspaceSlug]/index.tsx @@ -28,7 +28,7 @@ import { renderShortNumericDateFormat, findHowManyDaysLeft } from "helpers/date- import { addSpaceIfCamelCase } from "helpers/string.helper"; import { groupBy } from "helpers/array.helper"; // types -import type { NextPage, NextPageContext } from "next"; +import type { NextPage, GetServerSidePropsContext } from "next"; const WorkspacePage: NextPage = () => { // router @@ -226,10 +226,10 @@ const WorkspacePage: NextPage = () => { ); }; -export const getServerSideProps = async (ctx: NextPageContext) => { +export const getServerSideProps = async (ctx: GetServerSidePropsContext) => { const user = await requiredAuth(ctx.req?.headers.cookie); - const redirectAfterSignIn = ctx.req?.url; + const redirectAfterSignIn = ctx.resolvedUrl; if (!user) { return { diff --git a/apps/app/pages/[workspaceSlug]/me/profile.tsx b/apps/app/pages/[workspaceSlug]/me/profile.tsx index a9517d46d..f636028b5 100644 --- a/apps/app/pages/[workspaceSlug]/me/profile.tsx +++ b/apps/app/pages/[workspaceSlug]/me/profile.tsx @@ -36,7 +36,7 @@ import { XMarkIcon, } from "@heroicons/react/24/outline"; // types -import type { NextPage, NextPageContext } from "next"; +import type { NextPage, GetServerSidePropsContext } from "next"; import type { IIssue, IUser } from "types"; // fetch-keys import { USER_ISSUE, USER_WORKSPACE_INVITATIONS, PROJECTS_LIST } from "constants/fetch-keys"; @@ -297,10 +297,10 @@ const Profile: NextPage = () => { ); }; -export const getServerSideProps = async (ctx: NextPageContext) => { +export const getServerSideProps = async (ctx: GetServerSidePropsContext) => { const user = await requiredAuth(ctx.req?.headers.cookie); - const redirectAfterSignIn = ctx.req?.url; + const redirectAfterSignIn = ctx.resolvedUrl; if (!user) { return { diff --git a/apps/app/pages/[workspaceSlug]/projects/[projectId]/cycles/[cycleId].tsx b/apps/app/pages/[workspaceSlug]/projects/[projectId]/cycles/[cycleId].tsx index b026c00b7..518fb06ff 100644 --- a/apps/app/pages/[workspaceSlug]/projects/[projectId]/cycles/[cycleId].tsx +++ b/apps/app/pages/[workspaceSlug]/projects/[projectId]/cycles/[cycleId].tsx @@ -3,7 +3,7 @@ import React, { useState } from "react"; import { useRouter } from "next/router"; import useSWR, { mutate } from "swr"; -import { NextPageContext } from "next"; +import { GetServerSidePropsContext } from "next"; // icons import { ArrowLeftIcon, ListBulletIcon, PlusIcon } from "@heroicons/react/24/outline"; import { CyclesIcon } from "components/icons"; @@ -226,9 +226,10 @@ const SingleCycle: React.FC = (props) => { ); }; -export const getServerSideProps = async (ctx: NextPageContext) => { +export const getServerSideProps = async (ctx: GetServerSidePropsContext) => { const user = await requiredAuth(ctx.req?.headers.cookie); - const redirectAfterSignIn = ctx.req?.url; + + const redirectAfterSignIn = ctx.resolvedUrl; if (!user) { return { diff --git a/apps/app/pages/[workspaceSlug]/projects/[projectId]/cycles/index.tsx b/apps/app/pages/[workspaceSlug]/projects/[projectId]/cycles/index.tsx index 8caef1266..df18ba620 100644 --- a/apps/app/pages/[workspaceSlug]/projects/[projectId]/cycles/index.tsx +++ b/apps/app/pages/[workspaceSlug]/projects/[projectId]/cycles/index.tsx @@ -22,7 +22,7 @@ import { BreadcrumbItem, Breadcrumbs } from "components/breadcrumbs"; // icons // types import { ICycle, SelectCycleType } from "types"; -import type { NextPage, NextPageContext } from "next"; +import type { NextPage, GetServerSidePropsContext } from "next"; // fetching keys import { CYCLE_LIST, PROJECT_DETAILS, WORKSPACE_DETAILS } from "constants/fetch-keys"; @@ -200,10 +200,10 @@ const ProjectCycles: NextPage = () => { ); }; -export const getServerSideProps = async (ctx: NextPageContext) => { +export const getServerSideProps = async (ctx: GetServerSidePropsContext) => { const user = await requiredAuth(ctx.req?.headers.cookie); - const redirectAfterSignIn = ctx.req?.url; + const redirectAfterSignIn = ctx.resolvedUrl; if (!user) { return { diff --git a/apps/app/pages/[workspaceSlug]/projects/[projectId]/issues/[issueId].tsx b/apps/app/pages/[workspaceSlug]/projects/[projectId]/issues/[issueId].tsx index 007a665f6..e9b5ba271 100644 --- a/apps/app/pages/[workspaceSlug]/projects/[projectId]/issues/[issueId].tsx +++ b/apps/app/pages/[workspaceSlug]/projects/[projectId]/issues/[issueId].tsx @@ -26,7 +26,7 @@ import { Loader, CustomMenu } from "components/ui"; import { Breadcrumbs } from "components/breadcrumbs"; // types import { IIssue, UserAuth } from "types"; -import type { NextPage, NextPageContext } from "next"; +import type { GetServerSidePropsContext, NextPage } from "next"; // fetch-keys import { PROJECT_ISSUES_ACTIVITY, ISSUE_DETAILS, SUB_ISSUES } from "constants/fetch-keys"; @@ -233,10 +233,10 @@ const IssueDetailsPage: NextPage = (props) => { ); }; -export const getServerSideProps = async (ctx: NextPageContext) => { +export const getServerSideProps = async (ctx: GetServerSidePropsContext) => { const user = await requiredAuth(ctx.req?.headers.cookie); - const redirectAfterSignIn = ctx.req?.url; + const redirectAfterSignIn = ctx.resolvedUrl; if (!user) { return { diff --git a/apps/app/pages/[workspaceSlug]/projects/[projectId]/issues/index.tsx b/apps/app/pages/[workspaceSlug]/projects/[projectId]/issues/index.tsx index df8984d1c..3c94594de 100644 --- a/apps/app/pages/[workspaceSlug]/projects/[projectId]/issues/index.tsx +++ b/apps/app/pages/[workspaceSlug]/projects/[projectId]/issues/index.tsx @@ -20,7 +20,7 @@ import { BreadcrumbItem, Breadcrumbs } from "components/breadcrumbs"; import { RectangleStackIcon, PlusIcon } from "@heroicons/react/24/outline"; // types import type { UserAuth } from "types"; -import type { NextPage, NextPageContext } from "next"; +import type { GetServerSidePropsContext, NextPage } from "next"; // fetch-keys import { PROJECT_DETAILS, PROJECT_ISSUES_LIST } from "constants/fetch-keys"; @@ -111,9 +111,10 @@ const ProjectIssues: NextPage = (props) => { ); }; -export const getServerSideProps = async (ctx: NextPageContext) => { +export const getServerSideProps = async (ctx: GetServerSidePropsContext) => { const user = await requiredAuth(ctx.req?.headers.cookie); - const redirectAfterSignIn = ctx.req?.url; + + const redirectAfterSignIn = ctx.resolvedUrl; if (!user) { return { diff --git a/apps/app/pages/[workspaceSlug]/projects/[projectId]/modules/[moduleId].tsx b/apps/app/pages/[workspaceSlug]/projects/[projectId]/modules/[moduleId].tsx index 262e01b7d..b0e8eeb59 100644 --- a/apps/app/pages/[workspaceSlug]/projects/[projectId]/modules/[moduleId].tsx +++ b/apps/app/pages/[workspaceSlug]/projects/[projectId]/modules/[moduleId].tsx @@ -1,7 +1,7 @@ import React, { useState } from "react"; import { useRouter } from "next/router"; -import { NextPageContext } from "next"; +import { GetServerSidePropsContext } from "next"; import useSWR, { mutate } from "swr"; // icons @@ -222,9 +222,10 @@ const SingleModule: React.FC = (props) => { ); }; -export const getServerSideProps = async (ctx: NextPageContext) => { +export const getServerSideProps = async (ctx: GetServerSidePropsContext) => { const user = await requiredAuth(ctx.req?.headers.cookie); - const redirectAfterSignIn = ctx.req?.url; + + const redirectAfterSignIn = ctx.resolvedUrl; if (!user) { return { diff --git a/apps/app/pages/[workspaceSlug]/projects/[projectId]/modules/index.tsx b/apps/app/pages/[workspaceSlug]/projects/[projectId]/modules/index.tsx index 266d79318..c0824dcdf 100644 --- a/apps/app/pages/[workspaceSlug]/projects/[projectId]/modules/index.tsx +++ b/apps/app/pages/[workspaceSlug]/projects/[projectId]/modules/index.tsx @@ -20,7 +20,7 @@ import { BreadcrumbItem, Breadcrumbs } from "components/breadcrumbs"; // types import { IModule, SelectModuleType } from "types/modules"; // fetch-keys -import type { NextPage, NextPageContext } from "next"; +import type { NextPage, GetServerSidePropsContext } from "next"; import { MODULE_LIST, PROJECT_DETAILS } from "constants/fetch-keys"; const ProjectModules: NextPage = () => { @@ -139,10 +139,10 @@ const ProjectModules: NextPage = () => { ); }; -export const getServerSideProps = async (ctx: NextPageContext) => { +export const getServerSideProps = async (ctx: GetServerSidePropsContext) => { const user = await requiredAuth(ctx.req?.headers.cookie); - const redirectAfterSignIn = ctx.req?.url; + const redirectAfterSignIn = ctx.resolvedUrl; if (!user) { return { diff --git a/apps/app/pages/onboarding/index.tsx b/apps/app/pages/onboarding/index.tsx index 48f01462b..9bae9bf9a 100644 --- a/apps/app/pages/onboarding/index.tsx +++ b/apps/app/pages/onboarding/index.tsx @@ -23,7 +23,7 @@ import CommandMenu from "components/onboarding/command-menu"; // images import Logo from "public/onboarding/logo.svg"; // types -import type { NextPage, NextPageContext } from "next"; +import type { NextPage, GetServerSidePropsContext } from "next"; const Onboarding: NextPage = () => { const [step, setStep] = useState(1); @@ -92,10 +92,10 @@ const Onboarding: NextPage = () => { ); }; -export const getServerSideProps = async (ctx: NextPageContext) => { +export const getServerSideProps = async (ctx: GetServerSidePropsContext) => { const user = await requiredAuth(ctx.req?.headers.cookie); - const redirectAfterSignIn = ctx.req?.url; + const redirectAfterSignIn = ctx.resolvedUrl; if (!user) { return {