feat: show custom templates in new board form
This commit is contained in:
@@ -39,6 +39,13 @@ export function NewBoardForm({ isTemplate }: { isTemplate?: boolean }) {
|
|||||||
{ enabled: !!workspace.publicId },
|
{ 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 {
|
const {
|
||||||
register,
|
register,
|
||||||
handleSubmit,
|
handleSubmit,
|
||||||
@@ -114,6 +121,7 @@ export function NewBoardForm({ isTemplate }: { isTemplate?: boolean }) {
|
|||||||
currentBoard={currentTemplate}
|
currentBoard={currentTemplate}
|
||||||
setCurrentBoard={(t) => setValue("template", t)}
|
setCurrentBoard={(t) => setValue("template", t)}
|
||||||
showTemplates={showTemplates}
|
showTemplates={showTemplates}
|
||||||
|
customTemplates={formattedTemplates ?? []}
|
||||||
/>
|
/>
|
||||||
<div className="mt-12 flex items-center justify-end border-t border-light-600 px-5 pb-5 pt-5 dark:border-dark-600">
|
<div className="mt-12 flex items-center justify-end border-t border-light-600 px-5 pb-5 pt-5 dark:border-dark-600">
|
||||||
{!isTemplate && (
|
{!isTemplate && (
|
||||||
|
|||||||
@@ -88,16 +88,18 @@ export default function TemplateBoards({
|
|||||||
currentBoard,
|
currentBoard,
|
||||||
setCurrentBoard,
|
setCurrentBoard,
|
||||||
showTemplates,
|
showTemplates,
|
||||||
|
customTemplates,
|
||||||
}: {
|
}: {
|
||||||
currentBoard: Template | null;
|
currentBoard: Template | null;
|
||||||
setCurrentBoard: (board: Template | null) => void;
|
setCurrentBoard: (board: Template | null) => void;
|
||||||
showTemplates: boolean;
|
showTemplates: boolean;
|
||||||
|
customTemplates: Template[] | null;
|
||||||
}) {
|
}) {
|
||||||
const [showFade, setShowFade] = useState(false);
|
const [showFade, setShowFade] = useState(false);
|
||||||
const [showTopFade, setShowTopFade] = useState(false);
|
const [showTopFade, setShowTopFade] = useState(false);
|
||||||
const scrollRef = useRef<HTMLDivElement>(null);
|
const scrollRef = useRef<HTMLDivElement>(null);
|
||||||
|
|
||||||
const templates = getTemplates();
|
const templates = [...(customTemplates ?? []), ...getTemplates()];
|
||||||
|
|
||||||
const handleScroll = () => {
|
const handleScroll = () => {
|
||||||
if (!scrollRef.current) return;
|
if (!scrollRef.current) return;
|
||||||
|
|||||||
@@ -25,6 +25,23 @@ export const getAllByWorkspaceId = (
|
|||||||
publicId: true,
|
publicId: true,
|
||||||
name: 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(
|
where: and(
|
||||||
eq(boards.workspaceId, workspaceId),
|
eq(boards.workspaceId, workspaceId),
|
||||||
isNull(boards.deletedAt),
|
isNull(boards.deletedAt),
|
||||||
|
|||||||
Reference in New Issue
Block a user