fix: show sms receipt details with local time

This commit is contained in:
hectorzhao
2026-07-09 16:51:24 +08:00
parent 3ed5f51bae
commit 57a4c86a79
2 changed files with 31 additions and 4 deletions
+30 -4
View File
@@ -46,12 +46,38 @@ type RouteRow = {
submitStatus?: string | null;
};
function formatLocalDateTime(value?: string | null) {
if (!value) {
return null;
}
const date = new Date(value);
if (Number.isNaN(date.getTime())) {
return null;
}
const parts = new Intl.DateTimeFormat('zh-CN', {
timeZone: 'Asia/Shanghai',
hour12: false,
year: 'numeric',
month: '2-digit',
day: '2-digit',
hour: '2-digit',
minute: '2-digit',
second: '2-digit',
}).formatToParts(date);
const partMap = Object.fromEntries(parts.map((part) => [part.type, part.value]));
return `${partMap.year}-${partMap.month}-${partMap.day} ${partMap.hour}:${partMap.minute}:${partMap.second}`;
}
function getDate(value?: string | null) {
return value ? value.slice(0, 10) : '';
return formatLocalDateTime(value)?.slice(0, 10) ?? '';
}
function getTime(value?: string | null) {
return value ? `${value.slice(0, 10)} ${value.slice(11, 19)}` : '-';
return formatLocalDateTime(value) ?? '-';
}
function getClock(value?: string | null) {
return formatLocalDateTime(value)?.slice(11, 19) ?? '-';
}
function getStatusLabel(status?: string | null) {
@@ -233,7 +259,7 @@ export function AdminSmsRecordsPage() {
const [error, setError] = useState('');
function loadData() {
adminApi.listAdminMessages({
adminApi.listOperationMessages({
tenantId: enterprise === 'all' ? undefined : enterprise,
applicationId: application === 'all' ? undefined : application,
phoneNumber: phoneKeyword || undefined,
@@ -385,7 +411,7 @@ export function AdminSmsRecordsPage() {
<div className="admin-sms-record-sender">
<strong>{record.tenant?.name ?? record.tenantId}</strong>
<span>{record.application?.name ?? record.applicationId ?? '-'}</span>
<small>{getDate(record.queuedAt)}<br />{record.queuedAt.slice(11, 19)}</small>
<small>{getDate(record.queuedAt)}<br />{getClock(record.queuedAt)}</small>
</div>
</td>
<td><p className="admin-sms-record-content">{record.content}</p></td>