-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
73bdc89
commit 1ae5fb4
Showing
19 changed files
with
456 additions
and
38 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
prisma/migrations/20240605160230_added_board/migration.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
-- CreateTable | ||
CREATE TABLE "Group" ( | ||
"id" TEXT NOT NULL, | ||
"name" TEXT NOT NULL, | ||
"boardId" TEXT NOT NULL | ||
); | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "Group_id_key" ON "Group"("id"); | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "Group" ADD CONSTRAINT "Group_boardId_fkey" FOREIGN KEY ("boardId") REFERENCES "Board"("id") ON DELETE RESTRICT ON UPDATE CASCADE; |
11 changes: 11 additions & 0 deletions
11
prisma/migrations/20240606000459_added_group_card/migration.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
-- CreateTable | ||
CREATE TABLE "GroupCard" ( | ||
"id" TEXT NOT NULL, | ||
"title" VARCHAR(200) NOT NULL, | ||
"comment" TEXT NOT NULL, | ||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
"updatedAt" TIMESTAMP(3) NOT NULL | ||
); | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "GroupCard_id_key" ON "GroupCard"("id"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/* | ||
Warnings: | ||
- Added the required column `groupId` to the `GroupCard` table without a default value. This is not possible if the table is not empty. | ||
*/ | ||
-- AlterTable | ||
ALTER TABLE "GroupCard" ADD COLUMN "groupId" TEXT NOT NULL; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "GroupCard" ADD CONSTRAINT "GroupCard_groupId_fkey" FOREIGN KEY ("groupId") REFERENCES "Group"("id") ON DELETE RESTRICT ON UPDATE CASCADE; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
"use client"; | ||
import React, { useState } from "react"; | ||
import { FiEdit } from "react-icons/fi"; | ||
import Modal from "./modal"; | ||
|
||
const EditCardButton = () => { | ||
const [visible, setVisible] = useState(false); | ||
return ( | ||
<> | ||
<Modal | ||
header="Edit Card" | ||
visible={visible} | ||
onHide={() => setVisible(false)} | ||
onSave={() => console.log("s")} | ||
> | ||
This | ||
</Modal> | ||
<button className="hover:bg-gray-200 text-gray-800 font-bold py-2 px-2 rounded h-fit"> | ||
<FiEdit /> | ||
</button> | ||
</> | ||
); | ||
}; | ||
|
||
export default EditCardButton; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import React from "react"; | ||
import { InputTextarea } from "primereact/inputtextarea"; | ||
import { InputText } from "primereact/inputtext"; | ||
|
||
const CardForm = ({ | ||
formAction, | ||
formRef, | ||
}: { | ||
formAction: (payload: FormData) => void; | ||
formRef: React.MutableRefObject<HTMLFormElement | null>; | ||
}) => { | ||
return ( | ||
<form action={formAction} ref={formRef}> | ||
<div> | ||
<span className="">Title</span> | ||
<InputText className="w-full" name="title" /> | ||
</div> | ||
<div className="mt-3"> | ||
<span className="">Description</span> | ||
<InputTextarea | ||
rows={3} | ||
cols={30} | ||
className="w-full" | ||
name="description" | ||
autoResize | ||
/> | ||
</div> | ||
</form> | ||
); | ||
}; | ||
|
||
export default CardForm; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
"use client"; | ||
import React from "react"; | ||
import EditCardButton from "./edit-card-button"; | ||
|
||
type GroupCardProps = { | ||
title: string; | ||
description: string; | ||
}; | ||
|
||
const GroupCard = ({ title, description }: GroupCardProps) => { | ||
return ( | ||
<div className="w-full bg-white shadow rounded p-2"> | ||
<div className="flex justify-between p-2"> | ||
<div className="flex flex-col gap-1"> | ||
<h2 className="font-semibold text-md">{title}</h2> | ||
<div className="text-sm">{description}</div> | ||
</div> | ||
<EditCardButton /> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default GroupCard; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import React from "react"; | ||
import GroupCard from "./group-card"; | ||
import NewCardButton from "./new-card-button"; | ||
import prisma from "@/lib/db"; | ||
|
||
type GroupProps = { | ||
id: string; | ||
name: string; | ||
}; | ||
|
||
const Group = async ({ id, name }: GroupProps) => { | ||
const cards = await prisma.groupCard.findMany({ | ||
where: { | ||
groupId: id, | ||
}, | ||
}); | ||
return ( | ||
<div className="w-full"> | ||
<div className="mb-3">{name}</div> | ||
{cards.map((card) => { | ||
return ( | ||
<div key={card.id} className="mb-4"> | ||
<GroupCard title={card.title} description={card.comment} /> | ||
</div> | ||
); | ||
})} | ||
<NewCardButton groupId={id} /> | ||
</div> | ||
); | ||
}; | ||
|
||
export default Group; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import React from "react"; | ||
import { Dialog } from "primereact/dialog"; | ||
import { Button } from "primereact/button"; | ||
|
||
type ModalProps = { | ||
visible: boolean; | ||
onHide: () => void; | ||
children: React.ReactNode; | ||
onSave: () => void; | ||
header: string; | ||
}; | ||
|
||
const Modal = ({ visible, onHide, children, onSave, header }: ModalProps) => { | ||
const renderFooter = () => { | ||
return ( | ||
<div> | ||
<Button | ||
label="Cancel" | ||
icon="pi pi-times" | ||
onClick={() => onHide()} | ||
className="p-button-text" | ||
/> | ||
<Button | ||
label="Create" | ||
icon="pi pi-check" | ||
onClick={onSave} | ||
autoFocus | ||
type="submit" | ||
/> | ||
</div> | ||
); | ||
}; | ||
return ( | ||
<Dialog | ||
className="w-48" | ||
visible={visible} | ||
onHide={onHide} | ||
breakpoints={{ "960px": "75vw", "640px": "100vw" }} | ||
style={{ width: "50vw" }} | ||
header={header} | ||
footer={renderFooter()} | ||
draggable={false} | ||
> | ||
{children} | ||
</Dialog> | ||
); | ||
}; | ||
|
||
export default Modal; |
Oops, something went wrong.