Skip to content

Commit

Permalink
fix: 경기 모집 인원 안채워 졌으면 대진표 생성 버튼 안보이게 처리 (#157)
Browse files Browse the repository at this point in the history
  • Loading branch information
Yejin0O0 authored Oct 18, 2024
1 parent 9dc397a commit a7b0ee5
Showing 1 changed file with 33 additions and 26 deletions.
59 changes: 33 additions & 26 deletions app/(header)/club/[clubId]/schedule/[leagueId]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
usePostParticipateLeague,
} from "@/lib/api/hooks/leagueHook";
import { usePostMatches } from "@/lib/api/hooks/matchHook";
import { useGetMyInfo } from "@/lib/api/hooks/memberHook";
import { getTierWithEmoji } from "@/utils/getTierWithEmoji";
import { format } from "date-fns";
import {
Expand Down Expand Up @@ -48,6 +49,7 @@ function LeaguePage() {
);
const { mutate: deleteLeague } = useDeleteLeague(clubId, leagueId);
const { mutate: createMatch } = usePostMatches(clubId, leagueId);
const { data: myData } = useGetMyInfo(true);

const handleParticipate = (isParticipate: boolean) => {
if (!isParticipate) {
Expand Down Expand Up @@ -91,38 +93,43 @@ function LeaguePage() {
};

const renderButtonByMatchCreatedStatus = () => {
if (league?.is_match_created === true) {
if (league?.player_limit_count !== league?.recruited_member_count) {
return null;
}

if (!league?.is_match_created) {
return (
<Link
href={`/club/${clubId}/schedule/${leagueId}/match`}
className="flex justify-center items-center gap-4 w-1/3"
<Button
size="lg"
variant="outline"
className="items-center justify-center gap-2 border-primary w-1/3 hover:bg-white hover:text-primary"
onClick={() =>
createMatch(undefined, {
onSuccess: () =>
router.push(`/club/${clubId}/schedule/${leagueId}/match`),
})
}
>
<Button
size="lg"
variant="outline"
className="items-center justify-center gap-2 border-primary w-full"
>
<BookUser size={20} />
대진표 보기
</Button>
</Link>
<BookUser size={20} />
대진표 생성
</Button>
);
}

return (
<Button
size="lg"
variant="outline"
className="items-center justify-center gap-2 border-primary w-1/3 hover:bg-white hover:text-primary"
onClick={() =>
createMatch(undefined, {
onSuccess: () =>
router.push(`/club/${clubId}/schedule/${leagueId}/match`),
})
}
<Link
href={`/club/${clubId}/schedule/${leagueId}/match`}
className="flex justify-center items-center gap-4 w-1/3"
>
<BookUser size={20} />
대진표 생성
</Button>
<Button
size="lg"
variant="outline"
className="items-center justify-center gap-2 border-primary w-full"
>
<BookUser size={20} />
대진표 보기
</Button>
</Link>
);
};

Expand Down

0 comments on commit a7b0ee5

Please sign in to comment.