Skip to content

Free, Open Source, Self-Hosted WhatsApp API Gateway

fix(dashboard): export check times as ISO instants

Yudhi Armyndharis0bfb0935cade
diff --git a/dashboard/src/pages/NumberChecker.test.ts b/dashboard/src/pages/NumberChecker.test.ts
index eb8733804..8596f9493 100644
--- a/dashboard/src/pages/NumberChecker.test.ts
+++ b/dashboard/src/pages/NumberChecker.test.ts
@@ -261,6 +261,31 @@ test('NumberChecker: CSV export neutralizes error formulas and releases its obje
assert.equal(document.querySelector('a[download]'), null);
});
+test('NumberChecker: the CSV carries each check as an ISO instant while the table shows the time of day', async t => {
+ const downloads: Blob[] = [];
+ t.mock.method(URL, 'createObjectURL', (blob: Blob) => {
+ downloads.push(blob);
+ return 'blob:number-checker-csv';
+ });
+ t.mock.method(URL, 'revokeObjectURL');
+ t.mock.method(HTMLAnchorElement.prototype, 'click', () => {});
+ stubLookups(registered);
+
+ const { container } = renderComponent();
+ const textarea = await openBulkTab();
+ rtl.fireEvent.change(textarea, { target: { value: '919999999999' } });
+ rtl.fireEvent.click(rtl.screen.getByRole('button', { name: /Start Batch Check/i }));
+ await rtl.screen.findByText('+919999999999');
+ rtl.fireEvent.click(rtl.screen.getByRole('button', { name: /Export Results/i }));
+
+ const [, row] = (await downloads[0].text()).split('\n');
+ const checkedAt = row.split(',').at(-1) ?? '';
+ assert.match(checkedAt, /^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d\.\d{3}Z$/);
+ assert.equal(Number.isNaN(Date.parse(checkedAt)), false);
+ const shown = container.querySelector('.nc-history-table tbody td:last-child')?.textContent;
+ assert.equal(shown, new Date(checkedAt).toLocaleTimeString());
+});
+
test('NumberChecker: a rejected lookup is recorded as failed with error status, not as unregistered', async t => {
t.mock.method(HTMLAnchorElement.prototype, 'click', () => {});
const recordedDownloads: Blob[] = [];
diff --git a/dashboard/src/pages/NumberChecker.tsx b/dashboard/src/pages/NumberChecker.tsx
index bb3ebe5e2..ba5f8bf65 100644
--- a/dashboard/src/pages/NumberChecker.tsx
+++ b/dashboard/src/pages/NumberChecker.tsx
@@ -73,9 +73,12 @@ export interface CheckResultItem extends CheckNumberResponse {
status: CheckStatus;
error?: string | null;
avatarUrl?: string | null;
+ // ISO instant of the check: the CSV carries it as is, the tables show the time of day.
timestamp: string;
}
+const timeOfDay = (iso: string) => new Date(iso).toLocaleTimeString();
+
export function NumberChecker() {
const { t } = useTranslation();
useDocumentTitle(t('nav.numberChecker'));
@@ -229,7 +232,7 @@ export function NumberChecker() {
status: res.exists ? 'registered' : 'unregistered',
error: null,
avatarUrl: avatar,
- timestamp: new Date().toLocaleTimeString(),
+ timestamp: new Date().toISOString(),
};
setSingleResult(item);
@@ -289,7 +292,7 @@ export function NumberChecker() {
...res,
status: res.exists ? 'registered' : 'unregistered',
error: null,
- timestamp: new Date().toLocaleTimeString(),
+ timestamp: new Date().toISOString(),
};
results.push(item);
setBatchResults([...results]);
@@ -303,7 +306,7 @@ export function NumberChecker() {
whatsappId: null,
status: 'failed',
error: errorMsg,
- timestamp: new Date().toLocaleTimeString(),
+ timestamp: new Date().toISOString(),
});
setBatchResults([...results]);
@@ -599,7 +602,7 @@ export function NumberChecker() {
<div className="nc-detail-row">
<span className="nc-detail-label">{t('numberChecker.result.checkedAt')}</span>
<span className="nc-detail-value" style={{ fontFamily: 'inherit', fontWeight: 'normal' }}>
- <bdi>{singleResult.timestamp}</bdi>
+ <bdi>{timeOfDay(singleResult.timestamp)}</bdi>
</span>
</div>
</div>
@@ -678,7 +681,7 @@ export function NumberChecker() {
<bdi dir="ltr">{item.whatsappId || '-'}</bdi>
</td>
<td style={{ color: 'var(--text-muted)' }}>
- <bdi>{item.timestamp}</bdi>
+ <bdi>{timeOfDay(item.timestamp)}</bdi>
</td>
</tr>
))}
@@ -970,7 +973,7 @@ export function NumberChecker() {
<bdi dir="ltr">{item.whatsappId || '-'}</bdi>
</td>
<td style={{ color: 'var(--text-muted)' }}>
- <bdi>{item.timestamp}</bdi>
+ <bdi>{timeOfDay(item.timestamp)}</bdi>
</td>
</tr>
))}