diff --git a/package-lock.json b/package-lock.json index 9082b77e..dc1d65d4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10124,6 +10124,126 @@ "@react-email/components": "0.0.12", "react-email": "^1.10.0" } + }, + "node_modules/@next/swc-darwin-x64": { + "version": "14.1.4", + "resolved": "https://registry.npmjs.org/@next/swc-darwin-x64/-/swc-darwin-x64-14.1.4.tgz", + "integrity": "sha512-b0Xo1ELj3u7IkZWAKcJPJEhBop117U78l70nfoQGo4xUSvv0PJSTaV4U9xQBLvZlnjsYkc8RwQN1HoH/oQmLlQ==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-linux-arm64-gnu": { + "version": "14.1.4", + "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-14.1.4.tgz", + "integrity": "sha512-457G0hcLrdYA/u1O2XkRMsDKId5VKe3uKPvrKVOyuARa6nXrdhJOOYU9hkKKyQTMru1B8qEP78IAhf/1XnVqKA==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-linux-arm64-musl": { + "version": "14.1.4", + "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-14.1.4.tgz", + "integrity": "sha512-l/kMG+z6MB+fKA9KdtyprkTQ1ihlJcBh66cf0HvqGP+rXBbOXX0dpJatjZbHeunvEHoBBS69GYQG5ry78JMy3g==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-linux-x64-gnu": { + "version": "14.1.4", + "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-14.1.4.tgz", + "integrity": "sha512-BapIFZ3ZRnvQ1uWbmqEGJuPT9cgLwvKtxhK/L2t4QYO7l+/DxXuIGjvp1x8rvfa/x1FFSsipERZK70pewbtJtw==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-linux-x64-musl": { + "version": "14.1.4", + "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-14.1.4.tgz", + "integrity": "sha512-mqVxTwk4XuBl49qn2A5UmzFImoL1iLm0KQQwtdRJRKl21ylQwwGCxJtIYo2rbfkZHoSKlh/YgztY0qH3wG1xIg==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-win32-arm64-msvc": { + "version": "14.1.4", + "resolved": "https://registry.npmjs.org/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-14.1.4.tgz", + "integrity": "sha512-xzxF4ErcumXjO2Pvg/wVGrtr9QQJLk3IyQX1ddAC/fi6/5jZCZ9xpuL9Tzc4KPWMFq8GGWFVDMshZOdHGdkvag==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-win32-ia32-msvc": { + "version": "14.1.4", + "resolved": "https://registry.npmjs.org/@next/swc-win32-ia32-msvc/-/swc-win32-ia32-msvc-14.1.4.tgz", + "integrity": "sha512-WZiz8OdbkpRw6/IU/lredZWKKZopUMhcI2F+XiMAcPja0uZYdMTZQRoQ0WZcvinn9xZAidimE7tN9W5v9Yyfyw==", + "cpu": [ + "ia32" + ], + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-win32-x64-msvc": { + "version": "14.1.4", + "resolved": "https://registry.npmjs.org/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-14.1.4.tgz", + "integrity": "sha512-4Rto21sPfw555sZ/XNLqfxDUNeLhNYGO2dlPqsnuCg8N8a2a9u1ltqBOPQ4vj1Gf7eJC0W2hHG2eYUHuiXgY2w==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 10" + } } } } diff --git a/src/providers/board.tsx b/src/providers/board.tsx index 2b090216..107ce580 100644 --- a/src/providers/board.tsx +++ b/src/providers/board.tsx @@ -8,9 +8,9 @@ import React, { import { api } from "~/utils/api"; import { - GetBoardByIdOutput, - ReorderCardInput, - ReorderListInput, + type GetBoardByIdOutput, + type ReorderCardInput, + type ReorderListInput, } from "~/types/router.types"; interface BoardContextProps { @@ -40,29 +40,22 @@ export const BoardProvider: React.FC<{ children: ReactNode }> = ({ const [boardData, setBoardData] = useState(initialBoardData); - const refetchBoard = () => { - if (boardData?.publicId) - utils.board.byId.refetch({ boardPublicId: boardData.publicId }); + const refetchBoard = async () => { + if (boardData?.publicId) { + try { + await utils.board.byId.refetch({ boardPublicId: boardData.publicId }); + } catch (e) { + console.error(e); + } + } }; const updateCardMutation = api.card.reorder.useMutation({ - onSuccess: async () => { - try { - await refetchBoard(); - } catch (e) { - console.log(e); - } - }, + onSuccess: () => refetchBoard(), }); const updateListMutation = api.list.reorder.useMutation({ - onSuccess: async () => { - try { - await refetchBoard(); - } catch (e) { - console.log(e); - } - }, + onSuccess: () => refetchBoard(), }); const updateList = ({ diff --git a/src/server/api/routers/card.ts b/src/server/api/routers/card.ts index 845d571e..fea5dab7 100644 --- a/src/server/api/routers/card.ts +++ b/src/server/api/routers/card.ts @@ -195,7 +195,7 @@ export const cardRouter = createTRPCRouter({ input.cardPublicId, ); - if (!card || !card?.list?.id) return; + if (!card ?? !card?.list?.id) return; const deletedAt = new Date().toISOString(); diff --git a/src/server/api/routers/list.ts b/src/server/api/routers/list.ts index 40261701..b25cd252 100644 --- a/src/server/api/routers/list.ts +++ b/src/server/api/routers/list.ts @@ -105,5 +105,7 @@ export const listRouter = createTRPCRouter({ { name: input.name }, { listPublicId: input.listPublicId }, ); + + return result; }), }); diff --git a/src/server/api/routers/workspace.ts b/src/server/api/routers/workspace.ts index 02e52a21..d1c74708 100644 --- a/src/server/api/routers/workspace.ts +++ b/src/server/api/routers/workspace.ts @@ -1,5 +1,4 @@ import { z } from "zod"; -import { generateUID } from "~/utils/generateUID"; import { createTRPCRouter, protectedProcedure } from "~/server/api/trpc"; import * as workspaceRepo from "~/server/db/repository/workspace.repo"; diff --git a/src/types/router.types.ts b/src/types/router.types.ts index 8b7d7f6e..5c52527d 100644 --- a/src/types/router.types.ts +++ b/src/types/router.types.ts @@ -1,4 +1,4 @@ -import { RouterInputs, type RouterOutputs } from "~/utils/api"; +import { type RouterInputs, type RouterOutputs } from "~/utils/api"; export type GetBoardByIdOutput = RouterOutputs["board"]["byId"]; export type ReorderListInput = RouterInputs["list"]["reorder"]; diff --git a/src/views/board/components/DeleteListConfirmation.tsx b/src/views/board/components/DeleteListConfirmation.tsx index 4b1f67fb..894c3434 100644 --- a/src/views/board/components/DeleteListConfirmation.tsx +++ b/src/views/board/components/DeleteListConfirmation.tsx @@ -13,15 +13,20 @@ export function DeleteListConfirmation({ const { boardData } = useBoard(); const { closeModal } = useModal(); - const refetchBoard = () => { - if (boardData?.publicId) - utils.board.byId.refetch({ boardPublicId: boardData.publicId }); + const refetchBoard = async () => { + if (boardData?.publicId) { + try { + await utils.board.byId.refetch({ boardPublicId: boardData.publicId }); + } catch (e) { + console.error(e); + } + } }; const deleteList = api.list.delete.useMutation({ - onSuccess: async () => { + onSuccess: () => { closeModal(); - await refetchBoard(); + return refetchBoard(); }, }); diff --git a/src/views/board/components/NewCardForm.tsx b/src/views/board/components/NewCardForm.tsx index 5fbe8e83..fd00419d 100644 --- a/src/views/board/components/NewCardForm.tsx +++ b/src/views/board/components/NewCardForm.tsx @@ -9,7 +9,7 @@ import CheckboxDropdown from "~/components/CheckboxDropdown"; import { useBoard } from "~/providers/board"; import { useModal } from "~/providers/modal"; -import { NewCardInput } from "~/types/router.types"; +import { type NewCardInput } from "~/types/router.types"; type NewCardFormInput = NewCardInput & { isCreateAnotherEnabled: boolean; @@ -43,9 +43,14 @@ export function NewCardForm({ listPublicId }: NewCardFormProps) { const memberPublicIds = watch("memberPublicIds") || []; const isCreateAnotherEnabled = watch("isCreateAnotherEnabled"); - const refetchBoard = () => { - if (boardData?.publicId) - utils.board.byId.refetch({ boardPublicId: boardData.publicId }); + const refetchBoard = async () => { + if (boardData?.publicId) { + try { + await utils.board.byId.refetch({ boardPublicId: boardData.publicId }); + } catch (e) { + console.error(e); + } + } }; const createCard = api.card.create.useMutation({ diff --git a/src/views/board/components/NewListForm.tsx b/src/views/board/components/NewListForm.tsx index cb7f8976..5ea3f3f4 100644 --- a/src/views/board/components/NewListForm.tsx +++ b/src/views/board/components/NewListForm.tsx @@ -7,7 +7,7 @@ import { Switch } from "@headlessui/react"; import { useBoard } from "~/providers/board"; import { useModal } from "~/providers/modal"; -import { NewListInput } from "~/types/router.types"; +import { type NewListInput } from "~/types/router.types"; import { Formik, Form, Field } from "formik"; @@ -21,16 +21,21 @@ export function NewListForm({ boardPublicId }: { boardPublicId: string }) { const { closeModal } = useModal(); const [isCreateAnotherEnabled, setIsCreateAnotherEnabled] = useState(false); - const refetchBoard = () => { - if (boardData?.publicId) - utils.board.byId.refetch({ boardPublicId: boardData.publicId }); + const refetchBoard = async () => { + if (boardData?.publicId) { + try { + await utils.board.byId.refetch({ boardPublicId: boardData.publicId }); + } catch (e) { + console.error(e); + } + } }; const createList = api.list.create.useMutation({ - onSuccess: async () => { + onSuccess: () => { try { - await refetchBoard(); if (!isCreateAnotherEnabled) closeModal(); + return refetchBoard(); } catch (e) { console.log(e); } diff --git a/src/views/board/index.tsx b/src/views/board/index.tsx index fe705cff..61934de7 100644 --- a/src/views/board/index.tsx +++ b/src/views/board/index.tsx @@ -25,7 +25,7 @@ import { NewWorkspaceForm } from "~/components/NewWorkspaceForm"; import { NewCardForm } from "./components/NewCardForm"; import { NewListForm } from "./components/NewListForm"; -import { UpdateBoardInput } from "~/types/router.types"; +import { type UpdateBoardInput } from "~/types/router.types"; type PublicListId = string; @@ -228,7 +228,7 @@ export default function BoardPage() { > - {member?.user?.name && - member.user.name - .split(" ") - .map((namePart) => - namePart - .charAt(0) - .toUpperCase(), - ) - .join("")} + {member?.user?.name + ?.split(" ") + .map((namePart) => + namePart + .charAt(0) + .toUpperCase(), + ) + .join("")} ))} diff --git a/src/views/boards/components/NewBoardForm.tsx b/src/views/boards/components/NewBoardForm.tsx index 4f23bebf..026fbc32 100644 --- a/src/views/boards/components/NewBoardForm.tsx +++ b/src/views/boards/components/NewBoardForm.tsx @@ -7,7 +7,7 @@ import { useWorkspace } from "~/providers/workspace"; import { Formik, Form, Field } from "formik"; -import { NewBoardInput } from "~/types/router.types"; +import { type NewBoardInput } from "~/types/router.types"; export function NewBoardForm() { const utils = api.useUtils();