-
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.
add new endpoints for users to groups
- Loading branch information
1 parent
ab16af3
commit e99b59a
Showing
16 changed files
with
147 additions
and
97 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,27 @@ | ||
import { GetUsersToGroupsResponse } from './types'; | ||
|
||
async function fetchUsersToGroups(userId: string): Promise<GetUsersToGroupsResponse | null> { | ||
try { | ||
const response = await fetch( | ||
`${import.meta.env.VITE_SERVER_URL}/api/users/${userId}/users-to-groups`, | ||
{ | ||
credentials: 'include', | ||
headers: { | ||
'Content-Type': 'application/json', | ||
}, | ||
}, | ||
); | ||
|
||
if (!response.ok) { | ||
throw new Error(`HTTP Error! Status: ${response.status}`); | ||
} | ||
|
||
const userGroups = (await response.json()) as { data: GetUsersToGroupsResponse }; | ||
return userGroups.data; | ||
} catch (error) { | ||
console.error('Error fetching user groups:', error); | ||
return null; | ||
} | ||
} | ||
|
||
export default fetchUsersToGroups; |
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
File renamed without changes.
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 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,46 @@ | ||
type UsersToGroups = { | ||
id: string; | ||
createdAt: Date; | ||
updatedAt: Date; | ||
userId: string; | ||
groupCategoryId: string | null; | ||
groupId: string; | ||
}; | ||
|
||
export type GetUsersToGroupsResponse = { | ||
id: string; | ||
createdAt: string; | ||
updatedAt: string; | ||
userId: string; | ||
groupCategoryId: string | null; | ||
groupId: string; | ||
group: { | ||
id: string; | ||
name: string; | ||
createdAt: Date; | ||
updatedAt: Date; | ||
description: string | null; | ||
secret: string | null; | ||
groupCategoryId: string | null; | ||
groupCategory?: { | ||
createdAt: string; | ||
eventId: string; | ||
id: string; | ||
name: string; | ||
updatedAt: string; | ||
}; | ||
}; | ||
}[]; | ||
|
||
export type PostUsersToGroupsRequest = { | ||
groupId?: string; | ||
secret?: string; | ||
}; | ||
|
||
export type PutUsersToGroupsRequest = { | ||
userToGroupId: string; | ||
groupId: string; | ||
}; | ||
|
||
export type PostUsersToGroupsResponse = UsersToGroups; | ||
export type PutUsersToGroupsResponse = UsersToGroups; |
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
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
Oops, something went wrong.