forked from github/plane
1dac70ecbe
* chore: inbox issue status pill improvement * chore: loader inconsistancy resolved * chore: accepted and decline inbox issue validation * chore: removed clear all button in applied filters * chore: inbox issue create label improvement * chore: updated label filter * chore: updated fetching activites and comments * chore: inbox filters date * chore: removed the print statement * chore: inbox date filter updated * chore: handled custom date filter in inbox issue query params * chore: handled custom date filter in inbox issue single select * chore: inbox custom date filter updated * chore: inbox sidebar filter improvement * chore: inbox sidebar filter improvement * chore: duplicate issue detail * chore: duplicate inbox issue improvement * chore: lint issue resolved --------- Co-authored-by: Anmol Singh Bhatia <anmolsinghbhatia@plane.so> Co-authored-by: NarayanBavisetti <narayan3119@gmail.com>
57 lines
1.6 KiB
TypeScript
57 lines
1.6 KiB
TypeScript
import { subDays } from "date-fns";
|
|
import { renderFormattedPayloadDate } from "./date-time.helper";
|
|
|
|
export enum EPastDurationFilters {
|
|
TODAY = "today",
|
|
YESTERDAY = "yesterday",
|
|
LAST_7_DAYS = "last_7_days",
|
|
LAST_30_DAYS = "last_30_days",
|
|
}
|
|
|
|
export const getCustomDates = (duration: EPastDurationFilters): string => {
|
|
const today = new Date();
|
|
let firstDay, lastDay;
|
|
|
|
switch (duration) {
|
|
case EPastDurationFilters.TODAY:
|
|
firstDay = renderFormattedPayloadDate(today);
|
|
lastDay = renderFormattedPayloadDate(today);
|
|
return `${firstDay};after,${lastDay};before`;
|
|
case EPastDurationFilters.YESTERDAY:
|
|
const yesterday = subDays(today, 1);
|
|
firstDay = renderFormattedPayloadDate(yesterday);
|
|
lastDay = renderFormattedPayloadDate(yesterday);
|
|
return `${firstDay};after,${lastDay};before`;
|
|
case EPastDurationFilters.LAST_7_DAYS:
|
|
firstDay = renderFormattedPayloadDate(subDays(today, 7));
|
|
lastDay = renderFormattedPayloadDate(today);
|
|
return `${firstDay};after,${lastDay};before`;
|
|
case EPastDurationFilters.LAST_30_DAYS:
|
|
firstDay = renderFormattedPayloadDate(subDays(today, 30));
|
|
lastDay = renderFormattedPayloadDate(today);
|
|
return `${firstDay};after,${lastDay};before`;
|
|
}
|
|
};
|
|
|
|
export const PAST_DURATION_FILTER_OPTIONS: {
|
|
name: string;
|
|
value: string;
|
|
}[] = [
|
|
{
|
|
name: "Today",
|
|
value: EPastDurationFilters.TODAY,
|
|
},
|
|
{
|
|
name: "Yesterday",
|
|
value: EPastDurationFilters.YESTERDAY,
|
|
},
|
|
{
|
|
name: "Last 7 days",
|
|
value: EPastDurationFilters.LAST_7_DAYS,
|
|
},
|
|
{
|
|
name: "Last 30 days",
|
|
value: EPastDurationFilters.LAST_30_DAYS,
|
|
},
|
|
];
|