Skip to content

Commit a223e83

Browse files
committed
feat(ui): show ISP brand icons in UserPaymentLogs
- add `src/react/utils/icons.ts` exporting `brandIcons` (im3, axis, unknown) and `statusIcons` - update `src/react/pages/dashboard/UserPaymentLogs.tsx` to: - import `brandIcons` and compute `isp`/`iconSrc` - render circular brand image when available, fall back to `TX` badge - refine `payment.details` typing and use a typed lookup to avoid TS indexing errors
1 parent 83ab17b commit a223e83

File tree

2 files changed

+49
-4
lines changed

2 files changed

+49
-4
lines changed

src/react/pages/dashboard/UserPaymentLogs.tsx

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { useEffect, useState } from 'react';
22
import type { LogEntry } from '../../../../types/php_backend/logs';
33
import { isEmpty } from '../../../utils/string';
44
import { getUserLogs } from '../../utils/user';
5+
import { brandIcons } from '../../utils/icons';
56

67
interface Props {
78
logs?: LogEntry[];
@@ -13,7 +14,18 @@ interface MergedLogEntry {
1314
tx?: string;
1415
created_at?: string;
1516
package_buy?: any;
16-
payment?: any;
17+
payment?: {
18+
[key: string]: any;
19+
details?: {
20+
[key: string]: any;
21+
package_id: number;
22+
package_name: string;
23+
package_desc: string;
24+
package_isp: string;
25+
status: 'missing' | 'pending' | 'successful' | 'error';
26+
transaction_id: string;
27+
};
28+
};
1729
}
1830

1931
export default function UserPaymentLogs({ logs: initialLogs, maxItems = 50, className = '' }: Props) {
@@ -214,6 +226,10 @@ export default function UserPaymentLogs({ logs: initialLogs, maxItems = 50, clas
214226

215227
// stable string id for key and openSections (prefer tx, fall back to ids or index)
216228
const id = entry.tx ?? `${pkg?.id ?? pay?.id ?? `no-tx-${i}`}`;
229+
// isp: axis, im3, unknown
230+
const isp = String(pkg?.details?.package_isp ?? pay?.details?.package_isp ?? 'unknown');
231+
// typed lookup to avoid TS indexing errors
232+
const iconSrc = (brandIcons as Record<string, string>)[isp];
217233

218234
return (
219235
<div
@@ -223,9 +239,15 @@ export default function UserPaymentLogs({ logs: initialLogs, maxItems = 50, clas
223239
<div className="px-3 py-2 flex items-center justify-between gap-3">
224240
<div className="flex items-center gap-3 min-w-0">
225241
<div className="flex-shrink-0">
226-
<div className="h-8 w-8 rounded-full bg-gray-100 dark:bg-gray-700 flex items-center justify-center text-xs text-gray-600">
227-
TX
228-
</div>
242+
{iconSrc ? (
243+
<div className="h-8 w-8 rounded-full bg-gray-100 dark:bg-gray-700 overflow-hidden flex items-center justify-center">
244+
<img src={iconSrc} alt={`${isp} logo`} className="h-full w-full object-cover" />
245+
</div>
246+
) : (
247+
<div className="h-8 w-8 rounded-full bg-gray-100 dark:bg-gray-700 flex items-center justify-center text-xs text-gray-600">
248+
TX
249+
</div>
250+
)}
229251
</div>
230252
<div className="min-w-0">
231253
<p className="text-sm font-medium text-gray-800 dark:text-gray-100 truncate">{id}</p>

src/react/utils/icons.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { createUrl } from './url';
2+
3+
export const statusIcons = {
4+
success: '✔️',
5+
error: '❌',
6+
warning: '⚠️',
7+
info: 'ℹ️'
8+
};
9+
export const brandIcons = {
10+
im3: createUrl(
11+
'/php_backend/img.php?url=' +
12+
encodeURIComponent('https://im3-img.indosatooredoo.com/indosatassets/images/GeraiOnline.jpg')
13+
),
14+
axis: createUrl(
15+
'/php_backend/img.php?url=' +
16+
encodeURIComponent(
17+
'https://upload.wikimedia.org/wikipedia/commons/thumb/8/83/Axis_logo_2015.svg/1200px-Axis_logo_2015.svg.png'
18+
)
19+
),
20+
unknown: createUrl(
21+
'/php_backend/img.php?url=' + encodeURIComponent('https://www.pikpng.com/pngl/b/597-5973888_unknown-png.png')
22+
)
23+
};

0 commit comments

Comments
 (0)