feat(client): add Timestamp component, ESLint 10 + Prettier, and code quality fixes
- add Timestamp component with moment relative time and ISO tooltip - add Timestamp stories (JustNow, MinutesAgo, HoursAgo, DaysAgo, MonthsAgo) - add ESLint 10 with typescript-eslint, react-hooks, react-refresh, prettier - add Prettier config with singleQuote, semi, trailingComma all, printWidth 100 - add lint, lint:fix, format, test:storybook scripts to package.json - fix react-hooks/set-state-in-effect in all page components - auto-fix 113 Prettier formatting issues across src and .storybook
This commit is contained in:
@@ -2,7 +2,7 @@ import { useCallback, useEffect, useState } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { sessions } from '../api';
|
||||
import type { Session } from '../api';
|
||||
import { Badge, Button, Table, type TableColumn } from '../ui';
|
||||
import { Badge, Button, Table, type TableColumn, Timestamp } from '../ui';
|
||||
import styles from './Page.module.css';
|
||||
|
||||
export function SessionsPage() {
|
||||
@@ -12,38 +12,39 @@ export function SessionsPage() {
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
|
||||
const load = useCallback(() => {
|
||||
setLoading(true);
|
||||
sessions.list()
|
||||
sessions
|
||||
.list()
|
||||
.then((res) => setItems(res.data))
|
||||
.catch((err: Error) => setError(err.message))
|
||||
.finally(() => setLoading(false));
|
||||
}, []);
|
||||
|
||||
useEffect(load, [load]);
|
||||
useEffect(() => {
|
||||
load();
|
||||
}, [load]);
|
||||
|
||||
const handleDelete = async (id: number) => {
|
||||
await sessions.remove(id);
|
||||
setLoading(true);
|
||||
load();
|
||||
};
|
||||
|
||||
const columns: TableColumn<Session>[] = [
|
||||
{ key: 'id', header: t('sessions.col_id'), render: (s) => s.id, width: 60 },
|
||||
{ key: 'name', header: t('sessions.col_name'), render: (s) => s.sessionName },
|
||||
{ key: 'id', header: t('sessions.col_id'), render: (s) => s.id, width: 60 },
|
||||
{ key: 'name', header: t('sessions.col_name'), render: (s) => s.sessionName },
|
||||
{
|
||||
key: 'status',
|
||||
header: t('sessions.col_status'),
|
||||
width: 100,
|
||||
render: (s) => (
|
||||
<Badge variant={s.status === 'open' ? 'success' : 'neutral'}>
|
||||
{s.status}
|
||||
</Badge>
|
||||
<Badge variant={s.status === 'open' ? 'success' : 'neutral'}>{s.status}</Badge>
|
||||
),
|
||||
},
|
||||
{
|
||||
key: 'lastUsed',
|
||||
header: t('sessions.col_lastUsed'),
|
||||
width: 160,
|
||||
render: (s) => s.lastUsedAt ? new Date(s.lastUsedAt).toLocaleString() : '—',
|
||||
render: (s) => (s.lastUsedAt ? <Timestamp value={s.lastUsedAt} /> : '—'),
|
||||
},
|
||||
{
|
||||
key: 'actions',
|
||||
|
||||
Reference in New Issue
Block a user