mirror of
https://github.com/makeplane/plane
synced 2024-06-14 14:31:34 +00:00
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>
102 lines
3.3 KiB
TypeScript
102 lines
3.3 KiB
TypeScript
import { useState } from "react";
|
|
|
|
import { useRouter } from "next/router";
|
|
|
|
import useSWR from "swr";
|
|
|
|
// services
|
|
import cyclesService from "services/cycles.service";
|
|
// components
|
|
import { DeleteCycleModal, SingleCycleCard } from "components/cycles";
|
|
// icons
|
|
import { CompletedCycleIcon, ExclamationIcon } from "components/icons";
|
|
// types
|
|
import { ICycle, SelectCycleType } from "types";
|
|
// fetch-keys
|
|
import { CYCLE_COMPLETE_LIST } from "constants/fetch-keys";
|
|
import { EmptyState, Loader } from "components/ui";
|
|
// image
|
|
import emptyCycle from "public/empty-state/empty-cycle.svg";
|
|
|
|
export interface CompletedCyclesListProps {
|
|
setCreateUpdateCycleModal: React.Dispatch<React.SetStateAction<boolean>>;
|
|
setSelectedCycle: React.Dispatch<React.SetStateAction<SelectCycleType>>;
|
|
}
|
|
|
|
export const CompletedCyclesList: React.FC<CompletedCyclesListProps> = ({
|
|
setCreateUpdateCycleModal,
|
|
setSelectedCycle,
|
|
}) => {
|
|
const [cycleDeleteModal, setCycleDeleteModal] = useState(false);
|
|
const [selectedCycleForDelete, setSelectedCycleForDelete] = useState<SelectCycleType>();
|
|
|
|
const router = useRouter();
|
|
const { workspaceSlug, projectId } = router.query;
|
|
|
|
const { data: completedCycles } = useSWR(
|
|
workspaceSlug && projectId ? CYCLE_COMPLETE_LIST(projectId as string) : null,
|
|
workspaceSlug && projectId
|
|
? () => cyclesService.getCompletedCycles(workspaceSlug as string, projectId as string)
|
|
: null
|
|
);
|
|
|
|
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}
|
|
/>
|
|
{completedCycles ? (
|
|
completedCycles.completed_cycles.length > 0 ? (
|
|
<div className="flex flex-col gap-4">
|
|
<div className="flex items-center gap-2 text-sm text-brand-secondary">
|
|
<ExclamationIcon height={14} width={14} />
|
|
<span>Completed cycles are not editable.</span>
|
|
</div>
|
|
<div className="grid grid-cols-1 gap-9 md:grid-cols-2 lg:grid-cols-3">
|
|
{completedCycles.completed_cycles.map((cycle) => (
|
|
<SingleCycleCard
|
|
key={cycle.id}
|
|
cycle={cycle}
|
|
handleDeleteCycle={() => handleDeleteCycle(cycle)}
|
|
handleEditCycle={() => handleEditCycle(cycle)}
|
|
isCompleted
|
|
/>
|
|
))}
|
|
</div>
|
|
</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.Item height="200px" />
|
|
<Loader.Item height="200px" />
|
|
</Loader>
|
|
)}
|
|
</>
|
|
);
|
|
};
|