feat(challenges): 新增 ChallengeProgressCard 组件并接入喝水挑战进度上报
- 抽离进度卡片为独立组件,支持主题色自定义与复用 - 挑战列表页顶部展示进行中的挑战进度 - 喝水记录自动上报至关联的水挑战 - 移除旧版 challengeSlice 与冗余进度样式 - 统一使用 value 字段上报进度,兼容多类型挑战
This commit is contained in:
@@ -16,6 +16,17 @@ export type RankingItemDto = {
|
||||
badge?: string;
|
||||
};
|
||||
|
||||
export enum ChallengeType {
|
||||
WATER = 'water',
|
||||
EXERCISE = 'exercise',
|
||||
DIET = 'diet',
|
||||
MOOD = 'mood',
|
||||
SLEEP = 'sleep',
|
||||
WEIGHT = 'weight',
|
||||
}
|
||||
|
||||
|
||||
|
||||
export type ChallengeListItemDto = {
|
||||
id: string;
|
||||
title: string;
|
||||
@@ -34,6 +45,7 @@ export type ChallengeListItemDto = {
|
||||
startAt?: string;
|
||||
endAt?: string;
|
||||
minimumCheckInDays: number; // 最小打卡天数
|
||||
type: ChallengeType;
|
||||
};
|
||||
|
||||
export type ChallengeDetailDto = ChallengeListItemDto & {
|
||||
@@ -58,7 +70,7 @@ export async function leaveChallenge(id: string): Promise<boolean> {
|
||||
return api.post<boolean>(`/challenges/${encodeURIComponent(id)}/leave`);
|
||||
}
|
||||
|
||||
export async function reportChallengeProgress(id: string, increment?: number): Promise<ChallengeProgressDto> {
|
||||
const body = increment != null ? { increment } : undefined;
|
||||
export async function reportChallengeProgress(id: string, value?: number): Promise<ChallengeProgressDto> {
|
||||
const body = value != null ? { value } : undefined;
|
||||
return api.post<ChallengeProgressDto>(`/challenges/${encodeURIComponent(id)}/progress`, body);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user