Skip to content
Closed
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
2 changes: 2 additions & 0 deletions src/app/(private)/(auth)/club/select/page.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { redirect } from 'next/navigation';
import { ClubList, HubProfile } from '@/components/auth/hub';
import { apiServer } from '@/lib/apis/server';
import { setClubCookie } from '@/lib/actions/club';
import type { ApiResponse } from '@/types/common';
import type { ClubDto } from '@/types/mypage';

Expand All @@ -10,6 +11,7 @@ export default async function ClubSelectPage() {

if (clubs.length === 1) {
const club = clubs[0];
await setClubCookie(club.id, club.name);
redirect(`/${club.id}/home`);
}

Expand Down
17 changes: 16 additions & 1 deletion src/app/(private)/(auth)/hub/page.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { unstable_rethrow } from 'next/navigation';
import { redirect, unstable_rethrow } from 'next/navigation';
import { HubActionCard, HubProfile } from '@/components/auth/hub';
import { apiServer } from '@/lib/apis/server';
import { setClubCookie } from '@/lib/actions/club';
import type { ApiResponse } from '@/types/common';
import type { ClubDto } from '@/types/mypage';

type CardVariant = 'create' | 'join' | 'go';

Expand Down Expand Up @@ -29,6 +32,18 @@ export default async function HubPage({
});

const hasActiveClub = status?.data?.hasActiveClub ?? false;

if (hasActiveClub) {
const clubsRes = await apiServer.get<ApiResponse<ClubDto[]>>('/clubs');
const clubs = clubsRes?.data ?? [];

if (clubs.length === 1) {
const club = clubs[0];
await setClubCookie(club.id, club.name);
redirect(`/${club.id}/home`);
}
}

if (hasActiveClub) goHref = '/club/select';

if (intent === 'create') {
Expand Down
Loading