feat(web): add account list and form components

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-05-07 02:30:32 +08:00
parent 93e67bb8dc
commit c9fe380d0d
3 changed files with 214 additions and 1 deletions

View File

@@ -0,0 +1,20 @@
import { useState, useEffect, useCallback } from 'react';
import { api } from '@/lib/api';
import type { Account } from '@/types';
export function useAccounts() {
const [accounts, setAccounts] = useState<Account[]>([]);
const [loading, setLoading] = useState(true);
const refresh = useCallback(() => {
api.listAccounts().then(setAccounts).finally(() => setLoading(false));
}, []);
useEffect(() => { refresh(); }, [refresh]);
const create = (data: Partial<Account>) => api.createAccount(data).then(refresh);
const update = (id: string, data: Partial<Account>) => api.updateAccount(id, data).then(refresh);
const remove = (id: string) => api.deleteAccount(id).then(refresh);
return { accounts, loading, refresh, create, update, remove };
}