c32d7d7486
* feat(frontend): ✨ add user recipe export functionality * remove depreciated folders * change/remove depreciated folders * add testing variable in config * add GUID support for group_id * improve testing feedback on 422 errors * remove/cleanup files/folders * initial user export support * delete unused css * update backup page UI * remove depreciated settings * feat: ✨ export download links * fix #813 * remove top level statements * show footer * add export purger to scheduler * update purge glob * fix meal-planner lockout * feat: ✨ add bulk delete/purge exports * style(frontend): 💄 update UI for site settings * feat: ✨ add version checker * update documentation Co-authored-by: hay-kot <hay-kot@pm.me>
78 lines
1.8 KiB
TypeScript
78 lines
1.8 KiB
TypeScript
import { BaseAPI } from "../_base";
|
|
|
|
interface BasePayload {
|
|
recipes: string[];
|
|
}
|
|
|
|
type exportType = "json";
|
|
|
|
interface RecipeBulkDelete extends BasePayload {}
|
|
|
|
interface RecipeBulkExport extends BasePayload {
|
|
exportType: exportType;
|
|
}
|
|
|
|
interface RecipeBulkCategorize extends BasePayload {
|
|
categories: string[];
|
|
}
|
|
|
|
interface RecipeBulkTag extends BasePayload {
|
|
tags: string[];
|
|
}
|
|
|
|
interface BulkActionError {
|
|
recipe: string;
|
|
error: string;
|
|
}
|
|
|
|
interface BulkActionResponse {
|
|
success: boolean;
|
|
message: string;
|
|
errors: BulkActionError[];
|
|
}
|
|
|
|
export interface GroupDataExport {
|
|
id: string;
|
|
groupId: string;
|
|
name: string;
|
|
filename: string;
|
|
path: string;
|
|
size: string;
|
|
expires: Date;
|
|
}
|
|
|
|
const prefix = "/api";
|
|
|
|
const routes = {
|
|
bulkExport: prefix + "/recipes/bulk-actions/export",
|
|
purgeExports: prefix + "/recipes/bulk-actions/export/purge",
|
|
bulkCategorize: prefix + "/recipes/bulk-actions/categorize",
|
|
bulkTag: prefix + "/recipes/bulk-actions/tag",
|
|
bulkDelete: prefix + "/recipes/bulk-actions/delete",
|
|
};
|
|
|
|
export class BulkActionsAPI extends BaseAPI {
|
|
async bulkExport(payload: RecipeBulkExport) {
|
|
return await this.requests.post<BulkActionResponse>(routes.bulkExport, payload);
|
|
}
|
|
|
|
async bulkCategorize(payload: RecipeBulkCategorize) {
|
|
return await this.requests.post<BulkActionResponse>(routes.bulkCategorize, payload);
|
|
}
|
|
|
|
async bulkTag(payload: RecipeBulkTag) {
|
|
return await this.requests.post<BulkActionResponse>(routes.bulkTag, payload);
|
|
}
|
|
|
|
async bulkDelete(payload: RecipeBulkDelete) {
|
|
return await this.requests.post<BulkActionResponse>(routes.bulkDelete, payload);
|
|
}
|
|
|
|
async fetchExports() {
|
|
return await this.requests.get<GroupDataExport[]>(routes.bulkExport);
|
|
}
|
|
|
|
async purgeExports() {
|
|
return await this.requests.delete(routes.purgeExports);
|
|
}
|
|
}
|