| 
									
										
										
										
											2022-10-22 11:51:07 -08:00
										 |  |  | import { BaseCRUDAPI } from "../base/base-clients"; | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  | import type { GroupBase, GroupInDB } from "~/lib/api/types/user"; | 
					
						
							|  |  |  | import type { GroupAdminUpdate } from "~/lib/api/types/group"; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-11-25 14:17:02 -09:00
										 |  |  | const prefix = "/api"; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | const routes = { | 
					
						
							|  |  |  |   adminUsers: `${prefix}/admin/groups`, | 
					
						
							| 
									
										
										
										
											2022-05-21 21:22:02 +02:00
										 |  |  |   adminUsersId: (id: string) => `${prefix}/admin/groups/${id}`, | 
					
						
							| 
									
										
										
										
											2021-11-25 14:17:02 -09:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-21 21:22:02 +02:00
										 |  |  | export class AdminGroupsApi extends BaseCRUDAPI<GroupBase, GroupInDB, GroupAdminUpdate> { | 
					
						
							| 
									
										
										
										
											2021-11-25 14:17:02 -09:00
										 |  |  |   baseRoute: string = routes.adminUsers; | 
					
						
							|  |  |  |   itemRoute = routes.adminUsersId; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-21 21:22:02 +02:00
										 |  |  |   async updateOne(id: string, payload: GroupAdminUpdate) { | 
					
						
							| 
									
										
										
										
											2022-01-09 07:15:23 +01:00
										 |  |  |     // TODO: This should probably be a patch request, which isn't offered by the API currently
 | 
					
						
							| 
									
										
										
										
											2022-05-21 21:22:02 +02:00
										 |  |  |     return await this.requests.put<GroupInDB, GroupAdminUpdate>(this.itemRoute(id), payload); | 
					
						
							| 
									
										
										
										
											2021-11-25 14:17:02 -09:00
										 |  |  |   } | 
					
						
							|  |  |  | } |