-
Notifications
You must be signed in to change notification settings - Fork 22
fix: hardcode facilities per carolina and for maine deployment #1213
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
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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
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
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
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
85 changes: 69 additions & 16 deletions
85
frontend/src/pages/student/digital-transcript/useLearningRecordFacilities.ts
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 |
|---|---|---|
| @@ -1,29 +1,82 @@ | ||
| import useSWR from 'swr'; | ||
| // import useSWR from 'swr'; | ||
| import type { LearningRecordFacility } from '@/api/learningRecord'; | ||
| import type { ServerResponseMany } from '@/types/server'; | ||
| // import type { ServerResponseMany } from '@/types/server'; | ||
|
|
||
| /** | ||
| * Facilities for the achievement location dropdown. SWR dedupes the request | ||
| * across every mounted form row, so this fetches once rather than once per row. | ||
| * TEMPORARY (pilot): the Maine women's facilities, hardcoded. | ||
| * | ||
| * A failed load must never be cached as an empty list: residents would silently | ||
| * lose the real facility list for the rest of the session and could only pick | ||
| * "Other", turning a structured facility_id into free text. SWR keeps `data` | ||
| * undefined on error, so the next mount refetches. | ||
| * The pilot is specific to SMWRC, which houses only women, so the dropdown must | ||
| * not offer every facility in the tool — men's facilities are not valid answers | ||
| * here. Until the tool can distinguish men's from women's facilities, these are | ||
| * the only two listed; anything else goes under "Other (not listed)". | ||
| * | ||
| * The ids are the real facility ids, so entries still save a structured | ||
| * facility_id and the backend join keeps working unchanged. | ||
| * | ||
| * The `GET /api/learning-record/facilities` route stays in place and is only | ||
| * commented out below — restore the SWR fetch to undo this. | ||
| */ | ||
| const SMWRC: LearningRecordFacility = { id: 2, name: 'SMWRC' }; | ||
| const WOMENS_CENTER_MCC: LearningRecordFacility = { | ||
| id: 3, | ||
| name: "Women's Center (MCC)" | ||
| }; | ||
|
|
||
| const PILOT_FACILITIES: LearningRecordFacility[] = [SMWRC, WOMENS_CENTER_MCC]; | ||
|
|
||
| /** | ||
| * TEMPORARY (pilot): prefilled as the location on new achievements, since the | ||
| * pilot runs at SMWRC. Replaces the resident's own facility as the default — | ||
| * see the commented-out derivation in DigitalTranscriptWysiwygEntry. | ||
| */ | ||
| export const PILOT_DEFAULT_FACILITY: LearningRecordFacility = SMWRC; | ||
|
|
||
| /** | ||
| * Facilities for the achievement location dropdown. | ||
| * | ||
| * While the pilot list is hardcoded there is nothing to load and nothing that | ||
| * can fail, so `loaded` is always true and `failed` always false. The shape is | ||
| * unchanged from the fetching version so restoring the fetch touches only this | ||
| * file. | ||
| */ | ||
| export function useLearningRecordFacilities(): { | ||
| facilities: LearningRecordFacility[]; | ||
| loaded: boolean; | ||
| failed: boolean; | ||
| } { | ||
| const { data, error, isLoading } = useSWR< | ||
| ServerResponseMany<LearningRecordFacility>, | ||
| Error | ||
| >('/api/learning-record/facilities'); | ||
|
|
||
| return { | ||
| facilities: data?.data ?? [], | ||
| loaded: !isLoading, | ||
| failed: !!error | ||
| facilities: PILOT_FACILITIES, | ||
| loaded: true, | ||
| failed: false | ||
| }; | ||
| } | ||
|
|
||
| /* | ||
| * Pre-pilot implementation — restore this (and the imports above) once the | ||
| * facility list can be filtered server-side. | ||
| * | ||
| * SWR dedupes the request across every mounted form row, so this fetches once | ||
| * rather than once per row. | ||
| * | ||
| * A failed load must never be cached as an empty list: residents would silently | ||
| * lose the real facility list for the rest of the session and could only pick | ||
| * "Other", turning a structured facility_id into free text. SWR keeps `data` | ||
| * undefined on error, so the next mount refetches. | ||
| * | ||
| * export function useLearningRecordFacilities(): { | ||
| * facilities: LearningRecordFacility[]; | ||
| * loaded: boolean; | ||
| * failed: boolean; | ||
| * } { | ||
| * const { data, error, isLoading } = useSWR< | ||
| * ServerResponseMany<LearningRecordFacility>, | ||
| * Error | ||
| * >('/api/learning-record/facilities'); | ||
| * | ||
| * return { | ||
| * facilities: data?.data ?? [], | ||
| * loaded: !isLoading, | ||
| * failed: !!error | ||
| * }; | ||
| * } | ||
| */ |
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.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Restore a meaningful grouping comment.
The comment contains
dat asdfaeand no longer explains that activities are grouped by date. Replace it with accurate wording such as// Combine activities by date.🤖 Prompt for AI Agents