2022-12-16 16:20:09 +00:00
|
|
|
// react
|
|
|
|
import { useState } from "react";
|
|
|
|
// components
|
|
|
|
import SingleStat from "components/project/cycles/stats-view/single-stat";
|
|
|
|
import ConfirmCycleDeletion from "components/project/cycles/confirm-cycle-deletion";
|
2022-12-15 04:17:56 +00:00
|
|
|
// types
|
2022-12-16 16:20:09 +00:00
|
|
|
import { ICycle, SelectSprintType } from "types";
|
2022-12-15 04:17:56 +00:00
|
|
|
|
|
|
|
type Props = {
|
|
|
|
cycles: ICycle[];
|
2022-12-16 16:20:09 +00:00
|
|
|
setCreateUpdateCycleModal: React.Dispatch<React.SetStateAction<boolean>>;
|
|
|
|
setSelectedCycle: React.Dispatch<React.SetStateAction<SelectSprintType>>;
|
2022-12-15 04:17:56 +00:00
|
|
|
};
|
|
|
|
|
2022-12-16 16:20:09 +00:00
|
|
|
const CycleStatsView: React.FC<Props> = ({
|
|
|
|
cycles,
|
|
|
|
setCreateUpdateCycleModal,
|
|
|
|
setSelectedCycle,
|
|
|
|
}) => {
|
|
|
|
const [selectedCycleForDelete, setSelectedCycleForDelete] = useState<SelectSprintType>();
|
|
|
|
const [cycleDeleteModal, setCycleDeleteModal] = useState(false);
|
|
|
|
|
|
|
|
const handleDeleteCycle = (cycle: ICycle) => {
|
|
|
|
setSelectedCycleForDelete({ ...cycle, actionType: "delete" });
|
|
|
|
setCycleDeleteModal(true);
|
|
|
|
};
|
|
|
|
|
|
|
|
const handleEditCycle = (cycle: ICycle) => {
|
|
|
|
setSelectedCycle({ ...cycle, actionType: "edit" });
|
|
|
|
setCreateUpdateCycleModal(true);
|
|
|
|
};
|
|
|
|
|
2022-12-15 04:17:56 +00:00
|
|
|
return (
|
|
|
|
<>
|
2022-12-16 16:20:09 +00:00
|
|
|
<ConfirmCycleDeletion
|
|
|
|
isOpen={
|
|
|
|
cycleDeleteModal &&
|
|
|
|
!!selectedCycleForDelete &&
|
|
|
|
selectedCycleForDelete.actionType === "delete"
|
|
|
|
}
|
|
|
|
setIsOpen={setCycleDeleteModal}
|
|
|
|
data={selectedCycleForDelete}
|
|
|
|
/>
|
2022-12-15 04:17:56 +00:00
|
|
|
{cycles.map((cycle) => (
|
2022-12-16 16:20:09 +00:00
|
|
|
<SingleStat
|
|
|
|
key={cycle.id}
|
|
|
|
cycle={cycle}
|
|
|
|
handleDeleteCycle={() => handleDeleteCycle(cycle)}
|
|
|
|
handleEditCycle={() => handleEditCycle(cycle)}
|
|
|
|
/>
|
2022-12-15 04:17:56 +00:00
|
|
|
))}
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default CycleStatsView;
|