feat: show checklist progress on public board page

This commit is contained in:
Henry
2025-08-14 12:57:13 +01:00
parent 8c38c7c09a
commit cb80c664d9
4 changed files with 30 additions and 9 deletions

View File

@@ -10,7 +10,7 @@ interface Props {
children: React.ReactNode; children: React.ReactNode;
} }
type ModalContextType = { interface ModalContextType {
isOpen: boolean; isOpen: boolean;
openModal: ( openModal: (
contentType: string, contentType: string,
@@ -26,7 +26,7 @@ type ModalContextType = {
getModalState: (modalType: string) => any; getModalState: (modalType: string) => any;
clearModalState: (modalType: string) => void; clearModalState: (modalType: string) => void;
clearAllModalStates: () => void; clearAllModalStates: () => void;
}; }
const ModalContext = createContext<ModalContextType | undefined>(undefined); const ModalContext = createContext<ModalContextType | undefined>(undefined);
@@ -46,11 +46,11 @@ export const ModalProvider: React.FC<Props> = ({ children }) => {
entityLabel?: string, entityLabel?: string,
) => { ) => {
const newModal: ModalState = { contentType, entityId, entityLabel }; const newModal: ModalState = { contentType, entityId, entityLabel };
setModalStack(prev => [...prev, newModal]); setModalStack((prev) => [...prev, newModal]);
}; };
const closeModal = () => { const closeModal = () => {
setModalStack(prev => { setModalStack((prev) => {
if (prev.length <= 1) { if (prev.length <= 1) {
return []; return [];
} }
@@ -59,9 +59,9 @@ export const ModalProvider: React.FC<Props> = ({ children }) => {
}; };
const setModalState = (modalType: string, state: any) => { const setModalState = (modalType: string, state: any) => {
setModalStates(prev => ({ setModalStates((prev) => ({
...prev, ...prev,
[modalType]: state [modalType]: state,
})); }));
}; };
@@ -70,7 +70,7 @@ export const ModalProvider: React.FC<Props> = ({ children }) => {
}; };
const clearModalState = (modalType: string) => { const clearModalState = (modalType: string) => {
setModalStates(prev => { setModalStates((prev) => {
const newStates = { ...prev }; const newStates = { ...prev };
delete newStates[modalType]; delete newStates[modalType];
return newStates; return newStates;

View File

@@ -13,7 +13,6 @@ import type { UpdateBoardInput } from "@kan/api/types";
import Button from "~/components/Button"; import Button from "~/components/Button";
import { DeleteLabelConfirmation } from "~/components/DeleteLabelConfirmation"; import { DeleteLabelConfirmation } from "~/components/DeleteLabelConfirmation";
import FeedbackModal from "~/components/FeedbackModal";
import { LabelForm } from "~/components/LabelForm"; import { LabelForm } from "~/components/LabelForm";
import Modal from "~/components/modal"; import Modal from "~/components/modal";
import { NewWorkspaceForm } from "~/components/NewWorkspaceForm"; import { NewWorkspaceForm } from "~/components/NewWorkspaceForm";
@@ -492,7 +491,7 @@ export default function BoardPage() {
title={card.title} title={card.title}
labels={card.labels} labels={card.labels}
members={card.members} members={card.members}
checklists={card.checklists} checklists={card.checklists ?? []}
/> />
</Link> </Link>
)} )}

View File

@@ -175,6 +175,7 @@ export default function PublicBoardView() {
<Card <Card
title={card.title} title={card.title}
labels={card.labels} labels={card.labels}
checklists={card.checklists ?? []}
members={[]} members={[]}
/> />
</Link> </Link>

View File

@@ -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( where: and(
cardIds.length > 0 ? inArray(cards.publicId, cardIds) : undefined, cardIds.length > 0 ? inArray(cards.publicId, cardIds) : undefined,