Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "feat: 버튼, 뱃지 컴포넌트 화" #266

Merged
merged 1 commit into from
Nov 28, 2024
Merged
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
67 changes: 0 additions & 67 deletions components/liveMatch/LeagueStatusButton.tsx

This file was deleted.

46 changes: 0 additions & 46 deletions components/liveMatch/LeagueTierBadge.tsx

This file was deleted.

107 changes: 99 additions & 8 deletions components/pages/LiveMatchList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,106 @@ import {
useGetMainLeagues,
useGetMainLeaguesMatch,
} from "@/lib/api/hooks/mainLeagueHook";
import type { LeagueStatus, Tier } from "@/types/commonTypes";
import type {
GetMainLeagues,
GetMainLeaguesMatchData,
} from "@/types/mainLeagueTypes";
import { getTierWithEmojiAndText } from "@/utils/getTier";
import { format } from "date-fns";
import Link from "next/link";
import React, { useState } from "react";
import LeagueStatusButton from "../liveMatch/LeagueStatusButton";
import LeagueTierBadge from "../liveMatch/LeagueTierBadge";

const renderLeagueStatusButton = (
status: LeagueStatus,
clubToken: string,
leagueId: number,
) => {
if (status === "PLAYING") {
return (
<AccordionTrigger className="p-2 h-8 rounded-md text-xs w-[105px] border-0 bg-orange-500 text-white hover:no-underline">
진행 상황 보기
</AccordionTrigger>
);
}
if (status === "RECRUITING") {
return (
<Link href={`/club/${clubToken}/league/${leagueId}`}>
<Button className="p-2 h-8 rounded-md text-xs w-[105px] border-0 bg-blue-500 text-white">
모집중
</Button>
</Link>
);
}

if (status === "RECRUITING_COMPLETED") {
return (
<Link href={`/club/${clubToken}/league/${leagueId}`}>
<Button className="p-2 h-8 rounded-md text-xs w-[105px] border-0 bg-gray-300 text-gray-600 hover:bg-gray-300 hover:text-gray-600">
모집마감
</Button>
</Link>
);
}

if (status === "CANCELED") {
return (
<Link href={`/club/${clubToken}/league/${leagueId}`}>
<Button
variant="outline"
className="p-2 h-8 rounded-md text-xs w-[105px] border border-gray-300 text-gray-600 hover:border-gray-300 hover:text-gray-600 hover:bg-white"
>
경기취소
</Button>
</Link>
);
}

if (status === "FINISHED") {
return (
<Link href={`/club/${clubToken}/league/${leagueId}`}>
<Button className="p-2 h-8 rounded-md text-xs w-[105px] border-primary hover:border-primary hover:text-primay hover:bg-white">
경기종료
</Button>
</Link>
);
}
};

const renderLeagueTierBadge = (tier: Tier) => {
if (tier === "GOLD") {
return (
<Badge
variant="outline"
className="font-semibold px-2 py-0.5 text-xs rounded-full border-0 w-fit bg-yellow-200 text-yellow-800"
>
{getTierWithEmojiAndText(tier)}
</Badge>
);
}

if (tier === "SILVER") {
return (
<Badge
variant="outline"
className="font-semibold px-2 py-0.5 text-xs rounded-full border-0 w-fit bg-gray-200 text-gray-700"
>
{getTierWithEmojiAndText(tier)}
</Badge>
);
}

if (tier === "BRONZE") {
return (
<Badge
variant="outline"
className="font-semibold px-2 py-0.5 text-xs rounded-full border-0 w-fit bg-orange-200 text-orange-800"
>
{getTierWithEmojiAndText(tier)}
</Badge>
);
}
};

function LiveMatchList() {
const today = format(new Date(), "yyyy-MM-dd");
Expand Down Expand Up @@ -89,7 +180,7 @@ function LiveMatchList() {
</p>
</div>
<div className="flex flex-col flex-grow pl-3 gap-1">
<LeagueTierBadge tier={item.required_tier} />
{renderLeagueTierBadge(item.required_tier)}
<div className="flex items-center my-1 pl-1">
<p className="text-base font-semibold text-gray-900">
{item.league_name}
Expand All @@ -110,11 +201,11 @@ function LiveMatchList() {
</div>
</Link>
<div className="flex items-center">
<LeagueStatusButton
status={item.league_status}
clubToken={item.club_token}
leagueId={item.league_id}
/>
{renderLeagueStatusButton(
item.league_status,
item.club_token,
item.league_id,
)}
</div>
</div>
<AccordionContent>
Expand Down