mirror of
https://github.com/mealie-recipes/mealie.git
synced 2026-04-11 07:25:42 -04:00
chore: Nuxt 4 upgrade (#7426)
This commit is contained in:
48
frontend/app/lib/api/user/groups.ts
Normal file
48
frontend/app/lib/api/user/groups.ts
Normal file
@@ -0,0 +1,48 @@
|
||||
import { BaseCRUDAPI } from "../base/base-clients";
|
||||
import type { PaginationData } from "../types/non-generated";
|
||||
import type { QueryValue } from "../base/route";
|
||||
import type { GroupBase, GroupInDB, GroupSummary, UserSummary } from "~/lib/api/types/user";
|
||||
import type {
|
||||
GroupAdminUpdate,
|
||||
GroupStorage,
|
||||
ReadGroupPreferences,
|
||||
UpdateGroupPreferences,
|
||||
} from "~/lib/api/types/group";
|
||||
|
||||
const prefix = "/api";
|
||||
|
||||
const routes = {
|
||||
groups: `${prefix}/admin/groups`,
|
||||
groupsSelf: `${prefix}/groups/self`,
|
||||
preferences: `${prefix}/groups/preferences`,
|
||||
storage: `${prefix}/groups/storage`,
|
||||
members: `${prefix}/groups/members`,
|
||||
groupsId: (id: string | number) => `${prefix}/admin/groups/${id}`,
|
||||
};
|
||||
|
||||
export class GroupAPI extends BaseCRUDAPI<GroupBase, GroupInDB, GroupAdminUpdate> {
|
||||
baseRoute = routes.groups;
|
||||
itemRoute = routes.groupsId;
|
||||
/** Returns the Group Data for the Current User
|
||||
*/
|
||||
async getCurrentUserGroup() {
|
||||
return await this.requests.get<GroupSummary>(routes.groupsSelf);
|
||||
}
|
||||
|
||||
async getPreferences() {
|
||||
return await this.requests.get<ReadGroupPreferences>(routes.preferences);
|
||||
}
|
||||
|
||||
async setPreferences(payload: UpdateGroupPreferences) {
|
||||
// TODO: This should probably be a patch request, which isn't offered by the API currently
|
||||
return await this.requests.put<ReadGroupPreferences, UpdateGroupPreferences>(routes.preferences, payload);
|
||||
}
|
||||
|
||||
async fetchMembers(page = 1, perPage = -1, params = {} as Record<string, QueryValue>) {
|
||||
return await this.requests.get<PaginationData<UserSummary>>(routes.members, { page, perPage, ...params });
|
||||
}
|
||||
|
||||
async storage() {
|
||||
return await this.requests.get<GroupStorage>(routes.storage);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user