refactor(Planning): 投资规划中心重构为 Redux 状态管理
- 新增 planningSlice 管理计划/复盘数据 - InvestmentPlanningCenter 改用 Redux 而非本地 state - 列表和日历视图共享同一数据源,保持同步 - 优化 Mock handlers,改进事件 ID 生成和调试日志 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -351,15 +351,21 @@ export const accountHandlers = [
|
||||
const body = await request.json();
|
||||
console.log('[Mock] 创建投资计划:', body);
|
||||
|
||||
// 生成唯一 ID(使用时间戳避免冲突)
|
||||
const newId = Date.now();
|
||||
|
||||
const newPlan = {
|
||||
id: mockInvestmentPlans.length + 301,
|
||||
id: newId,
|
||||
user_id: currentUser.id,
|
||||
...body,
|
||||
// 确保 target_date 字段存在(兼容前端发送的 date 字段)
|
||||
target_date: body.target_date || body.date,
|
||||
created_at: new Date().toISOString(),
|
||||
updated_at: new Date().toISOString()
|
||||
};
|
||||
|
||||
mockInvestmentPlans.push(newPlan);
|
||||
console.log('[Mock] 新增计划/复盘,当前总数:', mockInvestmentPlans.length);
|
||||
|
||||
return HttpResponse.json({
|
||||
success: true,
|
||||
@@ -488,13 +494,22 @@ export const accountHandlers = [
|
||||
});
|
||||
}
|
||||
|
||||
// 打印今天的事件(方便调试)
|
||||
const today = new Date().toISOString().split('T')[0];
|
||||
const todayEvents = filteredEvents.filter(e =>
|
||||
(e.date === today || e.event_date === today)
|
||||
);
|
||||
|
||||
console.log('[Mock] 日历事件详情:', {
|
||||
currentUserId: currentUser.id,
|
||||
calendarEvents: calendarEvents.length,
|
||||
investmentPlansAsEvents: investmentPlansAsEvents.length,
|
||||
total: filteredEvents.length,
|
||||
plansCount: filteredEvents.filter(e => e.type === 'plan').length,
|
||||
reviewsCount: filteredEvents.filter(e => e.type === 'review').length
|
||||
reviewsCount: filteredEvents.filter(e => e.type === 'review').length,
|
||||
today,
|
||||
todayEventsCount: todayEvents.length,
|
||||
todayEventTitles: todayEvents.map(e => `[${e.type}] ${e.title}`)
|
||||
});
|
||||
|
||||
return HttpResponse.json({
|
||||
|
||||
Reference in New Issue
Block a user