From 7447e28abc3b84a2f8e21bd2856a09849ad10c15 Mon Sep 17 00:00:00 2001 From: Alon Peretz <8467965+alonp99@users.noreply.github.com> Date: Sat, 26 Oct 2024 23:10:40 +0300 Subject: [PATCH] fix(backoffice): mm local time --- apps/backoffice-v2/package.json | 3 ++- .../MerchantMonitoringTable/columns.tsx | 15 ++++++++++++--- pnpm-lock.yaml | 8 +++++--- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/apps/backoffice-v2/package.json b/apps/backoffice-v2/package.json index c359f4909..3b1005261 100644 --- a/apps/backoffice-v2/package.json +++ b/apps/backoffice-v2/package.json @@ -40,7 +40,7 @@ "lint": "eslint . --fix", "start": "vite", "dev": "vite", - "build": "vite build", + "build": "cross-env NODE_OPTIONS=--max-old-space-size=32768 vite build", "test": "vitest run --passWithNoTests", "test:unit": "vitest run --passWithNoTests", "test:e2e": "playwright test", @@ -156,6 +156,7 @@ "@typescript-eslint/parser": "^5.30.0", "@vitejs/plugin-react-swc": "^3.0.1", "autoprefixer": "^10.4.7", + "cross-env": "^7.0.3", "cspell": "^6.31.2", "eslint": "8.22.0", "eslint-config-prettier": "^8.5.0", diff --git a/apps/backoffice-v2/src/pages/MerchantMonitoring/components/MerchantMonitoringTable/columns.tsx b/apps/backoffice-v2/src/pages/MerchantMonitoring/components/MerchantMonitoringTable/columns.tsx index ad135fe7c..0a285299d 100644 --- a/apps/backoffice-v2/src/pages/MerchantMonitoring/components/MerchantMonitoringTable/columns.tsx +++ b/apps/backoffice-v2/src/pages/MerchantMonitoring/components/MerchantMonitoringTable/columns.tsx @@ -1,5 +1,11 @@ import dayjs from 'dayjs'; -import React from 'react'; +import utc from 'dayjs/plugin/utc'; +import timezone from 'dayjs/plugin/timezone'; + +// Add these plugins to dayjs +dayjs.extend(utc); +dayjs.extend(timezone); + import { createColumnHelper } from '@tanstack/react-table'; import { BusinessReportStatus, TBusinessReport } from '@/domains/business-reports/fetchers'; import { titleCase } from 'string-ts'; @@ -55,8 +61,11 @@ export const columns = [ return {createdAt}; } - const date = dayjs(createdAt).format('MMM DD, YYYY'); - const time = dayjs(createdAt).format('hh:mm'); + // Convert UTC time to local browser time + const localDateTime = dayjs.utc(createdAt).local(); + + const date = localDateTime.format('MMM DD, YYYY'); + const time = localDateTime.format('HH:mm'); return (
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index a193b2182..c2907e9a4 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -379,6 +379,9 @@ importers: autoprefixer: specifier: ^10.4.7 version: 10.4.14(postcss@8.4.31) + cross-env: + specifier: ^7.0.3 + version: 7.0.3 cspell: specifier: ^6.31.2 version: 6.31.3 @@ -22746,7 +22749,6 @@ packages: hasBin: true dependencies: cross-spawn: 7.0.3 - dev: false /cross-fetch@3.1.8: resolution: {integrity: sha512-cvA+JwZoU0Xq+h6WkMvAUqPEYy92Obet6UdKLfW60qn99ftItKjB5T+BkyWOFWe2pUyfQ+IJHmpOTznqk1M6Kg==} @@ -24629,7 +24631,7 @@ packages: eslint-import-resolver-webpack: optional: true dependencies: - '@typescript-eslint/parser': 5.62.0(eslint@8.54.0)(typescript@4.9.3) + '@typescript-eslint/parser': 5.62.0(eslint@8.54.0)(typescript@4.9.5) debug: 3.2.7 eslint: 8.54.0 eslint-import-resolver-node: 0.3.9 @@ -24794,7 +24796,7 @@ packages: '@typescript-eslint/parser': optional: true dependencies: - '@typescript-eslint/parser': 5.62.0(eslint@8.54.0)(typescript@4.9.3) + '@typescript-eslint/parser': 5.62.0(eslint@8.54.0)(typescript@4.9.5) array-includes: 3.1.7 array.prototype.findlastindex: 1.2.3 array.prototype.flat: 1.3.2