import { observer } from "mobx-react-lite"; import { useRouter } from "next/router"; import useSWR from "swr"; // components import { ActiveCycleInfo } from "components/cycles"; // services import { CycleService } from "services/cycle.service"; const cycleService = new CycleService(); // hooks import { useWorkspace } from "hooks/store"; // helpers import { renderEmoji } from "helpers/emoji.helper"; export const WorkspaceActiveCyclesList = observer(() => { // router const router = useRouter(); const { workspaceSlug } = router.query; // fetching active cycles in workspace const { data } = useSWR("WORKSPACE_ACTIVE_CYCLES", () => cycleService.workspaceActiveCycles(workspaceSlug as string)); // store const { workspaceActiveCyclesSearchQuery } = useWorkspace(); // filter cycles based on search query const filteredCycles = data?.filter( (cycle) => cycle.project_detail.name.toLowerCase().includes(workspaceActiveCyclesSearchQuery.toLowerCase()) || cycle.project_detail.identifier?.toLowerCase().includes(workspaceActiveCyclesSearchQuery.toLowerCase()) || cycle.name.toLowerCase().includes(workspaceActiveCyclesSearchQuery.toLowerCase()) ); return (
{workspaceSlug && filteredCycles && filteredCycles.map((cycle) => (
{cycle.project_detail.emoji ? ( {renderEmoji(cycle.project_detail.emoji)} ) : cycle.project_detail.icon_prop ? (
{renderEmoji(cycle.project_detail.icon_prop)}
) : ( {cycle.project_detail?.name.charAt(0)} )}

{cycle.project_detail.name}

))}
); });