forked from github/plane
5916d6e749
* fix: cycle and module sidebar scroll * style: date picker theming * style: workspace slug spacing * fix: app sidebar z-index * fix: favorite cycle mutation * fix: cycle modal on error close * feat: cycle view context * style: active cycle stats scroll * fix: active cycle favorite mutation * feat: import export banner * feat: cycle sidebar date picker logic updated * fix: NaN in progress percentage fix * fix: tooltip fix * style: empty state for active cycle * style: cycle badge width fix , all cycle empty state fix and cycle icon size fix
87 lines
2.7 KiB
TypeScript
87 lines
2.7 KiB
TypeScript
import { useState } from "react";
|
|
|
|
// components
|
|
import { DeleteCycleModal, SingleCycleList } from "components/cycles";
|
|
import { EmptyState, Loader } from "components/ui";
|
|
// image
|
|
import emptyCycle from "public/empty-state/empty-cycle.svg";
|
|
// icon
|
|
import { XMarkIcon } from "@heroicons/react/24/outline";
|
|
// types
|
|
import { ICycle, SelectCycleType } from "types";
|
|
|
|
type TCycleStatsViewProps = {
|
|
cycles: ICycle[] | undefined;
|
|
setCreateUpdateCycleModal: React.Dispatch<React.SetStateAction<boolean>>;
|
|
setSelectedCycle: React.Dispatch<React.SetStateAction<SelectCycleType>>;
|
|
type: "current" | "upcoming" | "draft";
|
|
};
|
|
|
|
export const AllCyclesList: React.FC<TCycleStatsViewProps> = ({
|
|
cycles,
|
|
setCreateUpdateCycleModal,
|
|
setSelectedCycle,
|
|
type,
|
|
}) => {
|
|
const [cycleDeleteModal, setCycleDeleteModal] = useState(false);
|
|
const [selectedCycleForDelete, setSelectedCycleForDelete] = useState<SelectCycleType>();
|
|
|
|
const handleDeleteCycle = (cycle: ICycle) => {
|
|
setSelectedCycleForDelete({ ...cycle, actionType: "delete" });
|
|
setCycleDeleteModal(true);
|
|
};
|
|
|
|
const handleEditCycle = (cycle: ICycle) => {
|
|
setSelectedCycle({ ...cycle, actionType: "edit" });
|
|
setCreateUpdateCycleModal(true);
|
|
};
|
|
|
|
return (
|
|
<>
|
|
<DeleteCycleModal
|
|
isOpen={
|
|
cycleDeleteModal &&
|
|
!!selectedCycleForDelete &&
|
|
selectedCycleForDelete.actionType === "delete"
|
|
}
|
|
setIsOpen={setCycleDeleteModal}
|
|
data={selectedCycleForDelete}
|
|
/>
|
|
{cycles ? (
|
|
cycles.length > 0 ? (
|
|
<div>
|
|
{cycles.map((cycle) => (
|
|
<div className="hover:bg-brand-surface-2">
|
|
<div className="flex flex-col border-brand-base">
|
|
<SingleCycleList
|
|
key={cycle.id}
|
|
cycle={cycle}
|
|
handleDeleteCycle={() => handleDeleteCycle(cycle)}
|
|
handleEditCycle={() => handleEditCycle(cycle)}
|
|
/>
|
|
</div>
|
|
</div>
|
|
))}
|
|
</div>
|
|
) : type === "current" ? (
|
|
<div className="flex w-full items-center justify-start rounded-[10px] bg-brand-surface-2 px-6 py-4">
|
|
<h3 className="text-base font-medium text-brand-base ">No cycle is present.</h3>
|
|
</div>
|
|
) : (
|
|
<EmptyState
|
|
type="cycle"
|
|
title="Create New Cycle"
|
|
description="Sprint more effectively with Cycles by confining your project
|
|
to a fixed amount of time. Create new cycle now."
|
|
imgURL={emptyCycle}
|
|
/>
|
|
)
|
|
) : (
|
|
<Loader className="grid grid-cols-1 gap-9 md:grid-cols-2 lg:grid-cols-3">
|
|
<Loader.Item height="200px" />
|
|
</Loader>
|
|
)}
|
|
</>
|
|
);
|
|
};
|