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, PencilIcon, PlusIcon, } from "@heroicons/react/24/outline"; import Image from "next/image"; import { divide } from "lodash"; 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; createdBy?: string; }; const SingleBoard: React.FC = ({ selectedGroup, groupTitle, groupedByIssues, index, setIsIssueOpen, properties, setPreloadedData, bgColor = "#0f2b16", stateId, createdBy, }) => { // Collapse/Expand const [show, setState] = useState(true); // Edit state name const [showInput, setInput] = useState(false); if (selectedGroup === "priority") groupTitle === "high" ? (bgColor = "#dc2626") : groupTitle === "medium" ? (bgColor = "#f97316") : groupTitle === "low" ? (bgColor = "#22c55e") : (bgColor = "#ff0000"); return ( {(provided, snapshot) => (
{showInput ? null : (

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

{groupedByIssues[groupTitle].length}
)}
{(provided, snapshot) => (
{groupedByIssues[groupTitle].map((childIssue, index: number) => ( {(provided, snapshot) => (
{childIssue.name} {Object.keys(properties).map( (key) => properties[key as keyof Properties] && !Array.isArray(childIssue[key as keyof IIssue]) && (
{key === "start_date" && childIssue.start_date !== null && ( {renderShortNumericDateFormat(childIssue.start_date)} - {childIssue.target_date ? renderShortNumericDateFormat(childIssue.target_date) : "None"} )} {key === "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"} )} )} {key === "key" && ( {childIssue.project_detail?.identifier}- {childIssue.sequence_id} )} {key === "state" && ( <>{addSpaceIfCamelCase(childIssue["state_detail"].name)} )} {key === "priority" && <>{childIssue.priority}} {key === "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. )}
) : null}
) )}
)}
))} {provided.placeholder}
)}
)}
); }; export default SingleBoard;