chore: update frontend/src/services/accounts.ts
This commit is contained in:
@@ -10,14 +10,13 @@
|
|||||||
*/
|
*/
|
||||||
import { apiClient } from './apiClient';
|
import { apiClient } from './apiClient';
|
||||||
import type { Account } from '../types';
|
import type { Account } from '../types';
|
||||||
|
import { useUserStore } from '../stores/userStore';
|
||||||
// Mock 用户 ID - 后续应从认证上下文动态获取
|
|
||||||
const USER_ID = 6;
|
|
||||||
|
|
||||||
export const accountsApi = {
|
export const accountsApi = {
|
||||||
// API: GET /api/accounts - 获取当前用户的所有账户
|
// API: GET /api/accounts - 获取当前用户的所有账户
|
||||||
async getAccounts(): Promise<Account[]> {
|
async getAccounts(): Promise<Account[]> {
|
||||||
const response = await apiClient.get<Account[]>('/accounts', { userId: USER_ID });
|
const userId = useUserStore.getState().userId;
|
||||||
|
const response = await apiClient.get<Account[]>('/accounts', { userId });
|
||||||
return response.data;
|
return response.data;
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -29,7 +28,8 @@ export const accountsApi = {
|
|||||||
|
|
||||||
// API: POST /api/accounts - 创建新账户,自动关联当前用户
|
// API: POST /api/accounts - 创建新账户,自动关联当前用户
|
||||||
async createAccount(data: Omit<Account, 'id' | 'createdAt' | 'updatedAt'>): Promise<Account> {
|
async createAccount(data: Omit<Account, 'id' | 'createdAt' | 'updatedAt'>): Promise<Account> {
|
||||||
const response = await apiClient.post<Account>('/accounts', { ...data, userId: USER_ID });
|
const userId = useUserStore.getState().userId;
|
||||||
|
const response = await apiClient.post<Account>('/accounts', { ...data, userId });
|
||||||
return response.data;
|
return response.data;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user