ui update and some backend functionality adding in accordance with research on adhd and ux design

This commit is contained in:
2026-02-14 17:21:37 -06:00
parent 4d3a9fbd54
commit fb480eacb2
32 changed files with 9549 additions and 248 deletions

View File

@@ -20,6 +20,7 @@ async function request<T>(
const token = getToken();
const headers: HeadersInit = {
'Content-Type': 'application/json',
'X-Timezone-Offset': String(new Date().getTimezoneOffset()),
...(token ? { Authorization: `Bearer ${token}` } : {}),
...options.headers,
};
@@ -375,6 +376,14 @@ export const api = {
duration_minutes?: number;
position: number;
} | null;
celebration?: {
streak_current: number;
streak_longest: number;
session_duration_minutes: number;
total_completions: number;
steps_completed: number;
steps_skipped: number;
};
}>(`/api/sessions/${sessionId}/complete-step`, {
method: 'POST',
body: JSON.stringify({ step_id: stepId }),
@@ -392,6 +401,14 @@ export const api = {
duration_minutes?: number;
position: number;
} | null;
celebration?: {
streak_current: number;
streak_longest: number;
session_duration_minutes: number;
total_completions: number;
steps_completed: number;
steps_skipped: number;
};
}>(`/api/sessions/${sessionId}/skip-step`, {
method: 'POST',
body: JSON.stringify({ step_id: stepId }),
@@ -546,6 +563,68 @@ export const api = {
},
},
// Victories
victories: {
get: async (days = 30) => {
return request<Array<{
type: string;
message: string;
date?: string;
}>>(`/api/victories?days=${days}`, { method: 'GET' });
},
},
// Rewards
rewards: {
getRandom: async (context = 'completion') => {
return request<{
reward: {
id: string;
category: string;
content: string;
emoji?: string;
rarity: string;
} | null;
}>(`/api/rewards/random?context=${context}`, { method: 'GET' });
},
getHistory: async () => {
return request<Array<{
earned_at: string;
context?: string;
category: string;
content: string;
emoji?: string;
rarity?: string;
}>>('/api/rewards/history', { method: 'GET' });
},
},
// Preferences
preferences: {
get: async () => {
return request<{
sound_enabled: boolean;
haptic_enabled: boolean;
show_launch_screen: boolean;
celebration_style: string;
}>('/api/preferences', { method: 'GET' });
},
update: async (data: {
sound_enabled?: boolean;
haptic_enabled?: boolean;
show_launch_screen?: boolean;
celebration_style?: string;
timezone_offset?: number;
}) => {
return request<Record<string, unknown>>('/api/preferences', {
method: 'PUT',
body: JSON.stringify(data),
});
},
},
// Notifications
notifications: {
getVapidPublicKey: async () => {