// react import React, { useState } from "react"; // swr import useSWR from "swr"; // services import workspaceService from "lib/services/workspace.service"; // components import SingleIssue from "components/common/board-view/single-issue"; // ui import { CustomMenu } from "ui"; // icons import { PlusIcon } from "@heroicons/react/24/outline"; // types import { IIssue, IWorkspaceMember, NestedKeyOf, Properties } from "types"; // fetch-keys import { WORKSPACE_MEMBERS } from "constants/fetch-keys"; // common import { addSpaceIfCamelCase } from "constants/common"; import { useRouter } from "next/router"; import StrictModeDroppable from "components/dnd/StrictModeDroppable"; import { Draggable } from "react-beautiful-dnd"; type Props = { properties: Properties; groupedByIssues: { [key: string]: IIssue[]; }; selectedGroup: NestedKeyOf | null; groupTitle: string; createdBy: string | null; bgColor?: string; openCreateIssueModal: (issue?: IIssue, actionType?: "create" | "edit" | "delete") => void; openIssuesListModal: () => void; removeIssueFromCycle: (bridgeId: string) => void; partialUpdateIssue: (formData: Partial, issueId: string) => void; handleDeleteIssue: React.Dispatch>; setPreloadedData: React.Dispatch< React.SetStateAction< | (Partial & { actionType: "createIssue" | "edit" | "delete"; }) | undefined > >; stateId: string | null; }; const SingleModuleBoard: React.FC = ({ properties, groupedByIssues, selectedGroup, groupTitle, createdBy, bgColor, openCreateIssueModal, openIssuesListModal, removeIssueFromCycle, partialUpdateIssue, handleDeleteIssue, setPreloadedData, stateId, }) => { // TODO: will use this to collapse/expand the board const [isCollapsed, setIsCollapsed] = useState(true); const router = useRouter(); const { workspaceSlug } = router.query; if (selectedGroup === "priority") groupTitle === "high" ? (bgColor = "#dc2626") : groupTitle === "medium" ? (bgColor = "#f97316") : groupTitle === "low" ? (bgColor = "#22c55e") : (bgColor = "#ff0000"); const { data: people } = useSWR( workspaceSlug ? WORKSPACE_MEMBERS : null, workspaceSlug ? () => workspaceService.workspaceMembers(workspaceSlug as string) : null ); return (

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

{groupedByIssues[groupTitle].length}
{ openCreateIssueModal(); if (selectedGroup !== null) { setPreloadedData({ state: stateId !== null ? stateId : undefined, [selectedGroup]: groupTitle, actionType: "createIssue", }); } }} > Create new openIssuesListModal()}> Add an existing issue
{(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} Add issue } className="mt-1" optionsPosition="left" noBorder > { openCreateIssueModal(); if (selectedGroup !== null) { setPreloadedData({ state: stateId !== null ? stateId : undefined, [selectedGroup]: groupTitle, actionType: "createIssue", }); } }} > Create new openIssuesListModal()}> Add an existing issue
)}
); }; export default SingleModuleBoard;