diff --git a/bun.lockb b/bun.lockb index f1103544..5c4e77ed 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/package.json b/package.json index a736408b..1da6ea12 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,7 @@ "@trpc/server": "^11.0.0-rc.566", "@vercel/postgres": "^0.7.2", "drizzle-orm": "^0.28.5", - "next": "^14.1.3", + "next": "^15.0.2", "nextjs-cors": "^2.2.0", "postgres": "^3.4.4", "react": "18.2.0", diff --git a/src/pages/api/v1/[trpc].ts b/src/pages/api/v1/[...trpc].ts similarity index 100% rename from src/pages/api/v1/[trpc].ts rename to src/pages/api/v1/[...trpc].ts diff --git a/src/providers/board.tsx b/src/providers/board.tsx index 25d05ef5..7cc7af4a 100644 --- a/src/providers/board.tsx +++ b/src/providers/board.tsx @@ -164,23 +164,25 @@ export const BoardProvider: React.FC<{ children: ReactNode }> = ({ }; const updateList = ({ - boardId, - listId, + listPublicId, currentIndex, newIndex, }: ReorderListInput) => { updateListMutation.mutate({ - boardId, - listId, + listPublicId, currentIndex, newIndex, }); }; - const updateCard = ({ cardId, newListId, newIndex }: ReorderCardInput) => { + const updateCard = ({ + cardPublicId, + newListPublicId, + newIndex, + }: ReorderCardInput) => { updateCardMutation.mutate({ - cardId, - newListId, + cardPublicId, + newListPublicId, newIndex, }); }; diff --git a/src/server/api/routers/auth.ts b/src/server/api/routers/auth.ts index 89a74615..d4e0d7a8 100644 --- a/src/server/api/routers/auth.ts +++ b/src/server/api/routers/auth.ts @@ -16,8 +16,12 @@ export const authRouter = createTRPCRouter({ .meta({ openapi: { method: "GET", - path: "/auth/user", + path: "/users/me", summary: "Get user", + description: + "Retrieves the currently authenticated user's profile information", + tags: ["Users"], + protect: true, }, }) .input(z.void()) @@ -52,8 +56,10 @@ export const authRouter = createTRPCRouter({ .meta({ openapi: { method: "POST", - path: "/auth/email", + path: "/auth/login/email", summary: "Login with email", + description: "Sends a login URL to the provided email address", + tags: ["Auth"], }, }) .input(z.object({ email: z.string() })) @@ -78,8 +84,11 @@ export const authRouter = createTRPCRouter({ .meta({ openapi: { method: "POST", - path: "/auth/oauth", + path: "/auth/login/oauth", summary: "Login with OAuth", + description: + "Initiates the login process for a user with the given OAuth provider", + tags: ["Auth"], }, }) .input(z.object({ provider: z.string() })) diff --git a/src/server/api/routers/board.ts b/src/server/api/routers/board.ts index e9561f0b..99d5539c 100644 --- a/src/server/api/routers/board.ts +++ b/src/server/api/routers/board.ts @@ -13,8 +13,11 @@ export const boardRouter = createTRPCRouter({ .meta({ openapi: { method: "GET", - path: "/board/{workspacePublicId}", + path: "/workspaces/{workspacePublicId}/boards", summary: "Get all boards", + description: "Retrieves all boards for a given workspace", + tags: ["Boards"], + protect: true, }, }) .input(z.object({ workspacePublicId: z.string().min(12) })) @@ -41,15 +44,18 @@ export const boardRouter = createTRPCRouter({ .meta({ openapi: { method: "GET", - path: "/board/{boardPublicId}", + path: "/boards/{boardPublicId}", summary: "Get board by public ID", + description: "Retrieves a board by its public ID", + tags: ["Boards"], + protect: true, }, }) .input( z.object({ boardPublicId: z.string().min(12), - members: z.array(z.string().min(12)), - labels: z.array(z.string().min(12)), + members: z.array(z.string().min(12)).optional(), + labels: z.array(z.string().min(12)).optional(), }), ) .output(z.custom>>()) @@ -58,8 +64,8 @@ export const boardRouter = createTRPCRouter({ ctx.db, input.boardPublicId, { - members: input.members, - labels: input.labels, + members: input.members ?? [], + labels: input.labels ?? [], }, ); @@ -69,8 +75,11 @@ export const boardRouter = createTRPCRouter({ .meta({ openapi: { method: "POST", - path: "/board", + path: "/workspaces/{workspacePublicId}/boards", summary: "Create board", + description: "Creates a new board for a given workspace", + tags: ["Boards"], + protect: true, }, }) .input( @@ -118,8 +127,11 @@ export const boardRouter = createTRPCRouter({ .meta({ openapi: { method: "PUT", - path: "/board/{boardPublicId}", + path: "/boards/{boardPublicId}", summary: "Update board", + description: "Updates a board by its public ID", + tags: ["Boards"], + protect: true, }, }) .input( @@ -147,8 +159,11 @@ export const boardRouter = createTRPCRouter({ .meta({ openapi: { method: "DELETE", - path: "/board/{boardPublicId}", + path: "/boards/{boardPublicId}", summary: "Delete board", + description: "Deletes a board by its public ID", + tags: ["Boards"], + protect: true, }, }) .input( diff --git a/src/server/api/routers/card.ts b/src/server/api/routers/card.ts index fb4ae389..efd6546e 100644 --- a/src/server/api/routers/card.ts +++ b/src/server/api/routers/card.ts @@ -14,7 +14,10 @@ export const cardRouter = createTRPCRouter({ openapi: { summary: "Create a card", method: "POST", - path: "/", + path: "/cards", + description: "Creates a new card for a given list", + tags: ["Cards"], + protect: true, }, }) .input( @@ -128,8 +131,11 @@ export const cardRouter = createTRPCRouter({ .meta({ openapi: { summary: "Add or remove a label from a card", - method: "POST", - path: "/{cardPublicId}/label/{labelPublicId}", + method: "PUT", + path: "/cards/{cardPublicId}/labels/{labelPublicId}", + description: "Adds or removes a label from a card", + tags: ["Cards"], + protect: true, }, }) .input( @@ -184,8 +190,10 @@ export const cardRouter = createTRPCRouter({ .meta({ openapi: { summary: "Add or remove a member from a card", - method: "POST", - path: "/{cardPublicId}/member/{workspaceMemberPublicId}", + method: "PUT", + path: "/cards/{cardPublicId}/members/{workspaceMemberPublicId}", + description: "Adds or removes a member from a card", + tags: ["Cards"], }, }) .input( @@ -242,12 +250,15 @@ export const cardRouter = createTRPCRouter({ byId: protectedProcedure .meta({ openapi: { - summary: "Get a card by ID", + summary: "Get a card by public ID", method: "GET", - path: "/{id}", + path: "/cards/{cardPublicId}", + description: "Retrieves a card by its public ID", + tags: ["Cards"], + protect: true, }, }) - .input(z.object({ id: z.string().min(12) })) + .input(z.object({ cardPublicId: z.string().min(12) })) .output( z.custom< Awaited> @@ -256,12 +267,12 @@ export const cardRouter = createTRPCRouter({ .query(async ({ ctx, input }) => { const result = await cardRepo.getWithListAndMembersByPublicId( ctx.db, - input.id, + input.cardPublicId, ); if (!result) throw new TRPCError({ - message: `Card with ID ${input.id} not found`, + message: `Card with public ID ${input.cardPublicId} not found`, code: "NOT_FOUND", }); @@ -272,12 +283,15 @@ export const cardRouter = createTRPCRouter({ openapi: { summary: "Update a card", method: "PUT", - path: "/{cardId}", + path: "/cards/{cardPublicId}", + description: "Updates a card by its public ID", + tags: ["Cards"], + protect: true, }, }) .input( z.object({ - cardId: z.string().min(12), + cardPublicId: z.string().min(12), title: z.string().min(1), description: z.string(), }), @@ -295,7 +309,7 @@ export const cardRouter = createTRPCRouter({ const result = await cardRepo.update( ctx.db, { title: input.title, description: input.description }, - { cardPublicId: input.cardId }, + { cardPublicId: input.cardPublicId }, ); if (!result) @@ -311,7 +325,10 @@ export const cardRouter = createTRPCRouter({ openapi: { summary: "Delete a card", method: "DELETE", - path: "/{cardPublicId}", + path: "/cards/{cardPublicId}", + description: "Deletes a card by its public ID", + tags: ["Cards"], + protect: true, }, }) .input( @@ -359,14 +376,17 @@ export const cardRouter = createTRPCRouter({ .meta({ openapi: { summary: "Reorder a card", - method: "POST", - path: "/{cardId}/reorder", + method: "PUT", + path: "/cards/{cardPublicId}/reorder", + description: "Reorders the position of a card in a given list", + tags: ["Cards"], + protect: true, }, }) .input( z.object({ - cardId: z.string().min(12), - newListId: z.string().min(12), + cardPublicId: z.string().min(12), + newListPublicId: z.string().min(12), newIndex: z.number().optional(), }), ) @@ -382,12 +402,12 @@ export const cardRouter = createTRPCRouter({ const card = await cardRepo.getCardWithListByPublicId( ctx.db, - input.cardId, + input.cardPublicId, ); if (!card?.list) throw new TRPCError({ - message: `Card with public ID ${input.cardId} not found`, + message: `Card with public ID ${input.cardPublicId} not found`, code: "NOT_FOUND", }); @@ -398,12 +418,12 @@ export const cardRouter = createTRPCRouter({ const newList = await listRepo.getWithCardsByPublicId( ctx.db, - input.newListId, + input.newListPublicId, ); if (!newList) throw new TRPCError({ - message: `List with public ID ${input.newListId} not found`, + message: `List with public ID ${input.newListPublicId} not found`, code: "NOT_FOUND", }); diff --git a/src/server/api/routers/import.ts b/src/server/api/routers/import.ts index f06e4208..f839197c 100644 --- a/src/server/api/routers/import.ts +++ b/src/server/api/routers/import.ts @@ -41,7 +41,10 @@ export const importRouter = createTRPCRouter({ openapi: { summary: "Get boards from Trello", method: "GET", - path: "/boards", + path: "/imports/trello/boards", + description: "Retrieves all boards from Trello", + tags: ["Imports"], + protect: true, }, }) .input( @@ -91,7 +94,10 @@ export const importRouter = createTRPCRouter({ openapi: { summary: "Import boards from Trello", method: "POST", - path: "/import", + path: "/imports/trello/import", + description: "Imports boards from Trello", + tags: ["Imports"], + protect: true, }, }) .input( diff --git a/src/server/api/routers/label.ts b/src/server/api/routers/label.ts index 353c59ed..9e9c3537 100644 --- a/src/server/api/routers/label.ts +++ b/src/server/api/routers/label.ts @@ -12,17 +12,20 @@ export const labelRouter = createTRPCRouter({ openapi: { summary: "Get a label by public ID", method: "GET", - path: "/{publicId}", + path: "/labels/{labelPublicId}", + description: "Retrieves a label by its public ID", + tags: ["Labels"], + protect: true, }, }) - .input(z.object({ publicId: z.string().min(12) })) + .input(z.object({ labelPublicId: z.string().min(12) })) .output(z.custom>>()) .query(async ({ ctx, input }) => { - const label = await labelRepo.getByPublicId(ctx.db, input.publicId); + const label = await labelRepo.getByPublicId(ctx.db, input.labelPublicId); if (!label) throw new TRPCError({ - message: `Label with public ID ${input.publicId} not found`, + message: `Label with public ID ${input.labelPublicId} not found`, code: "NOT_FOUND", }); @@ -33,7 +36,10 @@ export const labelRouter = createTRPCRouter({ openapi: { summary: "Create a label", method: "POST", - path: "/create", + path: "/labels", + description: "Creates a new label", + tags: ["Labels"], + protect: true, }, }) .input( @@ -84,12 +90,15 @@ export const labelRouter = createTRPCRouter({ openapi: { summary: "Update a label", method: "PUT", - path: "/{publicId}", + path: "/labels/{labelPublicId}", + description: "Updates a label by its public ID", + tags: ["Labels"], + protect: true, }, }) .input( z.object({ - publicId: z.string().min(12), + labelPublicId: z.string().min(12), name: z.string().min(1).max(36), colourCode: z.string().length(7), }), @@ -105,17 +114,20 @@ export const labelRouter = createTRPCRouter({ openapi: { summary: "Delete a label", method: "DELETE", - path: "/{publicId}", + path: "/labels/{labelPublicId}", + description: "Deletes a label by its public ID", + tags: ["Labels"], + protect: true, }, }) - .input(z.object({ publicId: z.string().min(12) })) + .input(z.object({ labelPublicId: z.string().min(12) })) .output(z.object({ success: z.boolean() })) .mutation(async ({ ctx, input }) => { - const label = await labelRepo.getByPublicId(ctx.db, input.publicId); + const label = await labelRepo.getByPublicId(ctx.db, input.labelPublicId); if (!label) throw new TRPCError({ - message: `Label with public ID ${input.publicId} not found`, + message: `Label with public ID ${input.labelPublicId} not found`, code: "NOT_FOUND", }); diff --git a/src/server/api/routers/list.ts b/src/server/api/routers/list.ts index 87516fdc..b3ae3db3 100644 --- a/src/server/api/routers/list.ts +++ b/src/server/api/routers/list.ts @@ -13,7 +13,10 @@ export const listRouter = createTRPCRouter({ openapi: { summary: "Create a list", method: "POST", - path: "/list/create", + path: "/lists", + description: "Creates a new list for a given board", + tags: ["Lists"], + protect: true, }, }) .input( @@ -65,24 +68,26 @@ export const listRouter = createTRPCRouter({ openapi: { summary: "Reorder a list", method: "POST", - path: "/{listId}/reorder", + path: "/lists/{listPublicId}/reorder", + description: "Reorders the position of a list", + tags: ["Lists"], + protect: true, }, }) .input( z.object({ - boardId: z.string().min(12), - listId: z.string().min(12), + listPublicId: z.string().min(12), currentIndex: z.number(), newIndex: z.number(), }), ) .output(z.custom>>()) .mutation(async ({ ctx, input }) => { - const list = await listRepo.getByPublicId(ctx.db, input.listId); + const list = await listRepo.getByPublicId(ctx.db, input.listPublicId); if (!list) throw new TRPCError({ - message: `List with public ID ${input.listId} not found`, + message: `List with public ID ${input.listPublicId} not found`, code: "NOT_FOUND", }); @@ -106,7 +111,10 @@ export const listRouter = createTRPCRouter({ openapi: { summary: "Delete a list", method: "DELETE", - path: "/{listPublicId}", + path: "/lists/{listPublicId}", + description: "Deletes a list by its public ID", + tags: ["Lists"], + protect: true, }, }) .input( @@ -158,7 +166,10 @@ export const listRouter = createTRPCRouter({ openapi: { summary: "Update a list", method: "PUT", - path: "/list/{listPublicId}", + path: "/lists/{listPublicId}", + description: "Updates a list by its public ID", + tags: ["Lists"], + protect: true, }, }) .input( diff --git a/src/server/api/routers/member.ts b/src/server/api/routers/member.ts index b286f03f..171ffe8b 100644 --- a/src/server/api/routers/member.ts +++ b/src/server/api/routers/member.ts @@ -15,7 +15,10 @@ export const memberRouter = createTRPCRouter({ openapi: { summary: "Invite a member to a workspace", method: "POST", - path: "/invite", + path: "/workspaces/{workspacePublicId}/members/invite", + description: "Invites a member to a workspace", + tags: ["Members"], + protect: true, }, }) .input( @@ -144,11 +147,15 @@ export const memberRouter = createTRPCRouter({ openapi: { summary: "Delete a member from a workspace", method: "DELETE", - path: "/{memberPublicId}", + path: "/workspaces/{workspacePublicId}/members/{memberPublicId}", + description: "Deletes a member from a workspace", + tags: ["Members"], + protect: true, }, }) .input( z.object({ + workspacePublicId: z.string().min(12), memberPublicId: z.string().min(12), }), ) @@ -162,6 +169,17 @@ export const memberRouter = createTRPCRouter({ code: "UNAUTHORIZED", }); + const workspace = await workspaceRepo.getByPublicId( + ctx.db, + input.workspacePublicId, + ); + + if (!workspace) + throw new TRPCError({ + message: `Workspace with public ID ${input.workspacePublicId} not found`, + code: "NOT_FOUND", + }); + const member = await memberRepo.getByPublicId( ctx.db, input.memberPublicId, diff --git a/src/server/api/routers/workspace.ts b/src/server/api/routers/workspace.ts index c8ae67f8..75a91078 100644 --- a/src/server/api/routers/workspace.ts +++ b/src/server/api/routers/workspace.ts @@ -10,7 +10,10 @@ export const workspaceRouter = createTRPCRouter({ openapi: { summary: "Get all workspaces", method: "GET", - path: "/", + path: "/workspaces", + description: "Retrieves all workspaces for the authenticated user", + tags: ["Workspaces"], + protect: true, }, }) .input(z.void()) @@ -35,10 +38,13 @@ export const workspaceRouter = createTRPCRouter({ openapi: { summary: "Get a workspace by public ID", method: "GET", - path: "/workspace/{publicId}", + path: "/workspaces/{workspacePublicId}", + description: "Retrieves a workspace by its public ID", + tags: ["Workspaces"], + protect: true, }, }) - .input(z.object({ publicId: z.string().min(12) })) + .input(z.object({ workspacePublicId: z.string().min(12) })) .output( z.custom< Awaited> @@ -47,7 +53,7 @@ export const workspaceRouter = createTRPCRouter({ .query(async ({ ctx, input }) => { const result = await workspaceRepo.getByPublicIdWithMembers( ctx.db, - input.publicId, + input.workspacePublicId, ); if (!result) @@ -63,7 +69,10 @@ export const workspaceRouter = createTRPCRouter({ openapi: { summary: "Create a workspace", method: "POST", - path: "/workspace/create", + path: "/workspaces", + description: "Creates a new workspace", + tags: ["Workspaces"], + protect: true, }, }) .input( @@ -100,7 +109,10 @@ export const workspaceRouter = createTRPCRouter({ openapi: { summary: "Update a workspace", method: "PUT", - path: "/workspace/{workspacePublicId}", + path: "/workspaces/{workspacePublicId}", + description: "Updates a workspace by its public ID", + tags: ["Workspaces"], + protect: true, }, }) .input( @@ -124,7 +136,10 @@ export const workspaceRouter = createTRPCRouter({ openapi: { summary: "Delete a workspace", method: "DELETE", - path: "/workspace/{workspacePublicId}", + path: "/workspaces/{workspacePublicId}", + description: "Deletes a workspace by its public ID", + tags: ["Workspaces"], + protect: true, }, }) .input(z.object({ workspacePublicId: z.string().min(12) })) diff --git a/src/server/api/trpc.ts b/src/server/api/trpc.ts index 4d8a59bf..310defc5 100644 --- a/src/server/api/trpc.ts +++ b/src/server/api/trpc.ts @@ -79,16 +79,22 @@ export const createTRPCContext = async ({ return createInnerTRPCContext({ db, adminDb, user }); }; -export const createRESTContext = async ({ - req, - res, -}: CreateNextContextOptions) => { - const db = createNextApiClient(req, res); +export const createRESTContext = async ({ req }: CreateNextContextOptions) => { + const db = createNextApiClient(req); const adminDb = createTRPCAdminClient(); + const authHeader = req.headers.authorization; + const accessToken = authHeader?.startsWith("Bearer ") + ? authHeader.substring(7) + : null; + + if (!accessToken) { + return createInnerTRPCContext({ db, adminDb, user: null }); + } + const { data: { user }, - } = await db.auth.getUser(); + } = await db.auth.getUser(accessToken); return createInnerTRPCContext({ db, adminDb, user }); }; diff --git a/src/server/db/repository/board.repo.ts b/src/server/db/repository/board.repo.ts index 0a93eda5..b15c7c0d 100644 --- a/src/server/db/repository/board.repo.ts +++ b/src/server/db/repository/board.repo.ts @@ -84,14 +84,12 @@ export const getByPublicId = async ( query = query.in("lists.cards.members.publicId", filters.members); } - const { data, error } = await query + const { data } = await query .order("index", { foreignTable: "list", ascending: true }) .order("index", { foreignTable: "list.card", ascending: true }) .limit(1) .single(); - console.log(error); - return data; }; diff --git a/src/server/db/repository/label.repo.ts b/src/server/db/repository/label.repo.ts index b0d322f8..320bd7a6 100644 --- a/src/server/db/repository/label.repo.ts +++ b/src/server/db/repository/label.repo.ts @@ -63,7 +63,7 @@ export const getByPublicId = async ( export const update = async ( db: SupabaseClient, labelInput: { - publicId: string; + labelPublicId: string; name: string; colourCode: string; }, @@ -74,7 +74,7 @@ export const update = async ( name: labelInput.name, colourCode: labelInput.colourCode, }) - .eq("publicId", labelInput.publicId); + .eq("publicId", labelInput.labelPublicId); return data; }; diff --git a/src/utils/supabase/api.ts b/src/utils/supabase/api.ts index 0f8f2715..3f7cf8a3 100644 --- a/src/utils/supabase/api.ts +++ b/src/utils/supabase/api.ts @@ -6,7 +6,7 @@ import { import { RequestCookies } from "@edge-runtime/cookies"; import { type Database } from "~/types/database.types"; -import { type NextApiRequest, type NextApiResponse } from "next"; +import { type NextApiRequest } from "next"; import { type NextRequest, type NextResponse } from "next/server"; export function createNextClient(req: NextRequest, res: NextResponse) { @@ -31,26 +31,25 @@ export function createNextClient(req: NextRequest, res: NextResponse) { return supabase; } -export function createNextApiClient( - _req: NextApiRequest, - _res: NextApiResponse, -) { +export function createNextApiClient(req: NextApiRequest) { + const authHeader = req.headers.authorization; + const accessToken = authHeader?.startsWith("Bearer ") + ? authHeader.substring(7) + : null; + const supabase = createServerClient( process.env.NEXT_PUBLIC_SUPABASE_URL!, process.env.SUPABASE_SERVICE_API_KEY!, { - cookies: { - get(_name: string) { - // return req.cookies.get(name)?.value; - return ""; - }, - set(_name: string, _value: string, _options: CookieOptions) { - // res.headers.append("Set-Cookie", serialize(name, value, options)); - }, - remove(_name: string, _options: CookieOptions) { - // res.headers.append("Set-Cookie", serialize(name, "", options)); - }, + auth: { + persistSession: false, + ...(accessToken && { + autoRefreshToken: false, + detectSessionInUrl: false, + access_token: accessToken, + }), }, + cookies: {}, }, ); diff --git a/src/views/board/index.tsx b/src/views/board/index.tsx index 634f503c..e59fb2ab 100644 --- a/src/views/board/index.tsx +++ b/src/views/board/index.tsx @@ -104,8 +104,7 @@ export default function BoardPage() { } updateList({ - boardId, - listId: draggableId, + listPublicId: draggableId, currentIndex: source.index, newIndex: destination.index, }); @@ -128,8 +127,8 @@ export default function BoardPage() { } updateCard({ - cardId: draggableId, - newListId: destination.droppableId, + cardPublicId: draggableId, + newListPublicId: destination.droppableId, newIndex: destination.index, }); } diff --git a/src/views/card/components/DeleteLabelConfirmation.tsx b/src/views/card/components/DeleteLabelConfirmation.tsx index 5f2d39ec..a6ba53bd 100644 --- a/src/views/card/components/DeleteLabelConfirmation.tsx +++ b/src/views/card/components/DeleteLabelConfirmation.tsx @@ -15,7 +15,7 @@ export function DeleteLabelConfirmation({ const { closeModal } = useModal(); const { showPopup } = usePopup(); - const refetchCard = () => utils.card.byId.refetch({ id: cardPublicId }); + const refetchCard = () => utils.card.byId.refetch({ cardPublicId }); const deleteLabelMutation = api.label.delete.useMutation({ onSuccess: () => refetchCard(), @@ -29,7 +29,7 @@ export function DeleteLabelConfirmation({ const handleDeleteLabel = () => { closeModal(); deleteLabelMutation.mutate({ - publicId: labelPublicId, + labelPublicId, }); }; diff --git a/src/views/card/components/LabelForm.tsx b/src/views/card/components/LabelForm.tsx index a1335067..90270ea4 100644 --- a/src/views/card/components/LabelForm.tsx +++ b/src/views/card/components/LabelForm.tsx @@ -44,7 +44,7 @@ export function LabelForm({ const label = api.label.byPublicId.useQuery( { - publicId: entityId, + labelPublicId: entityId, }, { enabled: isEdit && !!entityId, @@ -62,7 +62,7 @@ export function LabelForm({ }, }); - const refetchCard = () => utils.card.byId.refetch({ id: cardPublicId }); + const refetchCard = () => utils.card.byId.refetch({ cardPublicId }); const isCreateAnotherEnabled = watch("isCreateAnotherEnabled"); @@ -101,7 +101,7 @@ export function LabelForm({ if (isEdit) { updateLabel.mutate({ - publicId: label.data?.publicId ?? "", + labelPublicId: label.data?.publicId ?? "", name: values.name, colourCode: values.colour.code, }); diff --git a/src/views/card/components/LabelSelector.tsx b/src/views/card/components/LabelSelector.tsx index 3a8b6707..8861cae9 100644 --- a/src/views/card/components/LabelSelector.tsx +++ b/src/views/card/components/LabelSelector.tsx @@ -27,7 +27,7 @@ export default function LabelSelector({ const { openModal } = useModal(); const utils = api.useUtils(); - const refetchCard = () => utils.card.byId.refetch({ id: cardPublicId }); + const refetchCard = () => utils.card.byId.refetch({ cardPublicId }); const addOrRemoveLabel = api.card.addOrRemoveLabel.useMutation({ onSuccess: async () => { diff --git a/src/views/card/components/ListSelector.tsx b/src/views/card/components/ListSelector.tsx index 83eba488..b9e7fe0c 100644 --- a/src/views/card/components/ListSelector.tsx +++ b/src/views/card/components/ListSelector.tsx @@ -20,7 +20,7 @@ export default function ListSelector({ }: ListSelectorProps) { const utils = api.useUtils(); - const refetchCard = () => utils.card.byId.refetch({ id: cardPublicId }); + const refetchCard = () => utils.card.byId.refetch({ cardPublicId }); const updateCardList = api.card.reorder.useMutation({ onSuccess: async () => { @@ -78,8 +78,8 @@ export default function ListSelector({ setValue(list.publicId, newValue); updateCardList.mutate({ - cardId: cardPublicId, - newListId: list.publicId, + cardPublicId, + newListPublicId: list.publicId, }); handleSubmit(onSubmit); diff --git a/src/views/card/components/MemberSelector.tsx b/src/views/card/components/MemberSelector.tsx index 966304ea..bc353334 100644 --- a/src/views/card/components/MemberSelector.tsx +++ b/src/views/card/components/MemberSelector.tsx @@ -24,7 +24,7 @@ export default function MemberSelector({ }: MemberSelectorProps) { const utils = api.useUtils(); - const refetchCard = () => utils.card.byId.refetch({ id: cardPublicId }); + const refetchCard = () => utils.card.byId.refetch({ cardPublicId }); const addOrRemoveMember = api.card.addOrRemoveMember.useMutation({ onSuccess: async () => { diff --git a/src/views/card/index.tsx b/src/views/card/index.tsx index b88bcc75..3de0495e 100644 --- a/src/views/card/index.tsx +++ b/src/views/card/index.tsx @@ -32,7 +32,9 @@ export default function CardPage() { ? params.cardId[0] : params?.cardId; - const { data, isLoading } = api.card.byId.useQuery({ id: cardId ?? "" }); + const { data, isLoading } = api.card.byId.useQuery({ + cardPublicId: cardId ?? "", + }); const board = data?.list?.board; const boardId = board?.publicId; @@ -85,7 +87,7 @@ export default function CardPage() { const onSubmit = (values: FormValues) => { updateCard.mutate({ - cardId: values.cardId, + cardPublicId: values.cardId, title: values.title, description: values.description, }); diff --git a/src/views/members/components/DeleteMemberConfirmation.tsx b/src/views/members/components/DeleteMemberConfirmation.tsx index f1cb7d57..b4ef19d9 100644 --- a/src/views/members/components/DeleteMemberConfirmation.tsx +++ b/src/views/members/components/DeleteMemberConfirmation.tsx @@ -1,12 +1,14 @@ import { api } from "~/utils/api"; import { useModal } from "~/providers/modal"; import { usePopup } from "~/providers/popup"; +import { useWorkspace } from "~/providers/workspace"; import Button from "~/components/Button"; export function DeleteMemberConfirmation() { const utils = api.useUtils(); const { closeModal, entityLabel, entityId } = useModal(); + const { workspace } = useWorkspace(); const { showPopup } = usePopup(); const deleteMember = api.member.delete.useMutation({ @@ -31,6 +33,7 @@ export function DeleteMemberConfirmation() { if (entityId) deleteMember.mutate({ memberPublicId: entityId, + workspacePublicId: workspace.publicId, }); }; diff --git a/src/views/members/index.tsx b/src/views/members/index.tsx index 5dd138d7..38166bd7 100644 --- a/src/views/members/index.tsx +++ b/src/views/members/index.tsx @@ -18,7 +18,7 @@ export default function MembersPage() { const { workspace } = useWorkspace(); const { data, isLoading } = api.workspace.byId.useQuery( - { publicId: workspace.publicId }, + { workspacePublicId: workspace.publicId }, // { enabled: workspace?.publicId ? true : false }, );