( day: PatchyDay, activity: PatchyActivity, now: Date, )
| 65 | |
| 66 | // Pure: the day after one more activity. |
| 67 | export const addPatchyActivity = ( |
| 68 | day: PatchyDay, |
| 69 | activity: PatchyActivity, |
| 70 | now: Date, |
| 71 | ): PatchyDay => { |
| 72 | const base = day.day === getPatchyDayKey(now) ? day : createPatchyDay(now); |
| 73 | const counter = counterFor[activity]; |
| 74 | const next: PatchyDay = { ...base }; |
| 75 | if (counter) { |
| 76 | next[counter] = base[counter] + 1; |
| 77 | } |
| 78 | return next; |
| 79 | }; |
| 80 | |
| 81 | const storageKey = (userId: string) => `patchy_day:${userId}`; |
| 82 |
no test coverage detected