Skip to content

Commit

Permalink
/achievements/unlockedのスクロール可能にした
Browse files Browse the repository at this point in the history
  • Loading branch information
nasubi916 committed Sep 6, 2024
1 parent 84439c9 commit 271c3a6
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 40 deletions.
26 changes: 14 additions & 12 deletions src/pages/achievements/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { type Achievement } from "@/types/post-data/achievements";

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

Expand All @@ -24,18 +24,20 @@ export default function Page(): ReactElement {
return match(swrAchievements)
.with(S.Loading, () => <div>Loading...</div>)
.with(S.Success, ({ data }) => (
<BoxStyle width="70%">
<>
<Box mt="20vh" />
{data.map((achievement) => {
const typedAchievement = achievement as unknown as Achievement;
return (
<AchievementCard
key={achievement.id}
achievement={typedAchievement}
/>
);
})}
</BoxStyle>
<BoxStyle width="70%">
{data.map((achievement) => {
const typedAchievement = achievement as unknown as Achievement;
return (
<AchievementCard
key={achievement.id}
achievement={typedAchievement}
/>
);
})}
</BoxStyle>
</>
))
.otherwise(({ data, error }) => (
<ErrorScreen error={handleSWRError(data, error)} />
Expand Down
1 change: 0 additions & 1 deletion src/pages/members/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ export default function Page(): ReactElement {
return <MemberCard key={m.email} member={m} point={point} />;
})}
</BoxStyle>
<Box mt="20vh" />
</>
))
.otherwise(({ data, error }) => (
Expand Down
56 changes: 29 additions & 27 deletions src/pages/unlocked/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { type UnlockedAchievement } from "@/types/post-data/unlocked-achievement

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

Expand Down Expand Up @@ -83,34 +83,36 @@ export default function Page(): ReactElement {
data: { achievements, unlockedAchievements, currentMember },
mutate,
}) => (
<BoxStyle width="70%">
<>
<Box mt="20vh" />
{achievements.map((achievement) => {
const isUnlocked = unlockedAchievements.some(
(u) => u.achievementID === achievement.id,
);
<BoxStyle width="70%">
{achievements.map((achievement) => {
const isUnlocked = unlockedAchievements.some(
(u) => u.achievementID === achievement.id,
);

return (
<UnlockableCard
key={achievement.id}
achievement={achievement}
isDisabled={isUILocked}
isUnlocked={isUnlocked}
setIsUnlocked={(u) => {
void handleUnlockToggle(
achievement.id,
unlockedAchievements,
currentMember,
u,
async () => {
await mutate();
},
);
}}
/>
);
})}
</BoxStyle>
return (
<UnlockableCard
key={achievement.id}
achievement={achievement}
isDisabled={isUILocked}
isUnlocked={isUnlocked}
setIsUnlocked={(u) => {
void handleUnlockToggle(
achievement.id,
unlockedAchievements,
currentMember,
u,
async () => {
await mutate();
},
);
}}
/>
);
})}
</BoxStyle>
</>
),
)
.otherwise(({ data, error }) => (
Expand Down

0 comments on commit 271c3a6

Please sign in to comment.