From cb80c664d9dd584ea90670383b38bae34530cc8a Mon Sep 17 00:00:00 2001 From: Henry Date: Thu, 14 Aug 2025 12:57:13 +0100 Subject: [PATCH] feat: show checklist progress on public board page --- apps/web/src/providers/modal.tsx | 14 +++++++------- apps/web/src/views/board/index.tsx | 3 +-- apps/web/src/views/public/board/index.tsx | 1 + packages/db/src/repository/board.repo.ts | 21 +++++++++++++++++++++ 4 files changed, 30 insertions(+), 9 deletions(-) diff --git a/apps/web/src/providers/modal.tsx b/apps/web/src/providers/modal.tsx index d41ffdaf..2300d4df 100644 --- a/apps/web/src/providers/modal.tsx +++ b/apps/web/src/providers/modal.tsx @@ -10,7 +10,7 @@ interface Props { children: React.ReactNode; } -type ModalContextType = { +interface ModalContextType { isOpen: boolean; openModal: ( contentType: string, @@ -26,7 +26,7 @@ type ModalContextType = { getModalState: (modalType: string) => any; clearModalState: (modalType: string) => void; clearAllModalStates: () => void; -}; +} const ModalContext = createContext(undefined); @@ -46,11 +46,11 @@ export const ModalProvider: React.FC = ({ children }) => { entityLabel?: string, ) => { const newModal: ModalState = { contentType, entityId, entityLabel }; - setModalStack(prev => [...prev, newModal]); + setModalStack((prev) => [...prev, newModal]); }; const closeModal = () => { - setModalStack(prev => { + setModalStack((prev) => { if (prev.length <= 1) { return []; } @@ -59,9 +59,9 @@ export const ModalProvider: React.FC = ({ children }) => { }; const setModalState = (modalType: string, state: any) => { - setModalStates(prev => ({ + setModalStates((prev) => ({ ...prev, - [modalType]: state + [modalType]: state, })); }; @@ -70,7 +70,7 @@ export const ModalProvider: React.FC = ({ children }) => { }; const clearModalState = (modalType: string) => { - setModalStates(prev => { + setModalStates((prev) => { const newStates = { ...prev }; delete newStates[modalType]; return newStates; diff --git a/apps/web/src/views/board/index.tsx b/apps/web/src/views/board/index.tsx index 0e4ce5a2..beedd806 100644 --- a/apps/web/src/views/board/index.tsx +++ b/apps/web/src/views/board/index.tsx @@ -13,7 +13,6 @@ import type { UpdateBoardInput } from "@kan/api/types"; import Button from "~/components/Button"; import { DeleteLabelConfirmation } from "~/components/DeleteLabelConfirmation"; -import FeedbackModal from "~/components/FeedbackModal"; import { LabelForm } from "~/components/LabelForm"; import Modal from "~/components/modal"; import { NewWorkspaceForm } from "~/components/NewWorkspaceForm"; @@ -492,7 +491,7 @@ export default function BoardPage() { title={card.title} labels={card.labels} members={card.members} - checklists={card.checklists} + checklists={card.checklists ?? []} /> )} diff --git a/apps/web/src/views/public/board/index.tsx b/apps/web/src/views/public/board/index.tsx index 633ab929..1944f763 100644 --- a/apps/web/src/views/public/board/index.tsx +++ b/apps/web/src/views/public/board/index.tsx @@ -175,6 +175,7 @@ export default function PublicBoardView() { diff --git a/packages/db/src/repository/board.repo.ts b/packages/db/src/repository/board.repo.ts index 42219ec8..2dd6dbe2 100644 --- a/packages/db/src/repository/board.repo.ts +++ b/packages/db/src/repository/board.repo.ts @@ -303,6 +303,27 @@ export const getBySlug = async ( }, }, }, + checklists: { + columns: { + publicId: true, + name: true, + index: true, + }, + where: isNull(checklists.deletedAt), + orderBy: asc(checklists.index), + with: { + items: { + columns: { + publicId: true, + title: true, + completed: true, + index: true, + }, + where: isNull(checklistItems.deletedAt), + orderBy: asc(checklistItems.index), + }, + }, + }, }, where: and( cardIds.length > 0 ? inArray(cards.publicId, cardIds) : undefined,