From 8ba991a0d31a09fb1fb679b13c5e0e28bade31bc Mon Sep 17 00:00:00 2001 From: Henry Date: Thu, 9 Oct 2025 21:59:55 +0100 Subject: [PATCH] feat: show custom templates in new board form --- .../views/boards/components/NewBoardForm.tsx | 8 ++++++++ .../views/boards/components/TemplateBoards.tsx | 4 +++- packages/db/src/repository/board.repo.ts | 17 +++++++++++++++++ 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/apps/web/src/views/boards/components/NewBoardForm.tsx b/apps/web/src/views/boards/components/NewBoardForm.tsx index 16af6a22..696ef465 100644 --- a/apps/web/src/views/boards/components/NewBoardForm.tsx +++ b/apps/web/src/views/boards/components/NewBoardForm.tsx @@ -39,6 +39,13 @@ export function NewBoardForm({ isTemplate }: { isTemplate?: boolean }) { { enabled: !!workspace.publicId }, ); + const formattedTemplates = templates?.map((template) => ({ + id: template.publicId, + name: template.name, + lists: template.lists.map((list) => list.name), + labels: template.labels.map((label) => label.name), + })); + const { register, handleSubmit, @@ -114,6 +121,7 @@ export function NewBoardForm({ isTemplate }: { isTemplate?: boolean }) { currentBoard={currentTemplate} setCurrentBoard={(t) => setValue("template", t)} showTemplates={showTemplates} + customTemplates={formattedTemplates ?? []} />
{!isTemplate && ( diff --git a/apps/web/src/views/boards/components/TemplateBoards.tsx b/apps/web/src/views/boards/components/TemplateBoards.tsx index bdba9d5f..37cdbd5c 100644 --- a/apps/web/src/views/boards/components/TemplateBoards.tsx +++ b/apps/web/src/views/boards/components/TemplateBoards.tsx @@ -88,16 +88,18 @@ export default function TemplateBoards({ currentBoard, setCurrentBoard, showTemplates, + customTemplates, }: { currentBoard: Template | null; setCurrentBoard: (board: Template | null) => void; showTemplates: boolean; + customTemplates: Template[] | null; }) { const [showFade, setShowFade] = useState(false); const [showTopFade, setShowTopFade] = useState(false); const scrollRef = useRef(null); - const templates = getTemplates(); + const templates = [...(customTemplates ?? []), ...getTemplates()]; const handleScroll = () => { if (!scrollRef.current) return; diff --git a/packages/db/src/repository/board.repo.ts b/packages/db/src/repository/board.repo.ts index 0481c7e1..200fa9f2 100644 --- a/packages/db/src/repository/board.repo.ts +++ b/packages/db/src/repository/board.repo.ts @@ -25,6 +25,23 @@ export const getAllByWorkspaceId = ( publicId: true, name: true, }, + with: { + lists: { + columns: { + publicId: true, + name: true, + index: true, + }, + orderBy: [asc(lists.index)], + }, + labels: { + columns: { + publicId: true, + name: true, + colourCode: true, + }, + }, + }, where: and( eq(boards.workspaceId, workspaceId), isNull(boards.deletedAt),