feat: date range status function added
This commit is contained in:
parent
8a941d0d14
commit
02e4e58f19
3 changed files with 18 additions and 34 deletions
|
|
@ -25,6 +25,7 @@ import { CustomMenu, EmptySpace, EmptySpaceItem, Spinner } from "components/ui";
|
|||
import { BreadcrumbItem, Breadcrumbs } from "components/breadcrumbs";
|
||||
// helpers
|
||||
import { truncateText } from "helpers/string.helper";
|
||||
import { getDateRangeStatus } from "helpers/date-time.helper";
|
||||
// types
|
||||
import { CycleIssueResponse, UserAuth } from "types";
|
||||
// fetch-keys
|
||||
|
|
@ -34,8 +35,6 @@ import {
|
|||
PROJECT_ISSUES_LIST,
|
||||
PROJECT_DETAILS,
|
||||
CYCLE_DETAILS,
|
||||
CYCLE_COMPLETE_LIST,
|
||||
CYCLE_CURRENT_AND_UPCOMING_LIST,
|
||||
} from "constants/fetch-keys";
|
||||
|
||||
const SingleCycle: React.FC<UserAuth> = (props) => {
|
||||
|
|
@ -80,38 +79,9 @@ const SingleCycle: React.FC<UserAuth> = (props) => {
|
|||
: null
|
||||
);
|
||||
|
||||
const { data: currentAndUpcomingCycles } = useSWR(
|
||||
workspaceSlug && projectId ? CYCLE_CURRENT_AND_UPCOMING_LIST(projectId as string) : null,
|
||||
workspaceSlug && projectId
|
||||
? () =>
|
||||
cycleServices.getCurrentAndUpcomingCycles(workspaceSlug as string, projectId as string)
|
||||
: null
|
||||
);
|
||||
|
||||
const { data: completedCycles } = useSWR(
|
||||
workspaceSlug && projectId ? CYCLE_COMPLETE_LIST(projectId as string) : null,
|
||||
workspaceSlug && projectId
|
||||
? () => cycleServices.getCompletedCycles(workspaceSlug as string, projectId as string)
|
||||
: null
|
||||
);
|
||||
|
||||
const checkForInProgress = currentAndUpcomingCycles?.current_cycle?.filter(
|
||||
(c) => c.id === cycleDetails?.id
|
||||
);
|
||||
const checkForUpcoming = currentAndUpcomingCycles?.upcoming_cycle?.filter(
|
||||
(c) => c.id === cycleDetails?.id
|
||||
);
|
||||
const checkForInCompleted = completedCycles?.completed_cycles?.filter(
|
||||
(c) => c.id === cycleDetails?.id
|
||||
);
|
||||
|
||||
const cycleStatus =
|
||||
checkForInCompleted && checkForInCompleted.length > 0
|
||||
? "completed"
|
||||
: checkForInProgress && checkForInProgress.length > 0
|
||||
? "current"
|
||||
: checkForUpcoming && checkForUpcoming.length > 0
|
||||
? "upcoming"
|
||||
cycleDetails?.start_date && cycleDetails?.end_date
|
||||
? getDateRangeStatus(cycleDetails?.start_date, cycleDetails?.end_date)
|
||||
: "draft";
|
||||
|
||||
const { data: cycleIssues } = useSWR<CycleIssueResponse[]>(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue