-
Notifications
You must be signed in to change notification settings - Fork 0
PAPER-08: Wire Today dossier to real backend APIs #1056
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Chris0Jeky
wants to merge
13
commits into
main
Choose a base branch
from
paper/1004-today-dossier-api-wiring
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
66b16a6
Add todayApi HTTP client module for Today dossier endpoints
Chris0Jeky 9c33999
Wire useTodayDossier composable to real backend APIs
Chris0Jeky 1dedeb8
Make onSeal async to match async sealDay return type
Chris0Jeky 9d6b9cc
Update existing today tests to mock todayApi module
Chris0Jeky 8c4a002
Add todayApi module tests with mocked HTTP
Chris0Jeky e496a84
Add useTodayDossier composable tests for live and fallback paths
Chris0Jeky 0bd4ba0
fix(composable): HIGH race condition, sealDay error, autosave flush
Chris0Jeky df6917f
fix(api): LOW widen validateStatus to accept all 2xx codes
Chris0Jeky 062e9a4
Address review findings: wire saveLineForTomorrow, fix 204 empty stat…
Chris0Jeky 7667932
Gate seal success toast on actual seal result
Chris0Jeky caffa36
Harden Today dossier save states
Chris0Jeky 8a76f72
Harden Today note autosave states
Chris0Jeky c84d715
Guard Today note hydration race
Chris0Jeky File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| import http from './http' | ||
|
|
||
| export interface CadenceBucket { | ||
| hour: number | ||
| eventCount: number | ||
| } | ||
|
|
||
| export interface CadenceApiResponse { | ||
| buckets: CadenceBucket[] | ||
| firstActionAt: string | null | ||
| peakHour: number | null | ||
| lastActionAt: string | null | ||
| } | ||
|
|
||
| export interface StreakDay { | ||
| date: string | ||
| isSealed: boolean | ||
| intensityBucket: number | ||
| } | ||
|
|
||
| export interface StreakApiResponse { | ||
| days: StreakDay[] | ||
| currentStreakLength: number | ||
| longestStreakLength: number | ||
| dayCount: number | ||
| } | ||
|
|
||
| export interface SealApiResponse { | ||
| sealedAt: string | ||
| wasAlreadySealed: boolean | ||
| } | ||
|
|
||
| export interface SealStatusApiResponse { | ||
| date: string | ||
| isSealed: boolean | ||
| sealedAt: string | null | ||
| } | ||
|
|
||
| export interface TomorrowNoteApiResponse { | ||
| id: string | ||
| date: string | ||
| text: string | ||
| updatedAt: string | ||
| createdAt: string | ||
| } | ||
|
|
||
| export const todayApi = { | ||
| async getCadence(date: string): Promise<CadenceApiResponse> { | ||
| const { data } = await http.get<CadenceApiResponse>(`/today/cadence?date=${encodeURIComponent(date)}`) | ||
| return data | ||
| }, | ||
|
|
||
| async getStreak(days = 90): Promise<StreakApiResponse> { | ||
| const { data } = await http.get<StreakApiResponse>(`/today/streak?days=${days}`) | ||
| return data | ||
| }, | ||
|
|
||
| async sealDay(date: string): Promise<SealApiResponse> { | ||
| const { data } = await http.post<SealApiResponse>('/today/seal', { date }) | ||
| return data | ||
| }, | ||
|
|
||
| async getSealStatus(date: string): Promise<SealStatusApiResponse> { | ||
| const { data } = await http.get<SealStatusApiResponse>(`/today/seal?date=${encodeURIComponent(date)}`) | ||
| return data | ||
| }, | ||
|
|
||
| async getTomorrowNote(date: string): Promise<TomorrowNoteApiResponse | null> { | ||
| const response = await http.get<TomorrowNoteApiResponse>(`/today/tomorrow-note?date=${encodeURIComponent(date)}`) | ||
| if (response.status === 204) return null | ||
| return response.data | ||
| }, | ||
|
|
||
| async saveTomorrowNote(date: string, text: string): Promise<TomorrowNoteApiResponse> { | ||
| const { data } = await http.put<TomorrowNoteApiResponse>('/today/tomorrow-note', { date, text }) | ||
| return data | ||
| }, | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When the backend returns an empty cadence day (
peakHour: null), this fallback setspeakHourIndexto0, soTodayCadencehighlights midnight as the peak bar even thoughpeakActionsaysno peak. This creates contradictory and misleading UI on no-activity days. Keep the "no peak" state through to rendering (e.g., nullable/sentinel peak index) so no bar is emphasized when there is no peak hour.Useful? React with 👍 / 👎.