forked from github/plane
fix: incorrect dashboard tab (#3597)
* fix: incorrect dashboard tab * chore: added comments for the helper functions * style: updated tabs list UI * chore: default widget filters changed * fix: build errors --------- Co-authored-by: NarayanBavisetti <narayan3119@gmail.com>
This commit is contained in:
parent
4a145f7a06
commit
2e129682b7
33
apiserver/plane/db/migrations/0059_auto_20240208_0957.py
Normal file
33
apiserver/plane/db/migrations/0059_auto_20240208_0957.py
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
# Generated by Django 4.2.7 on 2024-02-08 09:57
|
||||||
|
|
||||||
|
from django.db import migrations
|
||||||
|
|
||||||
|
|
||||||
|
def widgets_filter_change(apps, schema_editor):
|
||||||
|
Widget = apps.get_model("db", "Widget")
|
||||||
|
widgets_to_update = []
|
||||||
|
|
||||||
|
# Define the filter dictionaries for each widget key
|
||||||
|
filters_mapping = {
|
||||||
|
"assigned_issues": {"duration": "none", "tab": "pending"},
|
||||||
|
"created_issues": {"duration": "none", "tab": "pending"},
|
||||||
|
"issues_by_state_groups": {"duration": "none"},
|
||||||
|
"issues_by_priority": {"duration": "none"},
|
||||||
|
}
|
||||||
|
|
||||||
|
# Iterate over widgets and update filters if applicable
|
||||||
|
for widget in Widget.objects.all():
|
||||||
|
if widget.key in filters_mapping:
|
||||||
|
widget.filters = filters_mapping[widget.key]
|
||||||
|
widgets_to_update.append(widget)
|
||||||
|
|
||||||
|
# Bulk update the widgets
|
||||||
|
Widget.objects.bulk_update(widgets_to_update, ["filters"], batch_size=10)
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
dependencies = [
|
||||||
|
('db', '0058_alter_moduleissue_issue_and_more'),
|
||||||
|
]
|
||||||
|
operations = [
|
||||||
|
migrations.RunPython(widgets_filter_change)
|
||||||
|
]
|
8
packages/types/src/dashboard.d.ts
vendored
8
packages/types/src/dashboard.d.ts
vendored
@ -24,21 +24,21 @@ export type TDurationFilterOptions =
|
|||||||
|
|
||||||
// widget filters
|
// widget filters
|
||||||
export type TAssignedIssuesWidgetFilters = {
|
export type TAssignedIssuesWidgetFilters = {
|
||||||
target_date?: TDurationFilterOptions;
|
duration?: TDurationFilterOptions;
|
||||||
tab?: TIssuesListTypes;
|
tab?: TIssuesListTypes;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type TCreatedIssuesWidgetFilters = {
|
export type TCreatedIssuesWidgetFilters = {
|
||||||
target_date?: TDurationFilterOptions;
|
duration?: TDurationFilterOptions;
|
||||||
tab?: TIssuesListTypes;
|
tab?: TIssuesListTypes;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type TIssuesByStateGroupsWidgetFilters = {
|
export type TIssuesByStateGroupsWidgetFilters = {
|
||||||
target_date?: TDurationFilterOptions;
|
duration?: TDurationFilterOptions;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type TIssuesByPriorityWidgetFilters = {
|
export type TIssuesByPriorityWidgetFilters = {
|
||||||
target_date?: TDurationFilterOptions;
|
duration?: TDurationFilterOptions;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type TWidgetFiltersFormData =
|
export type TWidgetFiltersFormData =
|
||||||
|
@ -13,7 +13,7 @@ import {
|
|||||||
WidgetProps,
|
WidgetProps,
|
||||||
} from "components/dashboard/widgets";
|
} from "components/dashboard/widgets";
|
||||||
// helpers
|
// helpers
|
||||||
import { getCustomDates, getRedirectionFilters } from "helpers/dashboard.helper";
|
import { getCustomDates, getRedirectionFilters, getTabKey } from "helpers/dashboard.helper";
|
||||||
// types
|
// types
|
||||||
import { TAssignedIssuesWidgetFilters, TAssignedIssuesWidgetResponse } from "@plane/types";
|
import { TAssignedIssuesWidgetFilters, TAssignedIssuesWidgetResponse } from "@plane/types";
|
||||||
// constants
|
// constants
|
||||||
@ -30,8 +30,8 @@ export const AssignedIssuesWidget: React.FC<WidgetProps> = observer((props) => {
|
|||||||
// derived values
|
// derived values
|
||||||
const widgetDetails = getWidgetDetails(workspaceSlug, dashboardId, WIDGET_KEY);
|
const widgetDetails = getWidgetDetails(workspaceSlug, dashboardId, WIDGET_KEY);
|
||||||
const widgetStats = getWidgetStats<TAssignedIssuesWidgetResponse>(workspaceSlug, dashboardId, WIDGET_KEY);
|
const widgetStats = getWidgetStats<TAssignedIssuesWidgetResponse>(workspaceSlug, dashboardId, WIDGET_KEY);
|
||||||
const selectedTab = widgetDetails?.widget_filters.tab ?? "pending";
|
const selectedDurationFilter = widgetDetails?.widget_filters.duration ?? "none";
|
||||||
const selectedDurationFilter = widgetDetails?.widget_filters.target_date ?? "none";
|
const selectedTab = getTabKey(selectedDurationFilter, widgetDetails?.widget_filters.tab);
|
||||||
|
|
||||||
const handleUpdateFilters = async (filters: Partial<TAssignedIssuesWidgetFilters>) => {
|
const handleUpdateFilters = async (filters: Partial<TAssignedIssuesWidgetFilters>) => {
|
||||||
if (!widgetDetails) return;
|
if (!widgetDetails) return;
|
||||||
@ -43,7 +43,7 @@ export const AssignedIssuesWidget: React.FC<WidgetProps> = observer((props) => {
|
|||||||
filters,
|
filters,
|
||||||
});
|
});
|
||||||
|
|
||||||
const filterDates = getCustomDates(filters.target_date ?? selectedDurationFilter);
|
const filterDates = getCustomDates(filters.duration ?? selectedDurationFilter);
|
||||||
fetchWidgetStats(workspaceSlug, dashboardId, {
|
fetchWidgetStats(workspaceSlug, dashboardId, {
|
||||||
widget_key: WIDGET_KEY,
|
widget_key: WIDGET_KEY,
|
||||||
issue_type: filters.tab ?? selectedTab,
|
issue_type: filters.tab ?? selectedTab,
|
||||||
@ -86,19 +86,19 @@ export const AssignedIssuesWidget: React.FC<WidgetProps> = observer((props) => {
|
|||||||
|
|
||||||
// switch to pending tab if target date is changed to none
|
// switch to pending tab if target date is changed to none
|
||||||
if (val === "none" && selectedTab !== "completed") {
|
if (val === "none" && selectedTab !== "completed") {
|
||||||
handleUpdateFilters({ target_date: val, tab: "pending" });
|
handleUpdateFilters({ duration: val, tab: "pending" });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// switch to upcoming tab if target date is changed to other than none
|
// switch to upcoming tab if target date is changed to other than none
|
||||||
if (val !== "none" && selectedDurationFilter === "none" && selectedTab !== "completed") {
|
if (val !== "none" && selectedDurationFilter === "none" && selectedTab !== "completed") {
|
||||||
handleUpdateFilters({
|
handleUpdateFilters({
|
||||||
target_date: val,
|
duration: val,
|
||||||
tab: "upcoming",
|
tab: "upcoming",
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
handleUpdateFilters({ target_date: val });
|
handleUpdateFilters({ duration: val });
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
@ -13,7 +13,7 @@ import {
|
|||||||
WidgetProps,
|
WidgetProps,
|
||||||
} from "components/dashboard/widgets";
|
} from "components/dashboard/widgets";
|
||||||
// helpers
|
// helpers
|
||||||
import { getCustomDates, getRedirectionFilters } from "helpers/dashboard.helper";
|
import { getCustomDates, getRedirectionFilters, getTabKey } from "helpers/dashboard.helper";
|
||||||
// types
|
// types
|
||||||
import { TCreatedIssuesWidgetFilters, TCreatedIssuesWidgetResponse } from "@plane/types";
|
import { TCreatedIssuesWidgetFilters, TCreatedIssuesWidgetResponse } from "@plane/types";
|
||||||
// constants
|
// constants
|
||||||
@ -30,8 +30,8 @@ export const CreatedIssuesWidget: React.FC<WidgetProps> = observer((props) => {
|
|||||||
// derived values
|
// derived values
|
||||||
const widgetDetails = getWidgetDetails(workspaceSlug, dashboardId, WIDGET_KEY);
|
const widgetDetails = getWidgetDetails(workspaceSlug, dashboardId, WIDGET_KEY);
|
||||||
const widgetStats = getWidgetStats<TCreatedIssuesWidgetResponse>(workspaceSlug, dashboardId, WIDGET_KEY);
|
const widgetStats = getWidgetStats<TCreatedIssuesWidgetResponse>(workspaceSlug, dashboardId, WIDGET_KEY);
|
||||||
const selectedTab = widgetDetails?.widget_filters.tab ?? "pending";
|
const selectedDurationFilter = widgetDetails?.widget_filters.duration ?? "none";
|
||||||
const selectedDurationFilter = widgetDetails?.widget_filters.target_date ?? "none";
|
const selectedTab = getTabKey(selectedDurationFilter, widgetDetails?.widget_filters.tab);
|
||||||
|
|
||||||
const handleUpdateFilters = async (filters: Partial<TCreatedIssuesWidgetFilters>) => {
|
const handleUpdateFilters = async (filters: Partial<TCreatedIssuesWidgetFilters>) => {
|
||||||
if (!widgetDetails) return;
|
if (!widgetDetails) return;
|
||||||
@ -43,7 +43,7 @@ export const CreatedIssuesWidget: React.FC<WidgetProps> = observer((props) => {
|
|||||||
filters,
|
filters,
|
||||||
});
|
});
|
||||||
|
|
||||||
const filterDates = getCustomDates(filters.target_date ?? selectedDurationFilter);
|
const filterDates = getCustomDates(filters.duration ?? selectedDurationFilter);
|
||||||
fetchWidgetStats(workspaceSlug, dashboardId, {
|
fetchWidgetStats(workspaceSlug, dashboardId, {
|
||||||
widget_key: WIDGET_KEY,
|
widget_key: WIDGET_KEY,
|
||||||
issue_type: filters.tab ?? selectedTab,
|
issue_type: filters.tab ?? selectedTab,
|
||||||
@ -83,19 +83,19 @@ export const CreatedIssuesWidget: React.FC<WidgetProps> = observer((props) => {
|
|||||||
|
|
||||||
// switch to pending tab if target date is changed to none
|
// switch to pending tab if target date is changed to none
|
||||||
if (val === "none" && selectedTab !== "completed") {
|
if (val === "none" && selectedTab !== "completed") {
|
||||||
handleUpdateFilters({ target_date: val, tab: "pending" });
|
handleUpdateFilters({ duration: val, tab: "pending" });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// switch to upcoming tab if target date is changed to other than none
|
// switch to upcoming tab if target date is changed to other than none
|
||||||
if (val !== "none" && selectedDurationFilter === "none" && selectedTab !== "completed") {
|
if (val !== "none" && selectedDurationFilter === "none" && selectedTab !== "completed") {
|
||||||
handleUpdateFilters({
|
handleUpdateFilters({
|
||||||
target_date: val,
|
duration: val,
|
||||||
tab: "upcoming",
|
tab: "upcoming",
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
handleUpdateFilters({ target_date: val });
|
handleUpdateFilters({ duration: val });
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
@ -16,42 +16,40 @@ export const TabsList: React.FC<Props> = observer((props) => {
|
|||||||
const { durationFilter, selectedTab } = props;
|
const { durationFilter, selectedTab } = props;
|
||||||
|
|
||||||
const tabsList = durationFilter === "none" ? UNFILTERED_ISSUES_TABS_LIST : FILTERED_ISSUES_TABS_LIST;
|
const tabsList = durationFilter === "none" ? UNFILTERED_ISSUES_TABS_LIST : FILTERED_ISSUES_TABS_LIST;
|
||||||
const selectedTabIndex = tabsList.findIndex((tab) => tab.key === (selectedTab ?? "pending"));
|
const selectedTabIndex = tabsList.findIndex((tab) => tab.key === selectedTab);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Tab.List
|
<Tab.List
|
||||||
as="div"
|
as="div"
|
||||||
className="relative border-[0.5px] border-custom-border-200 rounded bg-custom-background-80 grid"
|
className="relative border-[0.5px] border-custom-border-200 rounded bg-custom-background-80 p-[1px] grid"
|
||||||
style={{
|
style={{
|
||||||
gridTemplateColumns: `repeat(${tabsList.length}, 1fr)`,
|
gridTemplateColumns: `repeat(${tabsList.length}, 1fr)`,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
className={cn("absolute bg-custom-background-100 rounded transition-all duration-500 ease-in-out", {
|
className={cn(
|
||||||
// right shadow
|
"absolute top-1/2 left-[1px] bg-custom-background-100 rounded-[3px] transition-all duration-500 ease-in-out",
|
||||||
"shadow-[2px_0_8px_rgba(167,169,174,0.15)]": selectedTabIndex !== tabsList.length - 1,
|
{
|
||||||
// left shadow
|
// right shadow
|
||||||
"shadow-[-2px_0_8px_rgba(167,169,174,0.15)]": selectedTabIndex !== 0,
|
"shadow-[2px_0_8px_rgba(167,169,174,0.15)]": selectedTabIndex !== tabsList.length - 1,
|
||||||
})}
|
// left shadow
|
||||||
|
"shadow-[-2px_0_8px_rgba(167,169,174,0.15)]": selectedTabIndex !== 0,
|
||||||
|
}
|
||||||
|
)}
|
||||||
style={{
|
style={{
|
||||||
height: "calc(100% - 1px)",
|
height: "calc(100% - 2px)",
|
||||||
width: `${100 / tabsList.length}%`,
|
width: `calc(${100 / tabsList.length}% - 1px)`,
|
||||||
transform: `translateX(${selectedTabIndex * 100}%)`,
|
transform: `translate(${selectedTabIndex * 100}%, -50%)`,
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
{tabsList.map((tab) => (
|
{tabsList.map((tab) => (
|
||||||
<Tab
|
<Tab
|
||||||
key={tab.key}
|
key={tab.key}
|
||||||
className={cn(
|
className={cn(
|
||||||
"relative z-[1] font-semibold text-xs rounded py-1.5 text-custom-text-400 focus:outline-none",
|
"relative z-[1] font-semibold text-xs rounded-[3px] py-1.5 text-custom-text-400 focus:outline-none transition duration-500",
|
||||||
"transition duration-500",
|
|
||||||
{
|
{
|
||||||
"text-custom-text-100 bg-custom-background-100": selectedTab === tab.key,
|
"text-custom-text-100 bg-custom-background-100": selectedTab === tab.key,
|
||||||
"hover:text-custom-text-300": selectedTab !== tab.key,
|
"hover:text-custom-text-300": selectedTab !== tab.key,
|
||||||
// // right shadow
|
|
||||||
// "shadow-[2px_0_8px_rgba(167,169,174,0.15)]": selectedTabIndex !== tabsList.length - 1,
|
|
||||||
// // left shadow
|
|
||||||
// "shadow-[-2px_0_8px_rgba(167,169,174,0.15)]": selectedTabIndex !== 0,
|
|
||||||
}
|
}
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
|
@ -73,8 +73,10 @@ export const IssuesByPriorityWidget: React.FC<WidgetProps> = observer((props) =>
|
|||||||
const { dashboardId, workspaceSlug } = props;
|
const { dashboardId, workspaceSlug } = props;
|
||||||
// store hooks
|
// store hooks
|
||||||
const { fetchWidgetStats, getWidgetDetails, getWidgetStats, updateDashboardWidgetFilters } = useDashboard();
|
const { fetchWidgetStats, getWidgetDetails, getWidgetStats, updateDashboardWidgetFilters } = useDashboard();
|
||||||
|
// derived values
|
||||||
const widgetDetails = getWidgetDetails(workspaceSlug, dashboardId, WIDGET_KEY);
|
const widgetDetails = getWidgetDetails(workspaceSlug, dashboardId, WIDGET_KEY);
|
||||||
const widgetStats = getWidgetStats<TIssuesByPriorityWidgetResponse[]>(workspaceSlug, dashboardId, WIDGET_KEY);
|
const widgetStats = getWidgetStats<TIssuesByPriorityWidgetResponse[]>(workspaceSlug, dashboardId, WIDGET_KEY);
|
||||||
|
const selectedDuration = widgetDetails?.widget_filters.duration ?? "none";
|
||||||
|
|
||||||
const handleUpdateFilters = async (filters: Partial<TIssuesByPriorityWidgetFilters>) => {
|
const handleUpdateFilters = async (filters: Partial<TIssuesByPriorityWidgetFilters>) => {
|
||||||
if (!widgetDetails) return;
|
if (!widgetDetails) return;
|
||||||
@ -84,7 +86,7 @@ export const IssuesByPriorityWidget: React.FC<WidgetProps> = observer((props) =>
|
|||||||
filters,
|
filters,
|
||||||
});
|
});
|
||||||
|
|
||||||
const filterDates = getCustomDates(filters.target_date ?? widgetDetails.widget_filters.target_date ?? "none");
|
const filterDates = getCustomDates(filters.duration ?? selectedDuration);
|
||||||
fetchWidgetStats(workspaceSlug, dashboardId, {
|
fetchWidgetStats(workspaceSlug, dashboardId, {
|
||||||
widget_key: WIDGET_KEY,
|
widget_key: WIDGET_KEY,
|
||||||
...(filterDates.trim() !== "" ? { target_date: filterDates } : {}),
|
...(filterDates.trim() !== "" ? { target_date: filterDates } : {}),
|
||||||
@ -92,7 +94,7 @@ export const IssuesByPriorityWidget: React.FC<WidgetProps> = observer((props) =>
|
|||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const filterDates = getCustomDates(widgetDetails?.widget_filters.target_date ?? "none");
|
const filterDates = getCustomDates(selectedDuration);
|
||||||
fetchWidgetStats(workspaceSlug, dashboardId, {
|
fetchWidgetStats(workspaceSlug, dashboardId, {
|
||||||
widget_key: WIDGET_KEY,
|
widget_key: WIDGET_KEY,
|
||||||
...(filterDates.trim() !== "" ? { target_date: filterDates } : {}),
|
...(filterDates.trim() !== "" ? { target_date: filterDates } : {}),
|
||||||
@ -139,10 +141,10 @@ export const IssuesByPriorityWidget: React.FC<WidgetProps> = observer((props) =>
|
|||||||
Assigned by priority
|
Assigned by priority
|
||||||
</Link>
|
</Link>
|
||||||
<DurationFilterDropdown
|
<DurationFilterDropdown
|
||||||
value={widgetDetails.widget_filters.target_date ?? "none"}
|
value={selectedDuration}
|
||||||
onChange={(val) =>
|
onChange={(val) =>
|
||||||
handleUpdateFilters({
|
handleUpdateFilters({
|
||||||
target_date: val,
|
duration: val,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
|
@ -34,6 +34,7 @@ export const IssuesByStateGroupWidget: React.FC<WidgetProps> = observer((props)
|
|||||||
// derived values
|
// derived values
|
||||||
const widgetDetails = getWidgetDetails(workspaceSlug, dashboardId, WIDGET_KEY);
|
const widgetDetails = getWidgetDetails(workspaceSlug, dashboardId, WIDGET_KEY);
|
||||||
const widgetStats = getWidgetStats<TIssuesByStateGroupsWidgetResponse[]>(workspaceSlug, dashboardId, WIDGET_KEY);
|
const widgetStats = getWidgetStats<TIssuesByStateGroupsWidgetResponse[]>(workspaceSlug, dashboardId, WIDGET_KEY);
|
||||||
|
const selectedDuration = widgetDetails?.widget_filters.duration ?? "none";
|
||||||
|
|
||||||
const handleUpdateFilters = async (filters: Partial<TIssuesByStateGroupsWidgetFilters>) => {
|
const handleUpdateFilters = async (filters: Partial<TIssuesByStateGroupsWidgetFilters>) => {
|
||||||
if (!widgetDetails) return;
|
if (!widgetDetails) return;
|
||||||
@ -43,7 +44,7 @@ export const IssuesByStateGroupWidget: React.FC<WidgetProps> = observer((props)
|
|||||||
filters,
|
filters,
|
||||||
});
|
});
|
||||||
|
|
||||||
const filterDates = getCustomDates(filters.target_date ?? widgetDetails.widget_filters.target_date ?? "none");
|
const filterDates = getCustomDates(filters.duration ?? selectedDuration);
|
||||||
fetchWidgetStats(workspaceSlug, dashboardId, {
|
fetchWidgetStats(workspaceSlug, dashboardId, {
|
||||||
widget_key: WIDGET_KEY,
|
widget_key: WIDGET_KEY,
|
||||||
...(filterDates.trim() !== "" ? { target_date: filterDates } : {}),
|
...(filterDates.trim() !== "" ? { target_date: filterDates } : {}),
|
||||||
@ -52,7 +53,7 @@ export const IssuesByStateGroupWidget: React.FC<WidgetProps> = observer((props)
|
|||||||
|
|
||||||
// fetch widget stats
|
// fetch widget stats
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const filterDates = getCustomDates(widgetDetails?.widget_filters.target_date ?? "none");
|
const filterDates = getCustomDates(selectedDuration);
|
||||||
fetchWidgetStats(workspaceSlug, dashboardId, {
|
fetchWidgetStats(workspaceSlug, dashboardId, {
|
||||||
widget_key: WIDGET_KEY,
|
widget_key: WIDGET_KEY,
|
||||||
...(filterDates.trim() !== "" ? { target_date: filterDates } : {}),
|
...(filterDates.trim() !== "" ? { target_date: filterDates } : {}),
|
||||||
@ -138,10 +139,10 @@ export const IssuesByStateGroupWidget: React.FC<WidgetProps> = observer((props)
|
|||||||
Assigned by state
|
Assigned by state
|
||||||
</Link>
|
</Link>
|
||||||
<DurationFilterDropdown
|
<DurationFilterDropdown
|
||||||
value={widgetDetails.widget_filters.target_date ?? "none"}
|
value={selectedDuration}
|
||||||
onChange={(val) =>
|
onChange={(val) =>
|
||||||
handleUpdateFilters({
|
handleUpdateFilters({
|
||||||
target_date: val,
|
duration: val,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
|
@ -4,6 +4,10 @@ import { renderFormattedPayloadDate } from "./date-time.helper";
|
|||||||
// types
|
// types
|
||||||
import { TDurationFilterOptions, TIssuesListTypes } from "@plane/types";
|
import { TDurationFilterOptions, TIssuesListTypes } from "@plane/types";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description returns date range based on the duration filter
|
||||||
|
* @param duration
|
||||||
|
*/
|
||||||
export const getCustomDates = (duration: TDurationFilterOptions): string => {
|
export const getCustomDates = (duration: TDurationFilterOptions): string => {
|
||||||
const today = new Date();
|
const today = new Date();
|
||||||
let firstDay, lastDay;
|
let firstDay, lastDay;
|
||||||
@ -30,6 +34,10 @@ export const getCustomDates = (duration: TDurationFilterOptions): string => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description returns redirection filters for the issues list
|
||||||
|
* @param type
|
||||||
|
*/
|
||||||
export const getRedirectionFilters = (type: TIssuesListTypes): string => {
|
export const getRedirectionFilters = (type: TIssuesListTypes): string => {
|
||||||
const today = renderFormattedPayloadDate(new Date());
|
const today = renderFormattedPayloadDate(new Date());
|
||||||
|
|
||||||
@ -44,3 +52,20 @@ export const getRedirectionFilters = (type: TIssuesListTypes): string => {
|
|||||||
|
|
||||||
return filterParams;
|
return filterParams;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description returns the tab key based on the duration filter
|
||||||
|
* @param duration
|
||||||
|
* @param tab
|
||||||
|
*/
|
||||||
|
export const getTabKey = (duration: TDurationFilterOptions, tab: TIssuesListTypes | undefined): TIssuesListTypes => {
|
||||||
|
if (!tab) return "completed";
|
||||||
|
|
||||||
|
if (tab === "completed") return tab;
|
||||||
|
|
||||||
|
if (duration === "none") return "pending";
|
||||||
|
else {
|
||||||
|
if (["upcoming", "overdue"].includes(tab)) return tab;
|
||||||
|
else return "upcoming";
|
||||||
|
}
|
||||||
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user