Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export const BusinessReportSchema = z
reportType: z.enum([MERCHANT_REPORT_TYPES[0]!, ...MERCHANT_REPORT_TYPES.slice(1)]),
createdAt: z.string().datetime(),
updatedAt: z.string().datetime(),
displayDate: z.string().datetime(),
riskScore: z.number().nullable(),
status: z.enum([MERCHANT_REPORT_STATUSES[0]!, ...MERCHANT_REPORT_STATUSES.slice(1)]),
parentCompanyName: z.string().nullable(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,16 +153,12 @@ export const columns = [
},
header: 'Alert',
}),
columnHelper.accessor('createdAt', {
columnHelper.accessor('displayDate', {
cell: info => {
const createdAt = info.getValue();

if (!createdAt) {
return <TextWithNAFallback>{createdAt}</TextWithNAFallback>;
}
const displayDate = info.getValue();

// Convert UTC time to local browser time
const localDateTime = dayjs.utc(createdAt).local();
const localDateTime = dayjs.utc(displayDate).local();

const date = localDateTime.format('MMM DD, YYYY');
const time = localDateTime.format('HH:mm');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,8 +272,8 @@ export const MerchantMonitoringBusinessReport: FunctionComponent = () => {
</div>
<div className={`text-sm`}>
<span className={`me-2 leading-6 text-slate-400`}>Created at</span>
{businessReport?.createdAt &&
dayjs(new Date(businessReport?.createdAt)).format('HH:mm MMM Do, YYYY')}
{businessReport?.displayDate &&
dayjs(new Date(businessReport?.displayDate)).format('HH:mm MMM Do, YYYY')}
Comment on lines +275 to +276
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codebase verification

Date formatting and timezone handling needs standardization

The current implementation has several issues:

  • The date format 'HH:mm MMM Do, YYYY' is inconsistent with other date formats in the codebase
  • Redundant new Date() wrapper is unnecessary as dayjs can parse the date string directly
  • Timezone handling should be explicitly defined (UTC vs local) for consistency

Suggested changes:

dayjs(businessReport?.displayDate).format('DD/MM/YYYY HH:mm')
🔗 Analysis chain

LGTM! Verify date handling across time zones.

The change from createdAt to displayDate is consistent with the schema updates. The date formatting remains correct.

Please ensure that:

  1. The date is correctly displayed across different time zones
  2. The format 'HH:mm MMM Do, YYYY' is consistently used across the application
  3. Dayjs plugins (utc, timezone) are properly configured
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for consistent date formatting across the codebase
echo "Checking for date format consistency:"
rg -l "dayjs\(.*\)\.format\(" | xargs rg "format\(['\"].*['\"]\)"

Length of output: 8189

</div>
<div className={`flex items-center space-x-2 text-sm`}>
<span className={`text-slate-400`}>Monitoring Status</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export class BusinessReportService {

if (businessReportsCount >= maxBusinessReports) {
throw new BadRequestException(
`You have reached the maximum number of business reports allowed (${maxBusinessReports}).`,
`You've hit your reports limit. Talk to us to unlock additional features and continue effective risk management with Ballerine.`,
);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ const ReportSchema = z.object({
.string()
.datetime()
.transform(value => new Date(value)),
displayDate: z
.string()
.datetime()
.transform(value => new Date(value)),
data: z.record(z.string(), z.unknown()).nullish(),
});

Expand Down