feat(home): implement home summary feature with routes and use case
- Added home routes and corresponding route handler for fetching home summary. - Created GetHomeSummary use case to aggregate user data including groups, attendees, and upcoming payments. - Introduced HomeSummaryDto and related schemas for data validation. - Implemented nextClassOccurrence function to determine the next class based on user timezone. - Added tests for home summary functionality and next class occurrence logic.
This commit is contained in:
@@ -16,6 +16,7 @@ import type {
|
||||
GroupList,
|
||||
GroupWaitlistEntryDto,
|
||||
GroupWaitlistList,
|
||||
HomeSummaryDto,
|
||||
InviteTokenResult,
|
||||
JoinGroupViaInvite,
|
||||
JoinGroupViaInviteResult,
|
||||
@@ -88,6 +89,18 @@ export const createGroup = (payload: CreateFirstGroup) =>
|
||||
|
||||
export const getGroups = () => apiFetch<GroupList>('/api/v1/groups')
|
||||
|
||||
export const getHomeSummary = () => {
|
||||
let timeZone: string | undefined
|
||||
try {
|
||||
timeZone = Intl.DateTimeFormat().resolvedOptions().timeZone
|
||||
} catch {
|
||||
// Sin zona horaria disponible: el backend usa su valor por defecto.
|
||||
timeZone = undefined
|
||||
}
|
||||
const params = timeZone ? `?timeZone=${encodeURIComponent(timeZone)}` : ''
|
||||
return apiFetch<HomeSummaryDto>(`/api/v1/home${params}`)
|
||||
}
|
||||
|
||||
export const getGroup = (groupId: string) =>
|
||||
apiFetch<GroupDto>(`/api/v1/groups/${groupId}`)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user