Skip to content

Commit

Permalink
feat: notPlayedFilter
Browse files Browse the repository at this point in the history
  • Loading branch information
Simirall committed Aug 22, 2024
1 parent a95bffc commit e68a488
Showing 1 changed file with 76 additions and 54 deletions.
130 changes: 76 additions & 54 deletions src/pages/components/MadamisList.tsx
Original file line number Diff line number Diff line change
@@ -1,70 +1,92 @@
import { ActionIcon, Badge, Card, Group, NavLink, Stack } from "@mantine/core";
import {
ActionIcon,
Badge,
Card,
Chip,
Group,
NavLink,
Stack,
} from "@mantine/core";
import { Link, PencilSimple } from "@phosphor-icons/react";
import { useMadamisList } from "../hooks/useMadamisList";
import { useMadamisModalStore } from "../stores/madamisModalStore";
import { AddGameButton } from "./AddGamesButton";
import { GameState } from "./GameState";
import { Fragment } from "react/jsx-runtime";
import { useState } from "react";

export const MadamisList = () => {
const { data } = useMadamisList();
const { editOpen } = useMadamisModalStore();

const [onlyNotPlayed, updatePlayed] = useState(false);

return (
<>
<Group p="md" justify="center">
<Stack p="sm" align="center">
<Chip
size="xl"
checked={onlyNotPlayed}
onChange={(e) => {
updatePlayed(e);
}}
>
未プレイのみ
</Chip>
<Group justify="center">
{data &&
data.map((d) => (
<Card
key={d.id}
w="20rem"
shadow="sm"
p="md"
radius="md"
withBorder
>
<Stack>
<NavLink
href={d.link}
target="_blank"
label={d.title}
variant="subtle"
active
leftSection={<Link fontSize="1.4rem" />}
style={{
borderRadius: "4px",
}}
/>
<Group>
<Badge size="xl" color={d.gmRequired ? "orange" : "cyan"}>
GM: {d.gmRequired ? "要" : "レス可"}
</Badge>
<Badge size="xl" color="violet">
PL: {d.player}
</Badge>
<ActionIcon size="lg" radius="xl" variant="light">
<PencilSimple
fontSize="1.4rem"
onClick={() => {
editOpen(d.id);
}}
/>
</ActionIcon>
</Group>
{d.games.length > 0 && (
<Stack>
{d.games.map((g) => (
<Fragment key={g.id}>
<GameState game={g} madamisId={d.id} />
</Fragment>
))}
</Stack>
)}
{Boolean(d.bought) && <AddGameButton madamisId={d.id} />}
</Stack>
</Card>
))}
data
.filter((d) => (onlyNotPlayed ? d.games.length === 0 : true))
.map((d) => (
<Card
key={d.id}
w="20rem"
shadow="sm"
p="md"
radius="md"
withBorder
>
<Stack>
<NavLink
href={d.link}
target="_blank"
label={d.title}
variant="subtle"
active
leftSection={<Link fontSize="1.4rem" />}
style={{
borderRadius: "4px",
}}
/>
<Group>
<Badge size="xl" color={d.gmRequired ? "orange" : "cyan"}>
GM: {d.gmRequired ? "要" : "レス可"}
</Badge>
<Badge size="xl" color="violet">
PL: {d.player}
</Badge>
<ActionIcon size="lg" radius="xl" variant="light">
<PencilSimple
fontSize="1.4rem"
onClick={() => {
editOpen(d.id);
}}
/>
</ActionIcon>
</Group>
{d.games.length > 0 && (
<Stack>
{d.games.map((g) => (
<Fragment key={g.id}>
<GameState game={g} madamisId={d.id} />
</Fragment>
))}
</Stack>
)}
{Boolean(d.bought) && <AddGameButton madamisId={d.id} />}
</Stack>
</Card>
))}
</Group>
</>
</Stack>
);
};

0 comments on commit e68a488

Please sign in to comment.