forked from github/plane
3c2f5d12ed
* chore: add next theme and initial setup * chore: add dark mode colors to layouts * chore: user general setting page theming * chore: dashboard theming * chore: project page theming * chore: workspace setting page theming * chore: my issue page theming * chore: cmdk theming * chore: change hardcode bg and text color to theme * chore: change color name according to the design * style: fix card in the dashboard * style: fix merge conflict design issues * style: add light high contrast and dark high contrast * style: fix cmd k menu color and selection * feat: change theme from cmdk menu * chore: add multiple theme field to custom theme * chore: removed custom theming * fix: build error --------- Co-authored-by: Saheb Giri <iamsahebgiri@gmail.com>
89 lines
2.9 KiB
TypeScript
89 lines
2.9 KiB
TypeScript
import { useState } from "react";
|
|
|
|
// components
|
|
import { DeleteCycleModal, SingleCycleCard } 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 CyclesList: React.FC<TCycleStatsViewProps> = ({
|
|
cycles,
|
|
setCreateUpdateCycleModal,
|
|
setSelectedCycle,
|
|
type,
|
|
}) => {
|
|
const [cycleDeleteModal, setCycleDeleteModal] = useState(false);
|
|
const [selectedCycleForDelete, setSelectedCycleForDelete] = useState<SelectCycleType>();
|
|
const [showNoCurrentCycleMessage, setShowNoCurrentCycleMessage] = useState(true);
|
|
|
|
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 className="grid grid-cols-1 gap-9 md:grid-cols-2 lg:grid-cols-3">
|
|
{cycles.map((cycle) => (
|
|
<SingleCycleCard
|
|
key={cycle.id}
|
|
cycle={cycle}
|
|
handleDeleteCycle={() => handleDeleteCycle(cycle)}
|
|
handleEditCycle={() => handleEditCycle(cycle)}
|
|
/>
|
|
))}
|
|
</div>
|
|
) : type === "current" ? (
|
|
showNoCurrentCycleMessage && (
|
|
<div className="flex items-center justify-between bg-brand-surface-2 w-full px-6 py-4 rounded-[10px]">
|
|
<h3 className="text-base font-medium text-brand-base "> No current cycle is present.</h3>
|
|
<button onClick={() => setShowNoCurrentCycleMessage(false)}>
|
|
<XMarkIcon className="h-4 w-4" />
|
|
</button>
|
|
</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>
|
|
)}
|
|
</>
|
|
);
|
|
};
|