mirror of
https://github.com/mealie-recipes/mealie.git
synced 2026-04-19 11:25:35 -04:00
feat: Announcements (#7431)
Co-authored-by: Kuchenpirat <24235032+Kuchenpirat@users.noreply.github.com>
This commit is contained in:
@@ -12,9 +12,4 @@ const routes = {
|
||||
export class AdminGroupsApi extends BaseCRUDAPI<GroupBase, GroupInDB, GroupAdminUpdate> {
|
||||
baseRoute: string = routes.adminUsers;
|
||||
itemRoute = routes.adminUsersId;
|
||||
|
||||
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<GroupInDB, GroupAdminUpdate>(this.itemRoute(id), payload);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import type { AxiosRequestConfig } from "axios";
|
||||
import type { Recipe } from "../types/recipe";
|
||||
import type { ApiRequestInstance, PaginationData } from "~/lib/api/types/non-generated";
|
||||
import { type QueryValue, route } from "~/lib/api/base/route";
|
||||
@@ -44,38 +45,38 @@ export abstract class BaseCRUDAPIReadOnly<ReadType>
|
||||
return this.itemRouteFn(itemId);
|
||||
}
|
||||
|
||||
async getAll(page = 1, perPage = -1, params = {} as Record<string, QueryValue>) {
|
||||
async getAll(page = 1, perPage = -1, params = {} as Record<string, QueryValue>, config?: AxiosRequestConfig) {
|
||||
params = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== null && v !== undefined));
|
||||
return await this.requests.get<PaginationData<ReadType>>(route(this.baseRoute, { page, perPage, ...params }));
|
||||
return await this.requests.get<PaginationData<ReadType>>(route(this.baseRoute, { page, perPage, ...params }), undefined, config);
|
||||
}
|
||||
|
||||
async getOne(itemId: string | number) {
|
||||
return await this.requests.get<ReadType>(this.itemRoute(itemId));
|
||||
async getOne(itemId: string | number, config?: AxiosRequestConfig) {
|
||||
return await this.requests.get<ReadType>(this.itemRoute(itemId), undefined, config);
|
||||
}
|
||||
}
|
||||
|
||||
export abstract class BaseCRUDAPI<CreateType, ReadType, UpdateType = CreateType>
|
||||
extends BaseCRUDAPIReadOnly<ReadType>
|
||||
implements CrudAPIInterface {
|
||||
async createOne(payload: CreateType) {
|
||||
return await this.requests.post<ReadType>(this.baseRoute, payload);
|
||||
async createOne(payload: CreateType, config?: AxiosRequestConfig) {
|
||||
return await this.requests.post<ReadType>(this.baseRoute, payload, config);
|
||||
}
|
||||
|
||||
async updateOne(itemId: string | number, payload: UpdateType) {
|
||||
return await this.requests.put<ReadType, UpdateType>(this.itemRoute(itemId), payload);
|
||||
async updateOne(itemId: string | number, payload: UpdateType, config?: AxiosRequestConfig) {
|
||||
return await this.requests.put<ReadType, UpdateType>(this.itemRoute(itemId), payload, config);
|
||||
}
|
||||
|
||||
async patchOne(itemId: string, payload: Partial<UpdateType>) {
|
||||
return await this.requests.patch<ReadType, Partial<UpdateType>>(this.itemRoute(itemId), payload);
|
||||
async patchOne(itemId: string, payload: Partial<UpdateType>, config?: AxiosRequestConfig) {
|
||||
return await this.requests.patch<ReadType, Partial<UpdateType>>(this.itemRoute(itemId), payload, config);
|
||||
}
|
||||
|
||||
async deleteOne(itemId: string | number) {
|
||||
return await this.requests.delete<ReadType>(this.itemRoute(itemId));
|
||||
async deleteOne(itemId: string | number, config?: AxiosRequestConfig) {
|
||||
return await this.requests.delete<ReadType>(this.itemRoute(itemId), config);
|
||||
}
|
||||
|
||||
async duplicateOne(itemId: string | number, newName: string | undefined) {
|
||||
async duplicateOne(itemId: string | number, newName: string | undefined, config?: AxiosRequestConfig) {
|
||||
return await this.requests.post<Recipe>(`${this.itemRoute(itemId)}/duplicate`, {
|
||||
name: newName,
|
||||
});
|
||||
}, config);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ export type SupportedMigrations =
|
||||
|
||||
export interface CreateGroupPreferences {
|
||||
privateGroup?: boolean;
|
||||
showAnnouncements?: boolean;
|
||||
groupId: string;
|
||||
}
|
||||
export interface DataMigrationCreate {
|
||||
@@ -31,6 +32,7 @@ export interface GroupAdminUpdate {
|
||||
}
|
||||
export interface UpdateGroupPreferences {
|
||||
privateGroup?: boolean;
|
||||
showAnnouncements?: boolean;
|
||||
}
|
||||
export interface GroupDataExport {
|
||||
id: string;
|
||||
@@ -49,6 +51,7 @@ export interface GroupStorage {
|
||||
}
|
||||
export interface ReadGroupPreferences {
|
||||
privateGroup?: boolean;
|
||||
showAnnouncements?: boolean;
|
||||
groupId: string;
|
||||
id: string;
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ export interface CreateGroupRecipeAction {
|
||||
}
|
||||
export interface CreateHouseholdPreferences {
|
||||
privateHousehold?: boolean;
|
||||
showAnnouncements?: boolean;
|
||||
lockRecipeEditsFromOtherHouseholds?: boolean;
|
||||
firstDayOfWeek?: number;
|
||||
recipePublic?: boolean;
|
||||
@@ -199,6 +200,7 @@ export interface HouseholdInDB {
|
||||
}
|
||||
export interface ReadHouseholdPreferences {
|
||||
privateHousehold?: boolean;
|
||||
showAnnouncements?: boolean;
|
||||
lockRecipeEditsFromOtherHouseholds?: boolean;
|
||||
firstDayOfWeek?: number;
|
||||
recipePublic?: boolean;
|
||||
@@ -276,6 +278,7 @@ export interface SaveGroupRecipeAction {
|
||||
}
|
||||
export interface SaveHouseholdPreferences {
|
||||
privateHousehold?: boolean;
|
||||
showAnnouncements?: boolean;
|
||||
lockRecipeEditsFromOtherHouseholds?: boolean;
|
||||
firstDayOfWeek?: number;
|
||||
recipePublic?: boolean;
|
||||
@@ -769,6 +772,7 @@ export interface UpdateHouseholdAdmin {
|
||||
}
|
||||
export interface UpdateHouseholdPreferences {
|
||||
privateHousehold?: boolean;
|
||||
showAnnouncements?: boolean;
|
||||
lockRecipeEditsFromOtherHouseholds?: boolean;
|
||||
firstDayOfWeek?: number;
|
||||
recipePublic?: boolean;
|
||||
|
||||
@@ -85,6 +85,7 @@ export interface UserSummary {
|
||||
}
|
||||
export interface ReadGroupPreferences {
|
||||
privateGroup?: boolean;
|
||||
showAnnouncements?: boolean;
|
||||
groupId: string;
|
||||
id: string;
|
||||
}
|
||||
@@ -122,6 +123,8 @@ export interface PrivateUser {
|
||||
group: string;
|
||||
household: string;
|
||||
advanced?: boolean;
|
||||
showAnnouncements?: boolean;
|
||||
lastReadAnnouncement?: string | null;
|
||||
canInvite?: boolean;
|
||||
canManage?: boolean;
|
||||
canManageHousehold?: boolean;
|
||||
@@ -194,6 +197,8 @@ export interface UserBase {
|
||||
group?: string | null;
|
||||
household?: string | null;
|
||||
advanced?: boolean;
|
||||
showAnnouncements?: boolean;
|
||||
lastReadAnnouncement?: string | null;
|
||||
canInvite?: boolean;
|
||||
canManage?: boolean;
|
||||
canManageHousehold?: boolean;
|
||||
@@ -209,6 +214,8 @@ export interface UserIn {
|
||||
group?: string | null;
|
||||
household?: string | null;
|
||||
advanced?: boolean;
|
||||
showAnnouncements?: boolean;
|
||||
lastReadAnnouncement?: string | null;
|
||||
canInvite?: boolean;
|
||||
canManage?: boolean;
|
||||
canManageHousehold?: boolean;
|
||||
@@ -225,6 +232,8 @@ export interface UserOut {
|
||||
group: string;
|
||||
household: string;
|
||||
advanced?: boolean;
|
||||
showAnnouncements?: boolean;
|
||||
lastReadAnnouncement?: string | null;
|
||||
canInvite?: boolean;
|
||||
canManage?: boolean;
|
||||
canManageHousehold?: boolean;
|
||||
|
||||
Reference in New Issue
Block a user