diff --git a/web/helpers/date-time.helper.ts b/web/helpers/date-time.helper.ts index 5d5acd07e1..a6719ec1e3 100644 --- a/web/helpers/date-time.helper.ts +++ b/web/helpers/date-time.helper.ts @@ -224,7 +224,29 @@ export const getDate = (date: string | Date | undefined | null): Date | undefine return undefined; } }; + export const isInDateFormat = (date: string) => { const datePattern = /^\d{4}-\d{2}-\d{2}$/; return datePattern.test(date); }; + +/** + * returns the date string in ISO format regardless of the timezone in input date string + * @param dateString + * @returns + */ +export const convertToISODateString = (dateString: string | undefined) => { + if (!dateString) return dateString; + + const date = new Date(dateString); + return date.toISOString(); +}; + +/** + * get current Date time in UTC ISO format + * @returns + */ +export const getCurrentDateTimeInISO = () => { + const date = new Date(); + return date.toISOString(); +}; \ No newline at end of file diff --git a/web/store/issue/helpers/issue-helper.store.ts b/web/store/issue/helpers/issue-helper.store.ts index 3876d675cf..e308679cad 100644 --- a/web/store/issue/helpers/issue-helper.store.ts +++ b/web/store/issue/helpers/issue-helper.store.ts @@ -7,7 +7,7 @@ import values from "lodash/values"; import { ISSUE_PRIORITIES } from "@/constants/issue"; import { STATE_GROUPS } from "@/constants/state"; // helpers -import { renderFormattedPayloadDate } from "@/helpers/date-time.helper"; +import { convertToISODateString, renderFormattedPayloadDate } from "@/helpers/date-time.helper"; // types import { TIssue, TIssueMap, TIssueGroupByOptions, TIssueOrderByOptions } from "@plane/types"; // store @@ -262,13 +262,13 @@ export class IssueHelperStore implements TIssueHelperStore { return orderBy(array, (issue) => this.populateIssueDataForSorting("state_id", issue["state_id"]), ["desc"]); // dates case "created_at": - return orderBy(array, "created_at"); + return orderBy(array, (issue) => convertToISODateString(issue["created_at"])); case "-created_at": - return orderBy(array, "created_at", ["desc"]); + return orderBy(array, (issue) => convertToISODateString(issue["created_at"]), ["desc"]); case "updated_at": - return orderBy(array, "updated_at"); + return orderBy(array, (issue) => convertToISODateString(issue["updated_at"])); case "-updated_at": - return orderBy(array, "updated_at", ["desc"]); + return orderBy(array, (issue) => convertToISODateString(issue["updated_at"]), ["desc"]); case "start_date": return orderBy(array, [this.getSortOrderToFilterEmptyValues.bind(null, "start_date"), "start_date"]); //preferring sorting based on empty values to always keep the empty values below case "-start_date": diff --git a/web/store/issue/issue.store.ts b/web/store/issue/issue.store.ts index b6611ef494..b2b33464c2 100644 --- a/web/store/issue/issue.store.ts +++ b/web/store/issue/issue.store.ts @@ -6,6 +6,7 @@ import { computedFn } from "mobx-utils"; // types import { IssueService } from "@/services/issue"; import { TIssue } from "@plane/types"; +import { getCurrentDateTimeInISO } from "@/helpers/date-time.helper"; //services export type IIssueStore = { @@ -76,6 +77,7 @@ export class IssueStore implements IIssueStore { updateIssue = (issueId: string, issue: Partial) => { if (!issue || !issueId || isEmpty(this.issuesMap) || !this.issuesMap[issueId]) return; runInAction(() => { + set(this.issuesMap, [issueId, "updated_at"], getCurrentDateTimeInISO()); Object.keys(issue).forEach((key) => { set(this.issuesMap, [issueId, key], issue[key as keyof TIssue]); });