chore: update cycle fetch keys names

This commit is contained in:
Aaryan Khandelwal 2023-05-29 02:38:16 +05:30
parent 053ebc031d
commit 1c98f2dca9
15 changed files with 97 additions and 97 deletions

View File

@ -42,7 +42,7 @@ import { truncateText } from "helpers/string.helper";
// types
import { ICycle, IIssue } from "types";
// fetch-keys
import { CYCLE_CURRENT_LIST, CYCLE_ISSUES, CYCLE_LIST } from "constants/fetch-keys";
import { CURRENT_CYCLE_LIST, CYCLES_LIST, CYCLE_ISSUES } from "constants/fetch-keys";
type TSingleStatProps = {
cycle: ICycle;
@ -100,7 +100,7 @@ export const ActiveCycleDetails: React.FC<TSingleStatProps> = ({ cycle, isComple
if (!workspaceSlug || !projectId || !cycle) return;
mutate<ICycle[]>(
CYCLE_CURRENT_LIST(projectId as string),
CURRENT_CYCLE_LIST(projectId as string),
(prevData) =>
(prevData ?? []).map((c) => ({
...c,
@ -110,7 +110,7 @@ export const ActiveCycleDetails: React.FC<TSingleStatProps> = ({ cycle, isComple
);
mutate(
CYCLE_LIST(projectId as string),
CYCLES_LIST(projectId as string),
(prevData: any) =>
(prevData ?? []).map((c: any) => ({
...c,
@ -136,7 +136,7 @@ export const ActiveCycleDetails: React.FC<TSingleStatProps> = ({ cycle, isComple
if (!workspaceSlug || !projectId || !cycle) return;
mutate<ICycle[]>(
CYCLE_CURRENT_LIST(projectId as string),
CURRENT_CYCLE_LIST(projectId as string),
(prevData) =>
(prevData ?? []).map((c) => ({
...c,
@ -146,7 +146,7 @@ export const ActiveCycleDetails: React.FC<TSingleStatProps> = ({ cycle, isComple
);
mutate(
CYCLE_LIST(projectId as string),
CYCLES_LIST(projectId as string),
(prevData: any) =>
(prevData ?? []).map((c: any) => ({
...c,

View File

@ -7,7 +7,7 @@ import cyclesService from "services/cycles.service";
// components
import { CyclesView } from "components/cycles";
// fetch-keys
import { CYCLE_LIST } from "constants/fetch-keys";
import { CYCLES_LIST } from "constants/fetch-keys";
type Props = {
viewType: string | null;
@ -18,7 +18,7 @@ export const AllCyclesList: React.FC<Props> = ({ viewType }) => {
const { workspaceSlug, projectId } = router.query;
const { data: allCyclesList } = useSWR(
workspaceSlug && projectId ? CYCLE_LIST(projectId.toString()) : null,
workspaceSlug && projectId ? CYCLES_LIST(projectId.toString()) : null,
workspaceSlug && projectId
? () =>
cyclesService.getCyclesWithParams(workspaceSlug.toString(), projectId.toString(), {

View File

@ -7,7 +7,7 @@ import cyclesService from "services/cycles.service";
// components
import { CyclesView } from "components/cycles";
// fetch-keys
import { CYCLE_COMPLETE_LIST } from "constants/fetch-keys";
import { COMPLETED_CYCLES_LIST } from "constants/fetch-keys";
type Props = {
viewType: string | null;
@ -18,7 +18,7 @@ export const CompletedCyclesList: React.FC<Props> = ({ viewType }) => {
const { workspaceSlug, projectId } = router.query;
const { data: completedCyclesList } = useSWR(
workspaceSlug && projectId ? CYCLE_COMPLETE_LIST(projectId.toString()) : null,
workspaceSlug && projectId ? COMPLETED_CYCLES_LIST(projectId.toString()) : null,
workspaceSlug && projectId
? () =>
cyclesService.getCyclesWithParams(workspaceSlug.toString(), projectId.toString(), {

View File

@ -7,7 +7,7 @@ import cyclesService from "services/cycles.service";
// components
import { CyclesView } from "components/cycles";
// fetch-keys
import { CYCLE_DRAFT_LIST } from "constants/fetch-keys";
import { DRAFT_CYCLES_LIST } from "constants/fetch-keys";
type Props = {
viewType: string | null;
@ -18,7 +18,7 @@ export const DraftCyclesList: React.FC<Props> = ({ viewType }) => {
const { workspaceSlug, projectId } = router.query;
const { data: draftCyclesList } = useSWR(
workspaceSlug && projectId ? CYCLE_DRAFT_LIST(projectId.toString()) : null,
workspaceSlug && projectId ? DRAFT_CYCLES_LIST(projectId.toString()) : null,
workspaceSlug && projectId
? () =>
cyclesService.getCyclesWithParams(workspaceSlug.toString(), projectId.toString(), {

View File

@ -7,7 +7,7 @@ import cyclesService from "services/cycles.service";
// components
import { CyclesView } from "components/cycles";
// fetch-keys
import { CYCLE_UPCOMING_LIST } from "constants/fetch-keys";
import { UPCOMING_CYCLES_LIST } from "constants/fetch-keys";
type Props = {
viewType: string | null;
@ -18,7 +18,7 @@ export const UpcomingCyclesList: React.FC<Props> = ({ viewType }) => {
const { workspaceSlug, projectId } = router.query;
const { data: upcomingCyclesList } = useSWR(
workspaceSlug && projectId ? CYCLE_UPCOMING_LIST(projectId.toString()) : null,
workspaceSlug && projectId ? UPCOMING_CYCLES_LIST(projectId.toString()) : null,
workspaceSlug && projectId
? () =>
cyclesService.getCyclesWithParams(workspaceSlug.toString(), projectId.toString(), {

View File

@ -26,11 +26,11 @@ import { getDateRangeStatus } from "helpers/date-time.helper";
import { ICycle } from "types";
// fetch-keys
import {
CYCLE_COMPLETE_LIST,
CYCLE_CURRENT_LIST,
CYCLE_DRAFT_LIST,
CYCLE_LIST,
CYCLE_UPCOMING_LIST,
COMPLETED_CYCLES_LIST,
CURRENT_CYCLE_LIST,
CYCLES_LIST,
DRAFT_CYCLES_LIST,
UPCOMING_CYCLES_LIST,
} from "constants/fetch-keys";
type Props = {
@ -67,12 +67,12 @@ export const CyclesView: React.FC<Props> = ({ cycles, viewType }) => {
const fetchKey =
cycleStatus === "current"
? CYCLE_CURRENT_LIST(projectId as string)
? CURRENT_CYCLE_LIST(projectId as string)
: cycleStatus === "upcoming"
? CYCLE_UPCOMING_LIST(projectId as string)
? UPCOMING_CYCLES_LIST(projectId as string)
: cycleStatus === "completed"
? CYCLE_COMPLETE_LIST(projectId as string)
: CYCLE_DRAFT_LIST(projectId as string);
? COMPLETED_CYCLES_LIST(projectId as string)
: DRAFT_CYCLES_LIST(projectId as string);
mutate<ICycle[]>(
fetchKey,
@ -85,7 +85,7 @@ export const CyclesView: React.FC<Props> = ({ cycles, viewType }) => {
);
mutate(
CYCLE_LIST(projectId as string),
CYCLES_LIST(projectId as string),
(prevData: any) =>
(prevData ?? []).map((c: any) => ({
...c,
@ -114,12 +114,12 @@ export const CyclesView: React.FC<Props> = ({ cycles, viewType }) => {
const fetchKey =
cycleStatus === "current"
? CYCLE_CURRENT_LIST(projectId as string)
? CURRENT_CYCLE_LIST(projectId as string)
: cycleStatus === "upcoming"
? CYCLE_UPCOMING_LIST(projectId as string)
? UPCOMING_CYCLES_LIST(projectId as string)
: cycleStatus === "completed"
? CYCLE_COMPLETE_LIST(projectId as string)
: CYCLE_DRAFT_LIST(projectId as string);
? COMPLETED_CYCLES_LIST(projectId as string)
: DRAFT_CYCLES_LIST(projectId as string);
mutate<ICycle[]>(
fetchKey,
@ -132,7 +132,7 @@ export const CyclesView: React.FC<Props> = ({ cycles, viewType }) => {
);
mutate(
CYCLE_LIST(projectId as string),
CYCLES_LIST(projectId as string),
(prevData: any) =>
(prevData ?? []).map((c: any) => ({
...c,

View File

@ -22,11 +22,11 @@ type TConfirmCycleDeletionProps = {
};
// fetch-keys
import {
CYCLE_COMPLETE_LIST,
CYCLE_CURRENT_LIST,
CYCLE_DRAFT_LIST,
CYCLE_LIST,
CYCLE_UPCOMING_LIST,
COMPLETED_CYCLES_LIST,
CURRENT_CYCLE_LIST,
CYCLES_LIST,
DRAFT_CYCLES_LIST,
UPCOMING_CYCLES_LIST,
} from "constants/fetch-keys";
import { getDateRangeStatus } from "helpers/date-time.helper";
@ -58,12 +58,12 @@ export const DeleteCycleModal: React.FC<TConfirmCycleDeletionProps> = ({
const cycleType = getDateRangeStatus(data.start_date, data.end_date);
const fetchKey =
cycleType === "current"
? CYCLE_CURRENT_LIST(projectId as string)
? CURRENT_CYCLE_LIST(projectId as string)
: cycleType === "upcoming"
? CYCLE_UPCOMING_LIST(projectId as string)
? UPCOMING_CYCLES_LIST(projectId as string)
: cycleType === "completed"
? CYCLE_COMPLETE_LIST(projectId as string)
: CYCLE_DRAFT_LIST(projectId as string);
? COMPLETED_CYCLES_LIST(projectId as string)
: DRAFT_CYCLES_LIST(projectId as string);
mutate<ICycle[]>(
fetchKey,
@ -76,7 +76,7 @@ export const DeleteCycleModal: React.FC<TConfirmCycleDeletionProps> = ({
);
mutate(
CYCLE_LIST(projectId as string),
CYCLES_LIST(projectId as string),
(prevData: any) => {
if (!prevData) return;
return prevData.filter((cycle: any) => cycle.id !== data?.id);

View File

@ -12,7 +12,7 @@ type Props = {
handleFormSubmit: (values: Partial<ICycle>) => Promise<void>;
handleClose: () => void;
status: boolean;
data?: ICycle;
data?: ICycle | null;
};
const defaultValues: Partial<ICycle> = {
@ -28,7 +28,6 @@ export const CycleForm: React.FC<Props> = ({ handleFormSubmit, handleClose, stat
formState: { errors, isSubmitting },
handleSubmit,
control,
watch,
reset,
} = useForm<ICycle>({
defaultValues,

View File

@ -18,12 +18,12 @@ import { getDateRangeStatus, isDateGreaterThanToday } from "helpers/date-time.he
import type { ICycle } from "types";
// fetch keys
import {
CYCLE_COMPLETE_LIST,
CYCLE_CURRENT_LIST,
CYCLE_DRAFT_LIST,
CYCLE_INCOMPLETE_LIST,
CYCLE_LIST,
CYCLE_UPCOMING_LIST,
COMPLETED_CYCLES_LIST,
CURRENT_CYCLE_LIST,
CYCLES_LIST,
DRAFT_CYCLES_LIST,
INCOMPLETE_CYCLES_LIST,
UPCOMING_CYCLES_LIST,
} from "constants/fetch-keys";
type CycleModalProps = {
@ -43,24 +43,26 @@ export const CreateUpdateCycleModal: React.FC<CycleModalProps> = ({
const { setToastAlert } = useToast();
const createCycle = async (payload: Partial<ICycle>) => {
if (!workspaceSlug || !projectId) return;
await cycleService
.createCycle(workspaceSlug as string, projectId as string, payload)
.createCycle(workspaceSlug.toString(), projectId.toString(), payload)
.then((res) => {
switch (getDateRangeStatus(res.start_date, res.end_date)) {
case "completed":
mutate(CYCLE_COMPLETE_LIST(projectId as string));
mutate(COMPLETED_CYCLES_LIST(projectId.toString()));
break;
case "current":
mutate(CYCLE_CURRENT_LIST(projectId as string));
mutate(CURRENT_CYCLE_LIST(projectId.toString()));
break;
case "upcoming":
mutate(CYCLE_UPCOMING_LIST(projectId as string));
mutate(UPCOMING_CYCLES_LIST(projectId.toString()));
break;
default:
mutate(CYCLE_DRAFT_LIST(projectId as string));
mutate(DRAFT_CYCLES_LIST(projectId.toString()));
}
mutate(CYCLE_INCOMPLETE_LIST(projectId as string));
mutate(CYCLE_LIST(projectId as string));
mutate(INCOMPLETE_CYCLES_LIST(projectId.toString()));
mutate(CYCLES_LIST(projectId.toString()));
handleClose();
setToastAlert({
@ -69,7 +71,7 @@ export const CreateUpdateCycleModal: React.FC<CycleModalProps> = ({
message: "Cycle created successfully.",
});
})
.catch((err) => {
.catch(() => {
setToastAlert({
type: "error",
title: "Error!",
@ -79,39 +81,41 @@ export const CreateUpdateCycleModal: React.FC<CycleModalProps> = ({
};
const updateCycle = async (cycleId: string, payload: Partial<ICycle>) => {
if (!workspaceSlug || !projectId) return;
await cycleService
.updateCycle(workspaceSlug as string, projectId as string, cycleId, payload)
.updateCycle(workspaceSlug.toString(), projectId.toString(), cycleId, payload)
.then((res) => {
switch (getDateRangeStatus(data?.start_date, data?.end_date)) {
case "completed":
mutate(CYCLE_COMPLETE_LIST(projectId as string));
mutate(COMPLETED_CYCLES_LIST(projectId.toString()));
break;
case "current":
mutate(CYCLE_CURRENT_LIST(projectId as string));
mutate(CURRENT_CYCLE_LIST(projectId.toString()));
break;
case "upcoming":
mutate(CYCLE_UPCOMING_LIST(projectId as string));
mutate(UPCOMING_CYCLES_LIST(projectId.toString()));
break;
default:
mutate(CYCLE_DRAFT_LIST(projectId as string));
mutate(DRAFT_CYCLES_LIST(projectId.toString()));
}
mutate(CYCLE_LIST(projectId as string));
mutate(CYCLES_LIST(projectId.toString()));
if (
getDateRangeStatus(data?.start_date, data?.end_date) !=
getDateRangeStatus(res.start_date, res.end_date)
) {
switch (getDateRangeStatus(res.start_date, res.end_date)) {
case "completed":
mutate(CYCLE_COMPLETE_LIST(projectId as string));
mutate(COMPLETED_CYCLES_LIST(projectId.toString()));
break;
case "current":
mutate(CYCLE_CURRENT_LIST(projectId as string));
mutate(CURRENT_CYCLE_LIST(projectId.toString()));
break;
case "upcoming":
mutate(CYCLE_UPCOMING_LIST(projectId as string));
mutate(UPCOMING_CYCLES_LIST(projectId.toString()));
break;
default:
mutate(CYCLE_DRAFT_LIST(projectId as string));
mutate(DRAFT_CYCLES_LIST(projectId.toString()));
}
}

View File

@ -14,7 +14,7 @@ import cycleServices from "services/cycles.service";
// components
import { CreateUpdateCycleModal } from "components/cycles";
// fetch-keys
import { CYCLE_LIST } from "constants/fetch-keys";
import { CYCLES_LIST } from "constants/fetch-keys";
export type IssueCycleSelectProps = {
projectId: string;
@ -36,7 +36,7 @@ export const CycleSelect: React.FC<IssueCycleSelectProps> = ({
const { workspaceSlug } = router.query;
const { data: cycles } = useSWR(
workspaceSlug && projectId ? CYCLE_LIST(projectId) : null,
workspaceSlug && projectId ? CYCLES_LIST(projectId) : null,
workspaceSlug && projectId
? () =>
cycleServices.getCyclesWithParams(workspaceSlug as string, projectId as string, {

View File

@ -10,16 +10,16 @@ import { Dialog, Transition } from "@headlessui/react";
import cyclesService from "services/cycles.service";
// hooks
import useToast from "hooks/use-toast";
import useIssuesView from "hooks/use-issues-view";
//icons
import { MagnifyingGlassIcon, XMarkIcon } from "@heroicons/react/24/outline";
import { ContrastIcon, CyclesIcon, ExclamationIcon, TransferIcon } from "components/icons";
import { ContrastIcon, ExclamationIcon, TransferIcon } from "components/icons";
// fetch-key
import { CYCLE_INCOMPLETE_LIST, CYCLE_ISSUES_WITH_PARAMS } from "constants/fetch-keys";
import { CYCLE_ISSUES_WITH_PARAMS, INCOMPLETE_CYCLES_LIST } from "constants/fetch-keys";
// types
import { ICycle } from "types";
//helper
import { getDateRangeStatus } from "helpers/date-time.helper";
import useIssuesView from "hooks/use-issues-view";
type Props = {
isOpen: boolean;
@ -57,7 +57,7 @@ export const TransferIssuesModal: React.FC<Props> = ({ isOpen, handleClose }) =>
};
const { data: incompleteCycles } = useSWR(
workspaceSlug && projectId ? CYCLE_INCOMPLETE_LIST(projectId as string) : null,
workspaceSlug && projectId ? INCOMPLETE_CYCLES_LIST(projectId as string) : null,
workspaceSlug && projectId
? () =>
cyclesService.getCyclesWithParams(workspaceSlug as string, projectId as string, {

View File

@ -16,7 +16,7 @@ import { ContrastIcon } from "components/icons";
// types
import { ICycle, IIssue, UserAuth } from "types";
// fetch-keys
import { CYCLE_ISSUES, CYCLE_INCOMPLETE_LIST, ISSUE_DETAILS } from "constants/fetch-keys";
import { CYCLE_ISSUES, INCOMPLETE_CYCLES_LIST, ISSUE_DETAILS } from "constants/fetch-keys";
type Props = {
issueDetail: IIssue | undefined;
@ -33,7 +33,7 @@ export const SidebarCycleSelect: React.FC<Props> = ({
const { workspaceSlug, projectId, issueId } = router.query;
const { data: incompleteCycles } = useSWR(
workspaceSlug && projectId ? CYCLE_INCOMPLETE_LIST(projectId as string) : null,
workspaceSlug && projectId ? INCOMPLETE_CYCLES_LIST(projectId as string) : null,
workspaceSlug && projectId
? () =>
cyclesService.getCyclesWithParams(workspaceSlug as string, projectId as string, {

View File

@ -71,9 +71,18 @@ export const PROJECT_ISSUE_LABELS = (projectId: string) =>
export const PROJECT_GITHUB_REPOSITORY = (projectId: string) =>
`PROJECT_GITHUB_REPOSITORY_${projectId.toUpperCase()}`;
export const CYCLE_LIST = (projectId: string) => `CYCLE_LIST_${projectId.toUpperCase()}`;
export const CYCLE_INCOMPLETE_LIST = (projectId: string) =>
`CYCLE_INCOMPLETE_LIST_${projectId.toUpperCase()}`;
// cycles
export const CYCLES_LIST = (projectId: string) => `CYCLE_LIST_${projectId.toUpperCase()}`;
export const INCOMPLETE_CYCLES_LIST = (projectId: string) =>
`INCOMPLETE_CYCLES_LIST_${projectId.toUpperCase()}`;
export const CURRENT_CYCLE_LIST = (projectId: string) =>
`CURRENT_CYCLE_LIST_${projectId.toUpperCase()}`;
export const UPCOMING_CYCLES_LIST = (projectId: string) =>
`UPCOMING_CYCLES_LIST_${projectId.toUpperCase()}`;
export const DRAFT_CYCLES_LIST = (projectId: string) =>
`DRAFT_CYCLES_LIST_${projectId.toUpperCase()}`;
export const COMPLETED_CYCLES_LIST = (projectId: string) =>
`COMPLETED_CYCLES_LIST_${projectId.toUpperCase()}`;
export const CYCLE_ISSUES = (cycleId: string) => `CYCLE_ISSUES_${cycleId.toUpperCase()}`;
export const CYCLE_ISSUES_WITH_PARAMS = (cycleId: string, params?: any) => {
if (!params) return `CYCLE_ISSUES_WITH_PARAMS_${cycleId.toUpperCase()}`;
@ -84,15 +93,6 @@ export const CYCLE_ISSUES_WITH_PARAMS = (cycleId: string, params?: any) => {
};
export const CYCLE_DETAILS = (cycleId: string) => `CYCLE_DETAILS_${cycleId.toUpperCase()}`;
export const CYCLE_CURRENT_LIST = (projectId: string) =>
`CYCLE_CURRENT_LIST${projectId.toUpperCase()}`;
export const CYCLE_UPCOMING_LIST = (projectId: string) =>
`CYCLE_UPCOMING_LIST${projectId.toUpperCase()}`;
export const CYCLE_DRAFT_LIST = (projectId: string) =>
`CYCLE_DRAFT_LIST_${projectId.toUpperCase()}`;
export const CYCLE_COMPLETE_LIST = (projectId: string) =>
`CYCLE_COMPLETE_LIST_${projectId.toUpperCase()}`;
export const STATES_LIST = (projectId: string) => `STATES_LIST_${projectId.toUpperCase()}`;
export const STATE_DETAILS = "STATE_DETAILS";

View File

@ -30,7 +30,7 @@ import { getDateRangeStatus } from "helpers/date-time.helper";
// fetch-keys
import {
CYCLE_ISSUES,
CYCLE_LIST,
CYCLES_LIST,
PROJECT_DETAILS,
CYCLE_DETAILS,
PROJECT_ISSUES_LIST,
@ -54,7 +54,7 @@ const SingleCycle: React.FC = () => {
);
const { data: cycles } = useSWR(
workspaceSlug && projectId ? CYCLE_LIST(projectId as string) : null,
workspaceSlug && projectId ? CYCLES_LIST(projectId as string) : null,
workspaceSlug && projectId
? () =>
cycleServices.getCyclesWithParams(workspaceSlug as string, projectId as string, {

View File

@ -23,17 +23,15 @@ import {
UpcomingCyclesList,
} from "components/cycles";
// ui
import { EmptyState, PrimaryButton } from "components/ui";
import { PrimaryButton } from "components/ui";
import { BreadcrumbItem, Breadcrumbs } from "components/breadcrumbs";
// icons
import { ListBulletIcon, PlusIcon, Squares2X2Icon } from "@heroicons/react/24/outline";
// images
import emptyCycle from "public/empty-state/empty-cycle.svg";
// types
import { SelectCycleType } from "types";
import type { NextPage } from "next";
// fetch-keys
import { PROJECT_DETAILS, CYCLE_CURRENT_LIST } from "constants/fetch-keys";
import { CURRENT_CYCLE_LIST, PROJECT_DETAILS } from "constants/fetch-keys";
const tabsList = ["All", "Active", "Upcoming", "Completed", "Drafts"];
@ -72,7 +70,7 @@ const ProjectCycles: NextPage = () => {
);
const { data: currentCycle } = useSWR(
workspaceSlug && projectId ? CYCLE_CURRENT_LIST(projectId as string) : null,
workspaceSlug && projectId ? CURRENT_CYCLE_LIST(projectId as string) : null,
workspaceSlug && projectId
? () =>
cycleService.getCyclesWithParams(workspaceSlug as string, projectId as string, {
@ -207,12 +205,11 @@ const ProjectCycles: NextPage = () => {
{currentCycle?.[0] ? (
<ActiveCycleDetails cycle={currentCycle?.[0]} />
) : (
<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}
/>
<div className="flex w-full items-center justify-start rounded-[10px] bg-brand-surface-2 px-6 py-4">
<h3 className="text-base font-medium text-brand-base ">
No active cycle is present.
</h3>
</div>
)}
</Tab.Panel>
)}