test(front end): added in card test but removing
This commit is contained in:
58
frontend/src/components/dashboard/AddCards.tsx
Normal file
58
frontend/src/components/dashboard/AddCards.tsx
Normal file
@@ -0,0 +1,58 @@
|
||||
import { Button } from "@/components/ui/button";
|
||||
import {
|
||||
Dialog,
|
||||
DialogContent,
|
||||
DialogDescription,
|
||||
DialogFooter,
|
||||
DialogHeader,
|
||||
DialogTitle,
|
||||
DialogTrigger,
|
||||
} from "@/components/ui/dialog";
|
||||
|
||||
import { useCardStore } from "@/lib/store/useCardStore";
|
||||
import { toast } from "sonner";
|
||||
|
||||
export function AddCards() {
|
||||
const { cards, addCard } = useCardStore();
|
||||
|
||||
const handleAddPPOO = () => {
|
||||
const existingCard = cards.filter((c) => c.i === "PPOO");
|
||||
//console.log(existingCard.length);
|
||||
//console.log(data);
|
||||
if (existingCard.length != 0) {
|
||||
toast.error(`PPOO already exists no card will be added`);
|
||||
return;
|
||||
}
|
||||
addCard({
|
||||
i: "PPOO",
|
||||
x: 0,
|
||||
y: 0,
|
||||
w: 5,
|
||||
h: 3,
|
||||
isResizable: true,
|
||||
isDraggable: true,
|
||||
});
|
||||
};
|
||||
return (
|
||||
<Dialog>
|
||||
<DialogTrigger asChild>
|
||||
<Button variant="outline">Add Cards</Button>
|
||||
</DialogTrigger>
|
||||
<DialogContent className="sm:max-w-[425px]">
|
||||
<DialogHeader>
|
||||
<DialogTitle>Cards</DialogTitle>
|
||||
<DialogDescription>
|
||||
Please add a card below.
|
||||
</DialogDescription>
|
||||
</DialogHeader>
|
||||
<Button onClick={handleAddPPOO} className="w-48">
|
||||
PPOO
|
||||
</Button>
|
||||
|
||||
<DialogFooter>
|
||||
<Button type="submit">Save changes</Button>
|
||||
</DialogFooter>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user