feat: 增强目标管理功能及相关组件
- 在 GoalsListScreen 中新增目标编辑功能,支持用户编辑现有目标 - 更新 CreateGoalModal 组件,支持编辑模式下的目标更新 - 在 NutritionRecordsScreen 中新增删除营养记录功能,允许用户删除不需要的记录 - 更新 NutritionRecordCard 组件,增加操作选项,支持删除记录 - 修改 dietRecords 服务,添加删除营养记录的 API 调用 - 优化 goalsSlice,确保目标更新逻辑与 Redux 状态管理一致
This commit is contained in:
@@ -53,8 +53,8 @@ export const getGoalById = async (goalId: string): Promise<ApiResponse<GoalDetai
|
||||
/**
|
||||
* 更新目标
|
||||
*/
|
||||
export const updateGoal = async (goalId: string, goalData: UpdateGoalRequest): Promise<ApiResponse<Goal>> => {
|
||||
return api.put<ApiResponse<Goal>>(`/goals/${goalId}`, goalData);
|
||||
export const updateGoal = async (goalId: string, goalData: UpdateGoalRequest): Promise<Goal> => {
|
||||
return api.put<Goal>(`/goals/${goalId}`, goalData);
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -106,33 +106,6 @@ export const batchOperateGoals = async (operationData: BatchGoalOperationRequest
|
||||
return api.post<ApiResponse<BatchGoalOperationResult[]>>('/goals/batch', operationData);
|
||||
};
|
||||
|
||||
/**
|
||||
* 暂停目标
|
||||
*/
|
||||
export const pauseGoal = async (goalId: string): Promise<ApiResponse<Goal>> => {
|
||||
return updateGoal(goalId, { status: 'paused' });
|
||||
};
|
||||
|
||||
/**
|
||||
* 恢复目标
|
||||
*/
|
||||
export const resumeGoal = async (goalId: string): Promise<ApiResponse<Goal>> => {
|
||||
return updateGoal(goalId, { status: 'active' });
|
||||
};
|
||||
|
||||
/**
|
||||
* 完成目标
|
||||
*/
|
||||
export const markGoalCompleted = async (goalId: string): Promise<ApiResponse<Goal>> => {
|
||||
return updateGoal(goalId, { status: 'completed' });
|
||||
};
|
||||
|
||||
/**
|
||||
* 取消目标
|
||||
*/
|
||||
export const cancelGoal = async (goalId: string): Promise<ApiResponse<Goal>> => {
|
||||
return updateGoal(goalId, { status: 'cancelled' });
|
||||
};
|
||||
|
||||
// 导出所有API方法
|
||||
export const goalsApi = {
|
||||
@@ -145,10 +118,6 @@ export const goalsApi = {
|
||||
getGoalCompletions,
|
||||
getGoalStats,
|
||||
batchOperateGoals,
|
||||
pauseGoal,
|
||||
resumeGoal,
|
||||
markGoalCompleted,
|
||||
cancelGoal,
|
||||
};
|
||||
|
||||
export default goalsApi;
|
||||
Reference in New Issue
Block a user