diff --git a/prisma/dev.db b/prisma/dev.db index 98f3dbf..d5bdc3b 100644 Binary files a/prisma/dev.db and b/prisma/dev.db differ diff --git a/prisma/dev.db-journal b/prisma/dev.db-journal new file mode 100644 index 0000000..8c56184 Binary files /dev/null and b/prisma/dev.db-journal differ diff --git a/prisma/migrations/20240619155421_init/migration.sql b/prisma/migrations/20240619155421_init/migration.sql new file mode 100644 index 0000000..9dfdfe5 --- /dev/null +++ b/prisma/migrations/20240619155421_init/migration.sql @@ -0,0 +1,19 @@ +-- RedefineTables +PRAGMA defer_foreign_keys=ON; +PRAGMA foreign_keys=OFF; +CREATE TABLE "new_Sub" ( + "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + "storyId" INTEGER, + "pubId" INTEGER, + "submitted" TEXT NOT NULL, + "responded" TEXT, + "responseId" INTEGER, + CONSTRAINT "Sub_storyId_fkey" FOREIGN KEY ("storyId") REFERENCES "Story" ("id") ON DELETE SET NULL ON UPDATE CASCADE, + CONSTRAINT "Sub_pubId_fkey" FOREIGN KEY ("pubId") REFERENCES "Pub" ("id") ON DELETE SET NULL ON UPDATE CASCADE, + CONSTRAINT "Sub_responseId_fkey" FOREIGN KEY ("responseId") REFERENCES "Response" ("id") ON DELETE SET NULL ON UPDATE CASCADE +); +INSERT INTO "new_Sub" ("id", "pubId", "responded", "responseId", "storyId", "submitted") SELECT "id", "pubId", "responded", "responseId", "storyId", "submitted" FROM "Sub"; +DROP TABLE "Sub"; +ALTER TABLE "new_Sub" RENAME TO "Sub"; +PRAGMA foreign_keys=ON; +PRAGMA defer_foreign_keys=OFF; diff --git a/prisma/migrations/20240619155628_init/migration.sql b/prisma/migrations/20240619155628_init/migration.sql new file mode 100644 index 0000000..5351932 --- /dev/null +++ b/prisma/migrations/20240619155628_init/migration.sql @@ -0,0 +1,19 @@ +/* + Warnings: + + - You are about to drop the column `deleted` on the `Story` table. All the data in the column will be lost. + +*/ +-- RedefineTables +PRAGMA defer_foreign_keys=ON; +PRAGMA foreign_keys=OFF; +CREATE TABLE "new_Story" ( + "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + "word_count" INTEGER NOT NULL, + "title" TEXT NOT NULL +); +INSERT INTO "new_Story" ("id", "title", "word_count") SELECT "id", "title", "word_count" FROM "Story"; +DROP TABLE "Story"; +ALTER TABLE "new_Story" RENAME TO "Story"; +PRAGMA foreign_keys=ON; +PRAGMA defer_foreign_keys=OFF; diff --git a/prisma/migrations/20240619155716_init/migration.sql b/prisma/migrations/20240619155716_init/migration.sql new file mode 100644 index 0000000..269dfe7 --- /dev/null +++ b/prisma/migrations/20240619155716_init/migration.sql @@ -0,0 +1,20 @@ +/* + Warnings: + + - You are about to drop the column `deleted` on the `Pub` table. All the data in the column will be lost. + +*/ +-- RedefineTables +PRAGMA defer_foreign_keys=ON; +PRAGMA foreign_keys=OFF; +CREATE TABLE "new_Pub" ( + "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + "title" TEXT NOT NULL, + "link" TEXT NOT NULL DEFAULT '', + "query_after_days" INTEGER NOT NULL +); +INSERT INTO "new_Pub" ("id", "link", "query_after_days", "title") SELECT "id", "link", "query_after_days", "title" FROM "Pub"; +DROP TABLE "Pub"; +ALTER TABLE "new_Pub" RENAME TO "Pub"; +PRAGMA foreign_keys=ON; +PRAGMA defer_foreign_keys=OFF; diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 8a99d2a..3cbe396 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -14,7 +14,6 @@ model Story { id Int @id @default(autoincrement()) word_count Int title String - deleted Int @default(0) subs Sub[] genres Genre[] } @@ -24,7 +23,6 @@ model Pub { title String link String @default("") query_after_days Int - deleted Int @default(0) subs Sub[] genres Genre[] } @@ -44,12 +42,12 @@ model Response { model Sub { id Int @id @default(autoincrement()) - story Story @relation(fields: [storyId], references: [id]) - storyId Int - pub Pub @relation(fields: [pubId], references: [id]) - pubId Int + story Story? @relation(fields: [storyId], references: [id]) + storyId Int? + pub Pub? @relation(fields: [pubId], references: [id]) + pubId Int? submitted String - responded String - response Response @relation(fields: [responseId], references: [id]) - responseId Int + responded String? + response Response? @relation(fields: [responseId], references: [id]) + responseId Int? } diff --git a/src/app/lib/del.ts b/src/app/lib/del.ts new file mode 100644 index 0000000..37d3150 --- /dev/null +++ b/src/app/lib/del.ts @@ -0,0 +1,10 @@ +"use server" +import prisma from "./db"; + +export async function deleteStory(id) { + console.log(`id: ${id}`) + const res = await prisma.story.delete({ + where: { id } + }) + console.log(res) +} diff --git a/src/app/story/columns.tsx b/src/app/story/columns.tsx index c1a8879..8181a60 100644 --- a/src/app/story/columns.tsx +++ b/src/app/story/columns.tsx @@ -4,11 +4,14 @@ import { StoryWithGenres } from "./page" import { ArrowUpDown, MoreHorizontal } from "lucide-react" import { Button } from "@/components/ui/button" import { Badge } from "@/components/ui/badge" - +import { CircleX } from "lucide-react" +import { deleteStory } from "app/lib/del" const columnHelper = createColumnHelper() + + export const columns: ColumnDef[] = [ { accessorKey: "title", @@ -40,29 +43,22 @@ export const columns: ColumnDef[] = [ }, enableColumnFilter: false }, - // { - // accessorFn: row => { - // let unpacked = "" - // for (let i = 0; i < row.genres.length; i++) { - // unpacked = unpacked + " " + row.genres[i].name - // } - // return unpacked - // }, - // header: "Genres" - // - // - // }, columnHelper.accessor("genres", { cell: props => { const genres = props.getValue() .map(e => {e.name}) return genres } - }) - // { - // accessorKey: "deleted", - // header: "Deleted" - // }, + }), + { + id: "actions", + header: "Actions", + cell: ({ row }) => { + return + } + } ] diff --git a/src/app/story/data-table.tsx b/src/app/story/data-table.tsx index d8969d9..166606d 100644 --- a/src/app/story/data-table.tsx +++ b/src/app/story/data-table.tsx @@ -31,6 +31,7 @@ import { TableHeader, TableRow, } from "@/components/ui/table" +import { EyeIcon } from "lucide-react" interface DataTableProps { columns: ColumnDef[] @@ -105,7 +106,7 @@ export function DataTable({ diff --git a/src/app/tailwind.css b/src/app/tailwind.css index 4bbecb0..8b3d7ec 100644 --- a/src/app/tailwind.css +++ b/src/app/tailwind.css @@ -907,6 +907,10 @@ body { gap: 0.25rem; } +.gap-2 { + gap: 0.5rem; +} + .space-x-1 > :not([hidden]) ~ :not([hidden]) { --tw-space-x-reverse: 0; margin-right: calc(0.25rem * var(--tw-space-x-reverse)); @@ -967,6 +971,18 @@ body { margin-bottom: calc(2rem * var(--tw-space-y-reverse)); } +.justify-self-start { + justify-self: start; +} + +.justify-self-end { + justify-self: end; +} + +.justify-self-center { + justify-self: center; +} + .overflow-auto { overflow: auto; } @@ -987,6 +1003,10 @@ body { border-radius: calc(var(--radius) - 4px); } +.rounded-full { + border-radius: 9999px; +} + .border { border-width: 1px; } @@ -1011,6 +1031,10 @@ body { border-color: hsl(var(--primary)); } +.border-transparent { + border-color: transparent; +} + .bg-accent { background-color: hsl(var(--accent)); } @@ -1121,6 +1145,21 @@ body { padding-bottom: 1rem; } +.px-2\.5 { + padding-left: 0.625rem; + padding-right: 0.625rem; +} + +.py-0 { + padding-top: 0px; + padding-bottom: 0px; +} + +.py-0\.5 { + padding-top: 0.125rem; + padding-bottom: 0.125rem; +} + .pl-3 { padding-left: 0.75rem; } @@ -1400,6 +1439,14 @@ body { background-color: hsl(var(--secondary) / 0.8); } +.hover\:bg-destructive\/80:hover { + background-color: hsl(var(--destructive) / 0.8); +} + +.hover\:bg-primary\/80:hover { + background-color: hsl(var(--primary) / 0.8); +} + .hover\:text-accent-foreground:hover { color: hsl(var(--accent-foreground)); } diff --git a/src/app/ui/forms/genresTrigger.tsx b/src/app/ui/forms/genresTrigger.tsx index 3e457be..e54e0c7 100644 --- a/src/app/ui/forms/genresTrigger.tsx +++ b/src/app/ui/forms/genresTrigger.tsx @@ -24,4 +24,4 @@ export default function GenresTrigger({ value, genres }) { ) -} +}