diff --git a/apps/web/src/views/board/components/Filters.tsx b/apps/web/src/views/board/components/Filters.tsx index 643ad5c7..3a0accf6 100644 --- a/apps/web/src/views/board/components/Filters.tsx +++ b/apps/web/src/views/board/components/Filters.tsx @@ -13,59 +13,30 @@ import LabelIcon from "~/components/LabelIcon"; import { formatMemberDisplayName, formatToArray } from "~/utils/helpers"; import { getPublicUrl } from "~/utils/supabase/getPublicUrl"; -interface BoardData { +interface Member { + publicId: string; + user: { + name: string | null; + image: string | null; + email: string; + } | null; +} + +interface Label { publicId: string; name: string; - slug: string; - workspace: { - publicId: string; - members?: { - publicId: string; - user: { - name: string | null; - image: string | null; - email: string; - } | null; - }[]; - } | null; - labels: { - publicId: string; - name: string; - colourCode: string | null; - }[]; - lists: { - publicId: string; - name: string; - boardId: number; - index: number; - cards: { - publicId: string; - title: string; - description: string | null; - listId: number; - index: number; - labels: { - publicId: string; - name: string; - colourCode: string | null; - }[]; - members?: { - publicId: string; - user: { - name: string | null; - } | null; - }[]; - }[]; - }[]; + colourCode: string | null; } const Filters = ({ position = "right", - boardData, + labels, + members, isLoading, }: { position?: "left" | "right"; - boardData: BoardData | null; + labels: Label[]; + members: Member[]; isLoading: boolean; }) => { const router = useRouter(); @@ -84,33 +55,31 @@ const Filters = ({ } }; - const formattedMembers = - boardData?.workspace?.members?.map((member) => ({ - key: member.publicId, - value: formatMemberDisplayName( - member.user?.name ?? null, - member.user?.email ?? null, - ), - selected: !!router.query.members?.includes(member.publicId), - leftIcon: ( - - ), - })) ?? []; + const formattedMembers = members.map((member) => ({ + key: member.publicId, + value: formatMemberDisplayName( + member.user?.name ?? null, + member.user?.email ?? null, + ), + selected: !!router.query.members?.includes(member.publicId), + leftIcon: ( + + ), + })); - const formattedLabels = - boardData?.labels.map((label) => ({ - key: label.publicId, - value: label.name, - selected: !!router.query.labels?.includes(label.publicId), - leftIcon: , - })) ?? []; + const formattedLabels = labels.map((label) => ({ + key: label.publicId, + value: label.name, + selected: !!router.query.labels?.includes(label.publicId), + leftIcon: , + })); const groups = [ ...(formattedMembers.length diff --git a/apps/web/src/views/board/index.tsx b/apps/web/src/views/board/index.tsx index 1ded4827..204bc041 100644 --- a/apps/web/src/views/board/index.tsx +++ b/apps/web/src/views/board/index.tsx @@ -2,6 +2,7 @@ import type { DropResult } from "react-beautiful-dnd"; import Link from "next/link"; import { useParams } from "next/navigation"; import { useRouter } from "next/router"; +import { keepPreviousData } from "@tanstack/react-query"; import { useEffect, useState } from "react"; import { DragDropContext, Draggable } from "react-beautiful-dnd"; import { useForm } from "react-hook-form"; @@ -74,6 +75,7 @@ export default function BoardPage() { isLoading: isQueryLoading, } = api.board.byId.useQuery(queryParams, { enabled: !!boardId, + placeholderData: keepPreviousData, }); useEffect(() => { @@ -245,7 +247,8 @@ export default function BoardPage() { isAdmin={workspace.role === "admin"} /> diff --git a/apps/web/src/views/public/board/index.tsx b/apps/web/src/views/public/board/index.tsx index 6a01098a..a42e941c 100644 --- a/apps/web/src/views/public/board/index.tsx +++ b/apps/web/src/views/public/board/index.tsx @@ -1,5 +1,6 @@ import Link from "next/link"; import { useRouter } from "next/router"; +import { keepPreviousData } from "@tanstack/react-query"; import { useEffect, useState } from "react"; import { HiLink } from "react-icons/hi2"; @@ -32,7 +33,7 @@ export default function PublicBoardView() { members: formatToArray(router.query.members), labels: formatToArray(router.query.labels), }, - { enabled: !!boardSlug }, + { enabled: !!boardSlug, placeholderData: keepPreviousData }, ); const CopyBoardLink = () => { @@ -104,7 +105,11 @@ export default function PublicBoardView() { )}
- +