refactor: move web utils to packages (#7145)
* refactor: move web utils to packages * fix: build and lint errors * chore: update drag handle plugin * chore: update table cell type to fix build errors * fix: build errors * chore: sync few changes * fix: build errors * chore: minor fixes related to duplicate assets imports * fix: build errors * chore: minor changes
This commit is contained in:
parent
dffcc6dc10
commit
2014400bed
614 changed files with 1999 additions and 3030 deletions
34
packages/utils/src/intake.ts
Normal file
34
packages/utils/src/intake.ts
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
import { subDays } from "date-fns";
|
||||
// plane imports
|
||||
import { EPastDurationFilters } from "@plane/constants";
|
||||
// local imports
|
||||
import { renderFormattedPayloadDate } from "./datetime";
|
||||
|
||||
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`;
|
||||
}
|
||||
}
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue