mirror of
https://github.com/mealie-recipes/mealie.git
synced 2025-07-21 14:19:41 +02:00
Consolidate frontend types (#1245)
This commit is contained in:
parent
6a88a59981
commit
479900e912
74 changed files with 261 additions and 582 deletions
|
@ -1,55 +1,19 @@
|
|||
import { BaseCRUDAPI } from "../_base";
|
||||
import { UserOut } from "~/types/api-types/user";
|
||||
import { GroupBase, GroupInDB } from "~/types/api-types/user";
|
||||
import { GroupAdminUpdate } from "~/types/api-types/group";
|
||||
const prefix = "/api";
|
||||
|
||||
export interface Token {
|
||||
name: string;
|
||||
id: number;
|
||||
createdAt: Date;
|
||||
}
|
||||
|
||||
export interface Preferences {
|
||||
privateGroup: boolean;
|
||||
firstDayOfWeek: number;
|
||||
recipePublic: boolean;
|
||||
recipeShowNutrition: boolean;
|
||||
recipeShowAssets: boolean;
|
||||
recipeLandscapeView: boolean;
|
||||
recipeDisableComments: boolean;
|
||||
recipeDisableAmount: boolean;
|
||||
groupId: number;
|
||||
id: number;
|
||||
}
|
||||
|
||||
export interface GroupCreate {
|
||||
name: string;
|
||||
}
|
||||
|
||||
export interface GroupRead extends GroupCreate {
|
||||
id: number;
|
||||
categories: any[];
|
||||
webhooks: any[];
|
||||
users: UserOut[];
|
||||
preferences: Preferences;
|
||||
}
|
||||
|
||||
export interface AdminGroupUpdate {
|
||||
name: string;
|
||||
id: number;
|
||||
preferences: Preferences;
|
||||
}
|
||||
|
||||
const routes = {
|
||||
adminUsers: `${prefix}/admin/groups`,
|
||||
adminUsersId: (id: number) => `${prefix}/admin/groups/${id}`,
|
||||
adminUsersId: (id: string) => `${prefix}/admin/groups/${id}`,
|
||||
};
|
||||
|
||||
export class AdminGroupsApi extends BaseCRUDAPI<GroupRead, GroupCreate> {
|
||||
export class AdminGroupsApi extends BaseCRUDAPI<GroupBase, GroupInDB, GroupAdminUpdate> {
|
||||
baseRoute: string = routes.adminUsers;
|
||||
itemRoute = routes.adminUsersId;
|
||||
|
||||
async updateOne(id: number, payload: AdminGroupUpdate) {
|
||||
async updateOne(id: string, payload: GroupAdminUpdate) {
|
||||
// TODO: This should probably be a patch request, which isn't offered by the API currently
|
||||
return await this.requests.put<GroupRead, AdminGroupUpdate>(this.itemRoute(id), payload);
|
||||
return await this.requests.put<GroupInDB, GroupAdminUpdate>(this.itemRoute(id), payload);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue