// react import React, { useState } from "react"; // next import Link from "next/link"; import Image from "next/image"; // swr import useSWR from "swr"; // services import cycleServices from "lib/services/cycles.service"; // hooks import useUser from "lib/hooks/useUser"; // ui import { Spinner } from "ui"; // icons import { ArrowsPointingInIcon, ArrowsPointingOutIcon, CalendarDaysIcon, PlusIcon, EllipsisHorizontalIcon, TrashIcon, } from "@heroicons/react/24/outline"; import User from "public/user.png"; // types import { CycleIssueResponse, ICycle, IIssue, IWorkspaceMember, NestedKeyOf, Properties, } from "types"; // constants import { CYCLE_ISSUES, WORKSPACE_MEMBERS } from "constants/fetch-keys"; import { addSpaceIfCamelCase, findHowManyDaysLeft, renderShortNumericDateFormat, } from "constants/common"; import { Menu, Transition } from "@headlessui/react"; import workspaceService from "lib/services/workspace.service"; 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; }; const SingleCycleBoard: React.FC = ({ properties, groupedByIssues, selectedGroup, groupTitle, createdBy, bgColor, openCreateIssueModal, openIssuesListModal, removeIssueFromCycle, }) => { // Collapse/Expand const [show, setState] = useState(true); const { activeWorkspace, activeProject } = 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 (

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

{groupedByIssues[groupTitle].length}
{(active) => ( )} {(active) => ( )}
{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 (
{properties.key && (
{activeProject?.identifier}-{childIssue.sequence_id}
)}
{childIssue.name}
{properties.priority && (
{/* {getPriorityIcon(childIssue.priority ?? "")} */} {childIssue.priority ?? "None"}
Priority
{childIssue.priority ?? "None"}
)} {properties.state && (
{addSpaceIfCamelCase(childIssue.state_detail.name)}
State
{childIssue.state_detail.name}
)} {properties.start_date && (
{childIssue.start_date ? renderShortNumericDateFormat(childIssue.start_date) : "N/A"}
Started at
{renderShortNumericDateFormat(childIssue.start_date ?? "")}
)} {properties.target_date && (
{childIssue.target_date ? renderShortNumericDateFormat(childIssue.target_date) : "N/A"}
Target date
{renderShortNumericDateFormat(childIssue.target_date ?? "")}
{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 user
)}
Assigned to
{childIssue.assignee_details?.length > 0 ? childIssue.assignee_details .map((assignee) => assignee.first_name) .join(", ") : "No one"}
)}
); })}
); }; export default SingleCycleBoard;