diff --git a/src/lib/data/list-variants.ts b/src/lib/data/list-variants.ts new file mode 100644 index 0000000..2596b2a --- /dev/null +++ b/src/lib/data/list-variants.ts @@ -0,0 +1,10 @@ +export const VARIANT = { + standard: "Standard", + checklist: "Checklist", + project: "Project", +} as const; + +export const VARIANTS = Object.values(VARIANT) as unknown as readonly [ + string, + ...string[], +]; diff --git a/src/lib/data/task-labels.ts b/src/lib/data/task-labels.ts new file mode 100644 index 0000000..229cd53 --- /dev/null +++ b/src/lib/data/task-labels.ts @@ -0,0 +1,13 @@ +export const LABEL = { + feature: "Feature", + bug: "Bug", + docs: "Docs", + chore: "Chore", + refactor: "Refactor", + build: "Build", +} as const; + +export const LABELS = Object.values(LABEL) as unknown as readonly [ + string, + ...string[], +]; diff --git a/src/lib/data/task-priority.ts b/src/lib/data/task-priority.ts new file mode 100644 index 0000000..b2631f3 --- /dev/null +++ b/src/lib/data/task-priority.ts @@ -0,0 +1,10 @@ +export const PRIORITY = { + high: "High", + medium: "Medium", + low: "Low", +} as const; + +export const PRIORITIES = Object.values(PRIORITY) as unknown as readonly [ + string, + ...string[], +]; diff --git a/src/lib/data/task-status.ts b/src/lib/data/task-status.ts new file mode 100644 index 0000000..082371b --- /dev/null +++ b/src/lib/data/task-status.ts @@ -0,0 +1,12 @@ +export const STATUS = { + backlog: "Backlog", + todo: "Todo", + inProgress: "In Progress", + done: "Done", + canceled: "Canceled", +} as const; + +export const STATUSES = Object.values(STATUS) as unknown as readonly [ + string, + ...string[], +]; diff --git a/src/lib/schemas/list-creation-form.ts b/src/lib/schemas/list-creation-form.ts new file mode 100644 index 0000000..ba44194 --- /dev/null +++ b/src/lib/schemas/list-creation-form.ts @@ -0,0 +1,13 @@ +import { z } from "zod"; +import { LABELS } from "~/lib/data/task-labels"; +import { VARIANTS } from "~/lib/data/list-variants"; + +export const listNameSchema = z.string().max(128); + +export const listCreationFormSchema = z.object({ + name: listNameSchema, // Text + variant: z.union([z.enum(VARIANTS).optional(), z.literal("")]), // Radio group + labels: z.array(z.enum(LABELS)), // Checkbox group + id: z.boolean(), // Checkbox + idPrefix: z.string().max(8), // Text +}); diff --git a/src/lib/schemas/task-creation-form.ts b/src/lib/schemas/task-creation-form.ts new file mode 100644 index 0000000..7400fbb --- /dev/null +++ b/src/lib/schemas/task-creation-form.ts @@ -0,0 +1,3 @@ +import { z } from "zod"; + +export const taskCreationFormSchema = z.object({}); diff --git a/src/server/api/root.ts b/src/server/api/root.ts index 51e2498..8e7029b 100644 --- a/src/server/api/root.ts +++ b/src/server/api/root.ts @@ -1,4 +1,5 @@ -// import { postRouter } from "~/server/api/routers/post"; +import { listRouter } from "~/server/api/routers/lists"; +import { tasksRouter } from "~/server/api/routers/tasks"; import { createCallerFactory, createTRPCRouter } from "~/server/api/trpc"; /** @@ -7,7 +8,8 @@ import { createCallerFactory, createTRPCRouter } from "~/server/api/trpc"; * All routers added in /api/routers should be manually added here. */ export const appRouter = createTRPCRouter({ - // post: postRouter, + list: listRouter, + tasks: tasksRouter, }); // export type definition of API diff --git a/src/server/api/routers/lists.ts b/src/server/api/routers/lists.ts new file mode 100644 index 0000000..10cc8b7 --- /dev/null +++ b/src/server/api/routers/lists.ts @@ -0,0 +1,43 @@ +import { z } from "zod"; +import { + listCreationFormSchema, + listNameSchema, +} from "~/lib/schemas/list-creation-form"; + +import { createTRPCRouter, protectedProcedure } from "~/server/api/trpc"; + +export const listRouter = createTRPCRouter({ + create: protectedProcedure + .input(listCreationFormSchema) + .mutation(async ({ ctx, input }) => { + return []; + }), + getAll: protectedProcedure.query(async ({ ctx }) => { + return [ + { id: 0, name: "Groceries" }, + { id: 1, name: "Christmas" }, + { id: 2, name: "Salt Seeker" }, + { id: 3, name: "Maize Walker" }, + { id: 4, name: "Sympathy for the Machine" }, + { + id: 4, + name: "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor elit incididunt ut labore et dolore magna aliqua.", + }, + ]; + }), + get: protectedProcedure + .input(z.object({ listId: z.number() })) + .query(async ({ ctx, input }) => { + return { name: "Groceries", data: [] }; + }), + update: protectedProcedure + .input(z.object({ listId: z.number(), name: listNameSchema })) + .mutation(async ({ ctx, input }) => { + return []; + }), + delete: protectedProcedure + .input(z.object({ listId: z.number() })) + .mutation(async ({ ctx, input }) => { + return []; + }), +}); diff --git a/src/server/api/routers/post.ts b/src/server/api/routers/post.ts deleted file mode 100644 index 7a296c9..0000000 --- a/src/server/api/routers/post.ts +++ /dev/null @@ -1,39 +0,0 @@ -// import { z } from "zod"; - -// import { -// createTRPCRouter, -// protectedProcedure, -// publicProcedure, -// } from "~/server/api/trpc"; -// import { posts } from "~/server/db/schema"; - -// export const postRouter = createTRPCRouter({ -// hello: publicProcedure -// .input(z.object({ text: z.string() })) -// .query(({ input }) => { -// return { -// greeting: `Hello ${input.text}`, -// }; -// }), - -// create: protectedProcedure -// .input(z.object({ name: z.string().min(1) })) -// .mutation(async ({ ctx, input }) => { -// await ctx.db.insert(posts).values({ -// name: input.name, -// createdById: ctx.session.user.id, -// }); -// }), - -// getLatest: protectedProcedure.query(async ({ ctx }) => { -// const post = await ctx.db.query.posts.findFirst({ -// orderBy: (posts, { desc }) => [desc(posts.createdAt)], -// }); - -// return post ?? null; -// }), - -// getSecretMessage: protectedProcedure.query(() => { -// return "you can now see this secret message!"; -// }), -// }); diff --git a/src/server/api/routers/tasks.ts b/src/server/api/routers/tasks.ts new file mode 100644 index 0000000..205f6b7 --- /dev/null +++ b/src/server/api/routers/tasks.ts @@ -0,0 +1,12 @@ +import { z } from "zod"; +import { taskCreationFormSchema } from "~/lib/schemas/task-creation-form"; + +import { createTRPCRouter, protectedProcedure } from "~/server/api/trpc"; + +export const tasksRouter = createTRPCRouter({ + create: protectedProcedure + .input(taskCreationFormSchema) + .mutation(async ({ ctx, input }) => { + // + }), +});