-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change api: alerts to navLinks (#706)
* Update api * Fix export * Update header with new api * Fix api path * Add api for event navlinks and general navlinks * Update header * Fix requested changes
- Loading branch information
1 parent
8165aad
commit aff6c3b
Showing
7 changed files
with
89 additions
and
45 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains 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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { ApiRequest, GetNavLinksResponse } from './types'; | ||
|
||
export async function fetchEventNavLinks({ | ||
serverUrl, | ||
eventId, | ||
}: ApiRequest<{ eventId: string }>): Promise<GetNavLinksResponse | null> { | ||
try { | ||
const response = await fetch(`${serverUrl}/api/events/${eventId}/nav-links`, { | ||
credentials: 'include', | ||
headers: { | ||
'Content-Type': 'application/json', | ||
}, | ||
}); | ||
|
||
if (!response.ok) { | ||
throw new Error(`HTTP Error! Status: ${response.status}`); | ||
} | ||
|
||
const navLinks = (await response.json()) as { data: GetNavLinksResponse }; | ||
return navLinks.data; | ||
} catch (error) { | ||
console.error('Error fetching event nav links:', error); | ||
return null; | ||
} | ||
} |
This file contains 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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { ApiRequest, GetNavLinksResponse } from './types'; | ||
|
||
export async function fetchNavLinks({ | ||
serverUrl, | ||
}: ApiRequest<unknown>): Promise<GetNavLinksResponse | null> { | ||
try { | ||
const response = await fetch(`${serverUrl}/api/nav-links`, { | ||
credentials: 'include', | ||
headers: { | ||
'Content-Type': 'application/json', | ||
}, | ||
}); | ||
|
||
if (!response.ok) { | ||
throw new Error(`HTTP Error! Status: ${response.status}`); | ||
} | ||
|
||
const navLinks = (await response.json()) as { data: GetNavLinksResponse }; | ||
return navLinks.data; | ||
} catch (error) { | ||
console.error('Error fetching nav links:', error); | ||
return null; | ||
} | ||
} |
This file contains 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,41 +1,42 @@ | ||
export * from './deleteComment'; | ||
export * from './deleteLike'; | ||
export * from './deleteUsersToGroups'; | ||
export * from './fetchAlerts'; | ||
export * from './fetchCommentLikes'; | ||
export * from './fetchComments'; | ||
export * from './fetchCycle'; | ||
export * from './fetchCycles'; | ||
export * from './fetchEvent'; | ||
export * from './fetchEventCycles'; | ||
export * from './fetchEventGroupCategories'; | ||
export * from './fetchEventNavLinks'; | ||
export * from './fetchEvents'; | ||
export * from './fetchQuestionStatistics'; | ||
export * from './fetchQuestionFunding'; | ||
export * from './fetchGroupCategories'; | ||
export * from './fetchGroupMembers'; | ||
export * from './fetchGroupRegistrations'; | ||
export * from './fetchGroups'; | ||
export * from './fetchNavLinks'; | ||
export * from './fetchOption'; | ||
export * from './fetchOptionUsers'; | ||
export * from './fetchQuestionFunding'; | ||
export * from './fetchQuestionStatistics'; | ||
export * from './fetchRegistrationData'; | ||
export * from './fetchRegistrationFields'; | ||
export * from './fetchRegistrations'; | ||
export * from './fetchUser'; | ||
export * from './fetchUserAttributes'; | ||
export * from './fetchUserOptions'; | ||
export * from './fetchUserRegistrations'; | ||
export * from './fetchUsersToGroups'; | ||
export * from './fetchUserVotes'; | ||
export * from './logout'; | ||
export * from './postComment'; | ||
export * from './postGroup'; | ||
export * from './postLike'; | ||
export * from './postVerify'; | ||
export * from './postRegistration'; | ||
export * from './postUsersToGroups'; | ||
export * from './postVerify'; | ||
export * from './postVotes'; | ||
export * from './putRegistration'; | ||
export * from './putUser'; | ||
export * from './putUsersToGroups'; | ||
export * from './fetchEventGroupCategories'; | ||
export * from './fetchUserOptions'; | ||
export * from './types'; |
This file contains 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 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 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