2024-03-11 15:30:05 +00:00
|
|
|
import { FC } from "react";
|
|
|
|
import { observer } from "mobx-react-lite";
|
2024-03-19 14:38:35 +00:00
|
|
|
import { Disclosure } from "@headlessui/react";
|
2024-03-11 15:30:05 +00:00
|
|
|
// components
|
2024-04-30 11:51:24 +00:00
|
|
|
import { ListLayout } from "@/components/core/list";
|
2024-05-14 13:52:08 +00:00
|
|
|
import { ActiveCycleRoot, CycleListGroupHeader, CyclePeekOverview, CyclesListMap } from "@/components/cycles";
|
2024-03-11 15:30:05 +00:00
|
|
|
|
|
|
|
export interface ICyclesList {
|
|
|
|
completedCycleIds: string[];
|
2024-05-14 13:52:08 +00:00
|
|
|
upcomingCycleIds?: string[] | undefined;
|
2024-03-11 15:30:05 +00:00
|
|
|
cycleIds: string[];
|
|
|
|
workspaceSlug: string;
|
|
|
|
projectId: string;
|
2024-03-20 15:32:58 +00:00
|
|
|
isArchived?: boolean;
|
2024-03-11 15:30:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export const CyclesList: FC<ICyclesList> = observer((props) => {
|
2024-05-14 13:52:08 +00:00
|
|
|
const { completedCycleIds, upcomingCycleIds, cycleIds, workspaceSlug, projectId, isArchived = false } = props;
|
2024-03-11 15:30:05 +00:00
|
|
|
|
|
|
|
return (
|
2024-05-14 13:52:08 +00:00
|
|
|
<div className="flex h-full w-full justify-between ">
|
|
|
|
<ListLayout>
|
|
|
|
{isArchived ? (
|
|
|
|
<>
|
|
|
|
<CyclesListMap cycleIds={cycleIds} projectId={projectId} workspaceSlug={workspaceSlug} />
|
|
|
|
</>
|
|
|
|
) : (
|
|
|
|
<>
|
|
|
|
<ActiveCycleRoot workspaceSlug={workspaceSlug.toString()} projectId={projectId.toString()} />
|
|
|
|
|
|
|
|
{upcomingCycleIds && (
|
|
|
|
<Disclosure as="div" className="flex flex-shrink-0 flex-col" defaultOpen>
|
2024-03-11 15:30:05 +00:00
|
|
|
{({ open }) => (
|
|
|
|
<>
|
2024-05-14 13:52:08 +00:00
|
|
|
<Disclosure.Button className="sticky top-0 z-[2] w-full flex-shrink-0 border-b border-custom-border-200 bg-custom-background-90 px-7 py-1 cursor-pointer">
|
|
|
|
<CycleListGroupHeader
|
|
|
|
title="Upcoming cycle"
|
|
|
|
type="upcoming"
|
|
|
|
count={upcomingCycleIds.length}
|
|
|
|
showCount
|
|
|
|
isExpanded={open}
|
|
|
|
/>
|
|
|
|
</Disclosure.Button>
|
|
|
|
<Disclosure.Panel>
|
|
|
|
<CyclesListMap cycleIds={upcomingCycleIds} projectId={projectId} workspaceSlug={workspaceSlug} />
|
|
|
|
</Disclosure.Panel>
|
2024-03-11 15:30:05 +00:00
|
|
|
</>
|
|
|
|
)}
|
2024-05-14 13:52:08 +00:00
|
|
|
</Disclosure>
|
|
|
|
)}
|
|
|
|
|
|
|
|
<Disclosure as="div" className="flex flex-shrink-0 flex-col pb-7">
|
|
|
|
{({ open }) => (
|
|
|
|
<>
|
|
|
|
<Disclosure.Button className="sticky top-0 z-[2] w-full flex-shrink-0 border-b border-custom-border-200 bg-custom-background-90 px-7 py-1 cursor-pointer">
|
|
|
|
<CycleListGroupHeader
|
|
|
|
title="Completed cycle"
|
|
|
|
type="completed"
|
|
|
|
count={completedCycleIds.length}
|
|
|
|
showCount
|
|
|
|
isExpanded={open}
|
|
|
|
/>
|
|
|
|
</Disclosure.Button>
|
|
|
|
<Disclosure.Panel>
|
|
|
|
<CyclesListMap cycleIds={completedCycleIds} projectId={projectId} workspaceSlug={workspaceSlug} />
|
|
|
|
</Disclosure.Panel>
|
|
|
|
</>
|
|
|
|
)}
|
2024-03-11 15:30:05 +00:00
|
|
|
</Disclosure>
|
2024-05-14 13:52:08 +00:00
|
|
|
</>
|
|
|
|
)}
|
|
|
|
</ListLayout>
|
|
|
|
<CyclePeekOverview projectId={projectId} workspaceSlug={workspaceSlug} isArchived={isArchived} />
|
2024-03-11 15:30:05 +00:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
});
|