Skip to content

Commit

Permalink
vinvoor: refactor the cards page
Browse files Browse the repository at this point in the history
  • Loading branch information
Topvennie committed Jun 22, 2024
1 parent 98c1bf4 commit 506895d
Show file tree
Hide file tree
Showing 16 changed files with 427 additions and 382 deletions.
52 changes: 0 additions & 52 deletions vinvoor/src/cards/Card.tsx

This file was deleted.

222 changes: 0 additions & 222 deletions vinvoor/src/cards/CardTable.tsx

This file was deleted.

53 changes: 0 additions & 53 deletions vinvoor/src/cards/CardTableToolBar.tsx

This file was deleted.

21 changes: 21 additions & 0 deletions vinvoor/src/cards/Cards.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { useState } from "react";
import { LoadingSkeleton } from "../components/LoadingSkeleton";
import { useFetch } from "../hooks/useFetch";
import { Card } from "../types/cards";
import { CardsEmpty } from "./CardsEmpty";
import { CardsTable } from "./CardsTable";

export const Cards = () => {
const [cards, setCards] = useState<readonly Card[]>([]);
const { loading, error: _ } = useFetch<readonly Card[]>("cards", setCards);

return (
<LoadingSkeleton loading={loading}>
{!!cards.length ? (
<CardsTable cards={cards} setCards={setCards} />
) : (
<CardsEmpty />
)}
</LoadingSkeleton>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Button, Typography } from "@mui/material";
import { useState } from "react";
import { ConfirmationModal } from "../components/ConfirmationModal";

export const CardAdd = () => {
export const CardsAdd = () => {
const [open, setOpen] = useState<boolean>(false);

const handleOpen = () => setOpen(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ import DeleteIcon from "@mui/icons-material/Delete";
import { Button, IconButton, Tooltip, Typography } from "@mui/material";
import { Dispatch, FC, SetStateAction, useState } from "react";
import { ConfirmationModal } from "../components/ConfirmationModal";
import { CardType } from "../types/Cards";
import { Card } from "../types/cards";

interface CardDeleteProps {
selected: readonly string[];
setCards: Dispatch<SetStateAction<readonly CardType[] | undefined>>;
setCards: Dispatch<SetStateAction<readonly Card[]>>;
}

export const CardDelete: FC<CardDeleteProps> = ({ selected, setCards }) => {
export const CardsDelete: FC<CardDeleteProps> = ({ selected, setCards }) => {
const [open, setOpen] = useState<boolean>(false);

const numSelected = selected.length;
Expand Down
Loading

0 comments on commit 506895d

Please sign in to comment.