import React, { useState } from "react"; // Next imports import Link from "next/link"; // React beautiful dnd import { Draggable } from "react-beautiful-dnd"; import StrictModeDroppable from "components/dnd/StrictModeDroppable"; // common import { addSpaceIfCamelCase, findHowManyDaysLeft, renderShortNumericDateFormat, } from "constants/common"; // types import { IIssue, Properties, NestedKeyOf } from "types"; // icons import { ArrowsPointingInIcon, ArrowsPointingOutIcon, CalendarDaysIcon, EllipsisHorizontalIcon, PlusIcon, } from "@heroicons/react/24/outline"; import Image from "next/image"; import { getPriorityIcon } from "constants/global"; 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; }; const SingleBoard: React.FC = ({ selectedGroup, groupTitle, groupedByIssues, index, setIsIssueOpen, properties, setPreloadedData, bgColor = "#0f2b16", stateId, createdBy, }) => { // Collapse/Expand const [show, setState] = useState(true); if (selectedGroup === "priority") groupTitle === "high" ? (bgColor = "#dc2626") : groupTitle === "medium" ? (bgColor = "#f97316") : groupTitle === "low" ? (bgColor = "#22c55e") : (bgColor = "#ff0000"); return ( {(provided, snapshot) => (

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

{groupedByIssues[groupTitle].length}
{(provided, snapshot) => (
{groupedByIssues[groupTitle].map((childIssue, index: number) => ( {(provided, snapshot) => (
{properties.key && (
{childIssue.project_detail?.identifier}-{childIssue.sequence_id}
)}
{childIssue.name}
{properties.priority && (
{/* {getPriorityIcon(childIssue.priority ?? "")} */} {childIssue.priority}
)} {properties.state && (
{addSpaceIfCamelCase(childIssue.state_detail.name)}
)} {properties.start_date && (
{childIssue.start_date ? renderShortNumericDateFormat(childIssue.start_date) : "N/A"}
)} {properties.target_date && (
{childIssue.target_date ? renderShortNumericDateFormat(childIssue.target_date) : "N/A"} {childIssue.target_date && ( {childIssue.target_date < new Date().toISOString() ? `Target date has passed by ${findHowManyDaysLeft( childIssue.target_date )} days` : findHowManyDaysLeft(childIssue.target_date) <= 3 ? `Target date is in ${findHowManyDaysLeft( childIssue.target_date )} days` : "Target date"} )}
)} {properties.assignee && (
{childIssue?.assignee_details?.length > 0 ? ( childIssue?.assignee_details?.map( (assignee, index: number) => (
{assignee.avatar && assignee.avatar !== "" ? (
{assignee.name}
) : (
{assignee.first_name.charAt(0)}
)}
) ) ) : ( No assignee. )}
)}
)}
))} {provided.placeholder}
)}
)}
); }; export default SingleBoard;