mirror of
https://github.com/hexastack/hexabot
synced 2025-06-26 18:27:28 +00:00
fix(frontend): date normalization
This commit is contained in:
parent
dadb263176
commit
2c7c821b39
@ -22,6 +22,7 @@ import { useAuth } from "@/hooks/useAuth";
|
||||
import { useConfig } from "@/hooks/useConfig";
|
||||
import { useTranslate } from "@/hooks/useTranslate";
|
||||
import { EntityType } from "@/services/types";
|
||||
import { normalizeDate } from "@/utils/date";
|
||||
|
||||
import {
|
||||
getAvatarSrc,
|
||||
@ -115,8 +116,9 @@ export function Chat() {
|
||||
key={message.id}
|
||||
title={`${subscriber.first_name} ${
|
||||
subscriber.last_name
|
||||
} : ${message.createdAt.toLocaleString(
|
||||
} : ${normalizeDate(
|
||||
i18n.language,
|
||||
message.createdAt,
|
||||
)}`}
|
||||
src={getAvatarSrc(
|
||||
apiUrl,
|
||||
|
@ -20,6 +20,7 @@ import { useConfig } from "@/hooks/useConfig";
|
||||
import { useTranslate } from "@/hooks/useTranslate";
|
||||
import { Title } from "@/layout/content/Title";
|
||||
import { EntityType, RouterType } from "@/services/types";
|
||||
import { normalizeDate } from "@/utils/date";
|
||||
import { extractQueryParamsUrl } from "@/utils/URL";
|
||||
|
||||
import { getAvatarSrc } from "../helpers/mapMessages";
|
||||
@ -82,7 +83,7 @@ export const SubscribersList = (props: {
|
||||
{subscriber.first_name} {subscriber.last_name}
|
||||
</div>
|
||||
<div className="cs-conversation__info">
|
||||
{subscriber.lastvisit?.toLocaleString(i18n.language)}
|
||||
{normalizeDate(i18n.language, subscriber.lastvisit)}
|
||||
</div>
|
||||
</Conversation.Content>
|
||||
<Conversation.Operations visible>
|
||||
|
@ -14,3 +14,9 @@ export const getDateTimeFormatter = (date: Date) => ({
|
||||
val: DATE_TIME_FORMAT,
|
||||
},
|
||||
});
|
||||
|
||||
export const normalizeDate = (locale: string, dateField?: Date | string) =>
|
||||
(typeof dateField === "string"
|
||||
? new Date(dateField)
|
||||
: dateField
|
||||
)?.toLocaleString(locale);
|
||||
|
Loading…
Reference in New Issue
Block a user