mirror of
https://github.com/felipegcoutinho/openmonetis.git
synced 2026-05-09 11:01:45 +00:00
fix(inbox): alinhar horario da tooltip do card
This commit is contained in:
@@ -28,15 +28,8 @@ import {
|
|||||||
import { resolveLogoSrc } from "@/shared/lib/logo";
|
import { resolveLogoSrc } from "@/shared/lib/logo";
|
||||||
import type { InboxItem } from "./types";
|
import type { InboxItem } from "./types";
|
||||||
|
|
||||||
// O timestamp vem do app Android em horário local mas salvo como UTC.
|
|
||||||
// Adicionamos o offset de Brasília para corrigir o cálculo de "há X tempo".
|
|
||||||
const BRASILIA_OFFSET_MS = 3 * 60 * 60 * 1000;
|
|
||||||
const DEFAULT_INBOX_APP_LOGO = "/avatars/default_icon.png";
|
const DEFAULT_INBOX_APP_LOGO = "/avatars/default_icon.png";
|
||||||
|
|
||||||
function adjustToBrasilia(date: Date): Date {
|
|
||||||
return new Date(date.getTime() + BRASILIA_OFFSET_MS);
|
|
||||||
}
|
|
||||||
|
|
||||||
function findMatchingLogo(
|
function findMatchingLogo(
|
||||||
sourceAppName: string | null,
|
sourceAppName: string | null,
|
||||||
appLogoMap: Record<string, string>,
|
appLogoMap: Record<string, string>,
|
||||||
@@ -88,17 +81,14 @@ export function InboxCard({
|
|||||||
|
|
||||||
const amount = item.parsedAmount ? parseFloat(item.parsedAmount) : null;
|
const amount = item.parsedAmount ? parseFloat(item.parsedAmount) : null;
|
||||||
|
|
||||||
const rawDate = new Date(item.notificationTimestamp);
|
const createdAtDate = new Date(item.createdAt);
|
||||||
const notificationDate = adjustToBrasilia(rawDate);
|
|
||||||
|
|
||||||
const timeAgo = formatDistanceToNow(notificationDate, {
|
const timeAgo = formatDistanceToNow(createdAtDate, {
|
||||||
addSuffix: true,
|
addSuffix: true,
|
||||||
locale: ptBR,
|
locale: ptBR,
|
||||||
});
|
});
|
||||||
|
|
||||||
const fullDate = format(notificationDate, "EEE, d 'de' MMM yyyy 'às' HH:mm", {
|
const fullDate = format(createdAtDate, "PPpp", { locale: ptBR });
|
||||||
locale: ptBR,
|
|
||||||
});
|
|
||||||
|
|
||||||
const statusDate =
|
const statusDate =
|
||||||
item.status === "processed"
|
item.status === "processed"
|
||||||
|
|||||||
Reference in New Issue
Block a user