// react import React, { useState } from "react"; // swr import useSWR from "swr"; // react-beautiful-dnd import { Draggable } from "react-beautiful-dnd"; import StrictModeDroppable from "components/dnd/StrictModeDroppable"; // services import workspaceService from "lib/services/workspace.service"; // hooks import useUser from "lib/hooks/useUser"; // icons import { ArrowsPointingInIcon, ArrowsPointingOutIcon, EllipsisHorizontalIcon, PlusIcon, } from "@heroicons/react/24/outline"; import { addSpaceIfCamelCase } from "constants/common"; import { WORKSPACE_MEMBERS } from "constants/fetch-keys"; // types import { IIssue, Properties, NestedKeyOf, IWorkspaceMember } from "types"; import SingleIssue from "components/common/board-view/single-issue"; type Props = { selectedGroup: NestedKeyOf | null; groupTitle: string; groupedByIssues: { [key: string]: IIssue[]; }; index: number; setIsIssueOpen: React.Dispatch>; properties: Properties; setPreloadedData: React.Dispatch< React.SetStateAction< | (Partial & { actionType: "createIssue" | "edit" | "delete"; }) | undefined > >; bgColor?: string; stateId: string | null; createdBy: string | null; handleDeleteIssue: React.Dispatch>; partialUpdateIssue: (formData: Partial, childIssueId: string) => void; }; const SingleBoard: React.FC = ({ selectedGroup, groupTitle, groupedByIssues, index, setIsIssueOpen, properties, setPreloadedData, bgColor = "#0f2b16", stateId, createdBy, handleDeleteIssue, partialUpdateIssue, }) => { // Collapse/Expand const [show, setShow] = useState(true); const { activeWorkspace } = useUser(); if (selectedGroup === "priority") groupTitle === "high" ? (bgColor = "#dc2626") : groupTitle === "medium" ? (bgColor = "#f97316") : groupTitle === "low" ? (bgColor = "#22c55e") : (bgColor = "#ff0000"); const { data: people } = useSWR( activeWorkspace ? WORKSPACE_MEMBERS : null, activeWorkspace ? () => workspaceService.workspaceMembers(activeWorkspace.slug) : null ); return ( {(provided, snapshot) => (

{groupTitle === null || groupTitle === "null" ? "None" : createdBy ? createdBy : addSpaceIfCamelCase(groupTitle)}

{groupedByIssues[groupTitle].length}
{(provided, snapshot) => (
{groupedByIssues[groupTitle].map((childIssue, index: number) => { const assignees = [ ...(childIssue?.assignees_list ?? []), ...(childIssue?.assignees ?? []), ]?.map((assignee) => { const tempPerson = people?.find((p) => p.member.id === assignee)?.member; return { avatar: tempPerson?.avatar, first_name: tempPerson?.first_name, email: tempPerson?.email, }; }); return ( {(provided, snapshot) => (
)}
); })} {provided.placeholder}
)}
)}
); }; export default SingleBoard;