Skip to content

Commit

Permalink
/achievements/[id]の引数受け渡し
Browse files Browse the repository at this point in the history
  • Loading branch information
nasubi-dev committed Sep 6, 2024
1 parent 1806f26 commit 9cf71a3
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 18 deletions.
6 changes: 1 addition & 5 deletions src/components/achievements/Info.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,7 @@ export function Info({
return (
<InfoBox direction="column">
<Flex align="center" direction="column">
<Avatar
fallback="T"
size="9"
src={icon}
/>
<Avatar fallback="T" size="9" src={icon} />

<Text mt="1rem" size="8" weight="bold">
{name}
Expand Down
11 changes: 6 additions & 5 deletions src/components/member/Card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export function MemberCard({
point,
}: {
member: Member;
point: number;
point?: number;
}): ReactElement {
const navigate = useNavigate();

Expand Down Expand Up @@ -74,10 +74,11 @@ export function MemberCard({
/>

<NameStyle as="div">{member.name}</NameStyle>

<PointStyle as="div" size="6">
{point}pt
</PointStyle>
{point == null ? null : (
<PointStyle as="div" size="6">
{point}pt
</PointStyle>
)}
</CardStyle>
);
}
45 changes: 37 additions & 8 deletions src/pages/achievements/[id]/index.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,24 @@
import { Box, Flex, Text } from "@radix-ui/themes";
import { type ReactElement } from "react";
import { useParams } from "react-router-dom";
import styled from "styled-components";
import useSWRImmutable from "swr/immutable";
import { match } from "ts-pattern";
import { ErrorScreen } from "@/components/ErrorScreen";
import { Info } from "@/components/achievements/Info";
import { MemberCard } from "@/components/member/Card";
import { useAchievements } from "@/hooks/db/achievements";
import { useUnlockedAchievements } from "@/hooks/db/unlocked-achievements";
import { useTeam } from "@/hooks/teams";
import { S } from "@/lib/consts";
import { fetchMembersAndUnlockedAchievementsAndAchievements } from "@/lib/utils/fetchers";

Check failure on line 14 in src/pages/achievements/[id]/index.tsx

View workflow job for this annotation

GitHub Actions / build

Module '"@/lib/utils/fetchers"' has no exported member 'fetchMembersAndUnlockedAchievementsAndAchievements'.
import { handleSWRError } from "@/lib/utils/swr";
import { RecentUnlockedCard } from "@/components/achievements/RecentUnlockedCard";

const BoxStyle = styled(Box)`
margin: 0 auto;
height: 80vh;
overflow: scroll;
`;

export default function Page(): ReactElement {
const { id } = useParams();
Expand Down Expand Up @@ -38,14 +46,35 @@ export default function Page(): ReactElement {
const rateOfUnlocked = unlockedAchievements.filter(
(ua) => ua.achievementID === a.id,

Check failure on line 47 in src/pages/achievements/[id]/index.tsx

View workflow job for this annotation

GitHub Actions / build

Parameter 'ua' implicitly has an 'any' type.
).length;

const thisAchievementUnlockedMembers = members.filter((m) =>

Check failure on line 50 in src/pages/achievements/[id]/index.tsx

View workflow job for this annotation

GitHub Actions / build

Parameter 'm' implicitly has an 'any' type.
unlockedAchievements.some(
(ua) =>

Check failure on line 52 in src/pages/achievements/[id]/index.tsx

View workflow job for this annotation

GitHub Actions / build

Parameter 'ua' implicitly has an 'any' type.
ua.achievementID === a.id && ua.memberEmail === m.email,
),
);
return (
<Info
key={a.id}
icon={a.icon}
name={a.name}
rateOfUnlocked={rateOfUnlocked}
tags={a.tags}
/>
<Flex key={a.id} gap="9">
<Info
key={a.id}
icon={a.icon}
name={a.name}
rateOfUnlocked={rateOfUnlocked}
tags={a.tags}
/>
<div>
<Box mt="20vh" />
<BoxStyle>
<Text size="8" weight="bold">
最近解除したメンバー
</Text>
<Box mt="1rem" />
{thisAchievementUnlockedMembers.map((m) => (

Check failure on line 72 in src/pages/achievements/[id]/index.tsx

View workflow job for this annotation

GitHub Actions / build

Parameter 'm' implicitly has an 'any' type.
<MemberCard key={m.email} member={m} />
))}
</BoxStyle>
</div>
</Flex>
);
}
return null;
Expand Down

0 comments on commit 9cf71a3

Please sign in to comment.