Skip to content

Commit c1f7aaa

Browse files
committed
chore: redirect /team to /team/~ to select a team (#7124)
## [Dashboard] Fix: Simplify team redirection logic ## Notes for the reviewer This PR modifies the team redirection logic by: 1. Renaming `getLastVisitedTeamOrDefaultTeam()` to `getLastVisitedTeam()` 2. Removing the fallback to `getDefaultTeam()` when no last visited team is found 3. Updating the team root page to redirect to `/team/~` when no team is found instead of showing a 404 ## How to test Verify that users are properly redirected to their last visited team when available, and to `/team/~` when no team history exists. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **Bug Fixes** - Improved handling when no last visited team is found by redirecting users to a fallback page instead of showing a not found error. - **Refactor** - Updated team selection logic to remove fallback to a default team and streamline user redirection. <!-- end of auto-generated comment: release notes by coderabbit.ai --> <!-- start pr-codex --> --- ## PR-Codex overview This PR refactors the `getLastVisitedTeamOrDefaultTeam` function to `getLastVisitedTeam`, changing its behavior to return `null` instead of a default team. It updates the `TeamRootPage` to handle the absence of a team by redirecting to a fallback URL. ### Detailed summary - Renamed function `getLastVisitedTeamOrDefaultTeam` to `getLastVisitedTeam`. - Changed return value of `getLastVisitedTeam` from `getDefaultTeam()` to `null`. - Updated `TeamRootPage` to redirect to `/team/~` if no team is found, instead of calling `notFound()`. > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` <!-- end pr-codex -->
1 parent 1ad109f commit c1f7aaa

File tree

2 files changed

+6
-9
lines changed

2 files changed

+6
-9
lines changed

apps/dashboard/src/@/api/team.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ export async function getDefaultTeam() {
8484
return null;
8585
}
8686

87-
export async function getLastVisitedTeamOrDefaultTeam() {
87+
export async function getLastVisitedTeam() {
8888
const token = await getAuthToken();
8989
if (!token) {
9090
return null;
@@ -100,5 +100,5 @@ export async function getLastVisitedTeamOrDefaultTeam() {
100100
}
101101
}
102102

103-
return getDefaultTeam();
103+
return null;
104104
}
Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
1-
import { getLastVisitedTeamOrDefaultTeam } from "@/api/team";
2-
import { notFound, redirect } from "next/navigation";
1+
import { getLastVisitedTeam } from "@/api/team";
2+
import { redirect } from "next/navigation";
33

44
export default async function TeamRootPage() {
5-
const team = await getLastVisitedTeamOrDefaultTeam();
6-
if (!team) {
7-
notFound();
8-
}
9-
redirect(`/team/${team.slug}`);
5+
const team = await getLastVisitedTeam();
6+
redirect(team ? `/team/${team.slug}` : "/team/~");
107
}

0 commit comments

Comments
 (0)