Assignments > HW4: Frontend Integration
Due Tue, 02/24 at 11:59pm
Assigned Readings
For this homework assignment, your team will implement Module CRUD in the web UI, similar to the reference implementation in the instructor’s health-app UI. This involves
- Implementing Create / Read / Update / Delete for Modules in
tma-starter-app/ui. - Handling loading / error / empty / success states.
- Keeping your code TypeScript-safe and easy to adjust if your endpoint shape changes.
You can parallelize this work if you agree on shared types + helper functions early. Start by creating GitHub issues that match the “Person X checklist” items in Section 6, then have each person work from their issues.
1. New Files to Add
Your UI does not need to match these files exactly, but the behavior should feel similar.
| Component | File |
|---|---|
| Create module page | ui/src/pages/courses/CreateModulePage.tsx |
| Module detail page (edit + delete) | ui/src/pages/courses/ModuleDetailPage.tsx |
| Edit modal | ui/src/components/courses/EditModuleModal.tsx |
| Module API helpers (Module section) | ui/src/utils/api.ts |
| Module types (Module section) | health-app/ui/src/types/api.ts |
2. Team workflow requirement
- Each teammate must open at least one PR that includes React/TypeScript changes.
- All HW4 changes must be merged into
mainby the deadline. - Before coding, create issues for your work:
- Make 1+ GitHub issues per teammate (one per “Person X checklist” in Section 6 works well).
- Put a short checklist + acceptance criteria in each issue (what should work when you’re done).
- Assign each issue to one person.
- Each PR should reference the issue(s) it addresses (and close them when merged).
3. UI requirements (Module CRUD)
3.1. Where the UI should live Everyone
- Add Module UI under the Course area (recommended), so Modules feel “part of Courses”.
- At minimum, support deep links to a module page via a route (not just a modal).
3.2. Routes Person 1
Add routes in tma-starter-app/ui/src/App.tsx similar to how other dashboard routes are defined.
- Create module route (example):
/dashboard/courses/:courseId/modules/new - Module detail route (example):
/dashboard/courses/:courseId/modules/:moduleId
If your backend does not use courseId in the module endpoints, you can still keep these routes for the UI.
3.3. List/Read Person 2
- Update the course detail page (
tma-starter-app/ui/src/pages/courses/CourseDetailPage.tsx) to show a Modules section. - Show a “Create Module” action that navigates to the create page route.
- Each module should be clickable to navigate to its Module detail route.
- Handle UI states: loading, error, empty, success.
3.4. Create Person 3
-
Build a Create Module page with a simple form:
title(required)description(optional)color(optional)
-
On submit, call your backend “create module” endpoint and then navigate back to the course detail page (or the new module’s detail page).
-
You can eventually refactor this page’s form into a reusable component (for example, to reuse it in a modal).
3.5. Update Person 4
- On the Module detail page, provide an “Edit” action.
- Your edit UI can be a modal (like the reference) or a separate edit page.
- On submit, call your backend “update module” endpoint and refresh the displayed module data.
3.6. Delete Person 5 (optional)
- On the Module detail page, provide a “Delete” action.
- Ask for confirmation before deleting.
- If delete succeeds, navigate back to the course detail page (or a modules list).
- If delete fails (for example due to dependencies), show the error message.
4. TypeScript + code organization requirements Person 1 Everyone
-
Define
Module,ModuleCreate, andModuleUpdatetypes that match your backend. -
No
anyfor module data or props. -
Put module API calls in one place (either):
- Add a “Module API” section to
tma-starter-app/ui/src/utils/api.ts, or - Create a new file like
tma-starter-app/ui/src/utils/modulesApi.ts).
- Add a “Module API” section to
5. Minimal testing requirement
- Add 2 Vitest tests for one pure helper you wrote for this feature (examples:
buildModulesUrl,normalizeApiError,validateModuleTitle). - Keep tests small: test logic, not Mantine widgets.
6. Suggested Division of Labor
Person 1 (shared foundations)
Module, ModuleCreate, and ModuleUpdate types in one shared place (see Section 4). (ui/src/types/api.ts)ui/src/utils/api.ts or ui/src/utils/modulesApi.ts)tma-starter-app/ui/src/App.tsx (see Section 3.2). (ui/src/App.tsx)Person 2 (Course detail “Modules” section)
Update ui/src/pages/courses/CourseDetailPage.tsx.
Person 3 checklist (Create Module page)
Update ui/src/pages/courses/CreateModulePage.tsx.
Person 4 checklist (Module detail + Edit)
Update ui/src/pages/courses/ModuleDetailPage.tsx (and optionally ui/src/components/courses/EditModuleModal.tsx if using a modal for editing).
Person 5 checklist (optional: Delete + testing + polish)
ui/src/pages/courses/ModuleDetailPage.tsx)ui/src/pages/courses/ModuleDetailPage.tsx)ui/src/utils/api.test.ts or similar)7. Individual Reflection
Each student must complete an individual reflection in their shared Google document (LastName_FirstName_373).
Under today’s date, respond (200–350 words total):
- How did working with shared types and API helpers (or coordinating without them) affect your development process?
- What was most challenging about building the Module CRUD UI? Why?
- Since you’re working with a new team for this assignment, how did you establish workflow and coordinate work? What worked well, and what would you do differently?
Paste your reflection into the Weekly Reflection Form as usual.
8. Submission Checklist
Team Requirements
Implementation
Module, ModuleCreate, ModuleUpdate)Process
main by the deadline