wire frontend to real APIs - #303
Conversation
nourshoreibah
left a comment
There was a problem hiding this comment.
Some comments on pieces I think may be broken! Would you please add the test-environment label to this pr and test your pr with the account i sent in proj-branch? just to make sure the linking actually workss
|
|
||
| const mockDonors = ['Green Future Foundation', 'Horizon Trust', 'Bright Path Nonprofit', 'Unity Giving Circle', 'Sunrise Community Fund']; | ||
| const mockProjects = ['Clean Water Initiative', 'Youth Mentorship Program', 'Food Security Drive', 'Urban Garden Project', 'STEM Education Fund']; | ||
| const donorsBase = 'http://localhost:3003'; |
There was a problem hiding this comment.
Hard coding this will give invalid URL. we set a global base url that is either localhost or the api gateway url, so you should just be able to append to it
| const [error, setError] = useState<string | null>(null); | ||
|
|
||
| useEffect(() => { | ||
| async function fetchUsers() { |
There was a problem hiding this comment.
We'd want to put this fetch in a custom hook
| useEffect(() => { | ||
| async function fetchUsers() { | ||
| try { | ||
| const json = await api.get<User[] | { data: User[] }>('http://localhost:3001/users'); |
There was a problem hiding this comment.
I think this response shape may be wrong since user can be paginated
| @@ -16,26 +16,40 @@ type Donor = { | |||
| num_projects: number; | |||
There was a problem hiding this comment.
i think this needs to be updated. i dont think we give num_projects
mehanana
left a comment
There was a problem hiding this comment.
Apart from Nour's comments, I only found 1 small change needed!
| // eslint-disable-next-line react-hooks/exhaustive-deps | ||
| }, []); | ||
|
|
||
| const shownFacilitation = users.length ? users.filter(u => u.is_admin) : facilitationTeam; |
There was a problem hiding this comment.
I think these default to the mock data if the lists are empty, but I don't think we want to do that
ℹ️ Issue
Closes #248
📝 Description
Wire frontend pages to the real backend APIs and make tests CI-friendly by adding deterministic auth + API mocks so typecheck/tests don't fail when calling protected endpoints.
Briefly list the changes made to the code:
✔️ Verification
🏕️ (Optional) Future Work / Notes
I could not test the authenticated flow because I don't have login credentials or a valid access token.
The donations route returned {"message":"Handler 'donations' not found"} when I tried GET /donations.