-
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.
451 display option users at comments page (#452)
* Create fetchOptionUsers and type * Add query to comments page * Comment author + co authors & fetchOptionUsers
- Loading branch information
1 parent
cb337b0
commit 3589638
Showing
4 changed files
with
59 additions
and
6 deletions.
There are no files selected for viewing
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,27 @@ | ||
import { GetOptionUsersResponse } from './types/OptionUsersType'; | ||
|
||
async function fetchOptionUsers(optionId: string): Promise<GetOptionUsersResponse | null> { | ||
try { | ||
const response = await fetch( | ||
`${import.meta.env.VITE_SERVER_URL}/api/options/${optionId}/users`, | ||
{ | ||
credentials: 'include', | ||
headers: { | ||
'Content-Type': 'application/json', | ||
}, | ||
}, | ||
); | ||
|
||
if (!response.ok) { | ||
throw new Error(`HTTP Error! Status: ${response.status}`); | ||
} | ||
|
||
const alerts = (await response.json()) as { data: GetOptionUsersResponse }; | ||
return alerts.data; | ||
} catch (error) { | ||
console.error('Error fetching users:', error); | ||
return null; | ||
} | ||
} | ||
|
||
export default fetchOptionUsers; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { GetGroupsResponse } from './GroupType'; | ||
import { GetUserResponse } from './UserType'; | ||
|
||
export type GetOptionUsersResponse = { | ||
optionId: string; | ||
registrationId: string | null; | ||
userId: string | null; | ||
user: GetUserResponse | null; | ||
groupId: string | null; | ||
group: GetGroupsResponse | 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