Commit 1a36d75
Admin Profile View (#77)
## Notion ticket link
<!-- Please replace with your ticket's URL -->
[Ticket
Name](https://www.notion.so/uwblueprintexecs/Task-Board-db95cd7b93f245f78ee85e3a8a6a316d)
## Implementation description
* Replaced ad-hoc available_time records with recurring
`AvailabilityTemplate`s: new model + migrations, schema updates,
timezone
utilities, and service logic that creates/deletes template slots,
validates
input, and projects active templates when Hydrating users/admin lists.
* Added an admin `PATCH /users/{id}/user-data` flow backed by
`UserDataUpdateRequest`, expands `UserService` to materialize
treatments/
experiences/loved-one info, and ensures responses always include active
availability templates; extended seeds and helper scripts to
create/check/
undo match data plus availability seeding docs.
* Hardened `MatchService` to only attach suggestions for volunteers
with templates and to compare template weekdays in the volunteer’s
timezone before converting to UTC; added comprehensive unit
coverage (`test_availability_service`, `test_match_service`,
`test_match_service_timezone`, `test_user_data_update`).
* Built the admin user profile experience (`/admin/users/[id]`):
navigation
sidebar, profile summary card, editable cancer experience/loved-one
sections,
availability grid editor with drag-select, success messaging, and
supporting
hooks (`useUserProfile`, `useProfileEditing`, `useAvailabilityEditing`,
`useIntakeOptions`) plus Chakra-based UI components.
* Updated the admin directory/header to route into the new profile view,
expanded API clients/types/utilities to handle user-data patching +
availability templates, and added UI polish (single-select dropdown
upgrades,
user profile formatting helpers, date utilities, success banner, react-
datepicker).
## Steps to test
1. `docker-compose up -d` then run `cd backend && pdm run alembic
upgrade
head` to apply the availability template migrations.
2. `cd backend && pdm run dev` and `cd frontend && npm run dev`; sign in
to
the admin portal.
3. Visit `/admin/directory`, open any volunteer, and verify the profile
page
renders summary, profile, cancer, loved-one, and availability sections
with
existing data.
4. Click “Edit” in Profile Summary to update personal/demographic
fields,
save, and confirm the success toast plus persisted values via a hard
refresh;
repeat for cancer and loved-one sections (including clearing dates).
5. Use “Edit Availability” to drag-select new slots, save, and confirm
the
grid + subsequent reload reflect the template changes (verify via
network tab
hitting `/availability`).
6. Optional back-end verification: run `cd backend && pdm run tests
backend/tests/unit/test_availability_service.py backend/tests/unit/
test_match_service_timezone.py
backend/tests/unit/test_user_data_update.py`
to exercise the new logic, and use the helper scripts
(`create_test_matches.py`, `check_matches.py`, `undo_test_changes.py`)
to
inspect match suggestion behavior.
## What should reviewers focus on?
* **Migrations & data model:** ensure the `availability_templates`
migration,
seeds, and new helper scripts won’t clobber production data when rolled
out.
* **User data patching:** confirm `UserService.update_user_data_by_id`
correctly hydrates treatments/experiences and returns availability
templates
so the admin UI state stays consistent.
* **Matching/timezone logic:** double-check
`_attach_initial_suggested_times`
now uses volunteer-local weekdays and that suggested blocks remain
correct
across timezones.
* **Admin UI flows:** exercise the new hooks/components for editing
profile
sections and availability (loading states, drag interactions, and API
payloads) for both happy paths and cancellations.
* **API client/type updates:** watch for any regressions in other
consumers
now that `UserResponse` carries availability templates and the auth API
client maps the new schemas.
## Checklist
- [ ] My PR name is descriptive and in imperative tense
- [ ] My commit messages are descriptive and in imperative tense. My
commits
are atomic and trivial commits are squashed or fixup'd into non-trivial
commits
- [ ] I have run the appropriate linter(s)
- [ ] I have requested a review from the PL, as well as other devs who
have
background knowledge on this PR or who will be building on top of this
PR1 parent bb04542 commit 1a36d75
File tree
52 files changed
+6615
-399
lines changed- backend
- app
- models
- routes
- schemas
- seeds
- services/implementations
- utilities
- migrations/versions
- tests/unit
- frontend
- src
- APIClients
- components
- admin
- userProfile
- intake
- ui
- hooks
- pages/admin
- users
- types
- utils
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
52 files changed
+6615
-399
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
This file was deleted.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
18 | | - | |
19 | | - | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
48 | | - | |
49 | | - | |
| 48 | + | |
| 49 | + | |
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
9 | | - | |
10 | 8 | | |
11 | 9 | | |
| 10 | + | |
12 | 11 | | |
13 | 12 | | |
14 | 13 | | |
| |||
35 | 34 | | |
36 | 35 | | |
37 | 36 | | |
38 | | - | |
39 | 37 | | |
| 38 | + | |
40 | 39 | | |
41 | 40 | | |
42 | 41 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | | - | |
| 20 | + | |
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
14 | 15 | | |
15 | 16 | | |
16 | 17 | | |
| |||
89 | 90 | | |
90 | 91 | | |
91 | 92 | | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
92 | 109 | | |
93 | 110 | | |
94 | 111 | | |
| |||
110 | 127 | | |
111 | 128 | | |
112 | 129 | | |
| 130 | + | |
113 | 131 | | |
114 | 132 | | |
115 | 133 | | |
| |||
118 | 136 | | |
119 | 137 | | |
120 | 138 | | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
1 | 2 | | |
2 | 3 | | |
3 | 4 | | |
4 | 5 | | |
5 | 6 | | |
6 | | - | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
7 | 14 | | |
8 | 15 | | |
9 | 16 | | |
10 | 17 | | |
11 | | - | |
| 18 | + | |
12 | 19 | | |
13 | 20 | | |
14 | 21 | | |
| |||
22 | 29 | | |
23 | 30 | | |
24 | 31 | | |
25 | | - | |
| 32 | + | |
26 | 33 | | |
27 | 34 | | |
28 | 35 | | |
29 | 36 | | |
30 | | - | |
| 37 | + | |
31 | 38 | | |
32 | 39 | | |
33 | 40 | | |
34 | 41 | | |
35 | 42 | | |
36 | | - | |
37 | | - | |
38 | | - | |
| 43 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
12 | 16 | | |
13 | 17 | | |
14 | 18 | | |
| |||
135 | 139 | | |
136 | 140 | | |
137 | 141 | | |
| 142 | + | |
138 | 143 | | |
139 | 144 | | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
140 | 148 | | |
141 | 149 | | |
142 | 150 | | |
| |||
0 commit comments