mirror of
https://github.com/mealie-recipes/mealie.git
synced 2025-08-02 20:15:24 +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,8 +1,13 @@
|
|||
import { useAsync, ref, reactive } from "@nuxtjs/composition-api";
|
||||
import { toastLoading, loader } from "./use-toast";
|
||||
import { AllBackups, ImportBackup } from "~/api/class-interfaces/backups";
|
||||
import { AllBackups, BackupOptions } from "~/types/api-types/admin";
|
||||
import { useUserApi } from "~/composables/api";
|
||||
|
||||
interface ImportBackup {
|
||||
name: string;
|
||||
options: BackupOptions;
|
||||
}
|
||||
|
||||
const backups = ref<AllBackups>({
|
||||
imports: [],
|
||||
templates: [],
|
||||
|
@ -41,7 +46,6 @@ export const useBackups = function (fetch = true) {
|
|||
options: {
|
||||
recipes: true,
|
||||
settings: true,
|
||||
pages: true,
|
||||
themes: true,
|
||||
groups: true,
|
||||
users: true,
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { useAsync, ref, Ref } from "@nuxtjs/composition-api";
|
||||
import { useAsyncKey } from "./use-utils";
|
||||
import { useUserApi } from "~/composables/api";
|
||||
import { ReadCookBook, RecipeCookBook, UpdateCookBook } from "~/types/api-types/cookbook";
|
||||
import { ReadCookBook, UpdateCookBook } from "~/types/api-types/cookbook";
|
||||
|
||||
let cookbookStore: Ref<ReadCookBook[] | null> | null = null;
|
||||
|
||||
|
@ -66,7 +66,7 @@ export const useCookbooks = function () {
|
|||
}
|
||||
|
||||
loading.value = true;
|
||||
const { data } = await api.cookbooks.updateOne(updateData.id, updateData as RecipeCookBook);
|
||||
const { data } = await api.cookbooks.updateOne(updateData.id, updateData);
|
||||
if (data && cookbookStore?.value) {
|
||||
this.refreshAll();
|
||||
}
|
||||
|
|
|
@ -2,9 +2,7 @@ import { useAsync, ref, Ref, watch } from "@nuxtjs/composition-api";
|
|||
import { format } from "date-fns";
|
||||
import { useAsyncKey } from "./use-utils";
|
||||
import { useUserApi } from "~/composables/api";
|
||||
import { CreateMealPlan, UpdateMealPlan } from "~/api/class-interfaces/group-mealplan";
|
||||
|
||||
export type MealType = "breakfast" | "lunch" | "dinner" | "side";
|
||||
import { CreatePlanEntry, PlanEntryType, UpdatePlanEntry } from "~/types/api-types/meal-plan";
|
||||
|
||||
export const planTypeOptions = [
|
||||
{ text: "Breakfast", value: "breakfast" },
|
||||
|
@ -55,7 +53,7 @@ export const useMealplans = function (range: Ref<DateRange>) {
|
|||
|
||||
loading.value = false;
|
||||
},
|
||||
async createOne(payload: CreateMealPlan) {
|
||||
async createOne(payload: CreatePlanEntry) {
|
||||
loading.value = true;
|
||||
|
||||
const { data } = await api.mealplans.createOne(payload);
|
||||
|
@ -65,13 +63,12 @@ export const useMealplans = function (range: Ref<DateRange>) {
|
|||
|
||||
loading.value = false;
|
||||
},
|
||||
async updateOne(updateData: UpdateMealPlan) {
|
||||
async updateOne(updateData: UpdatePlanEntry) {
|
||||
if (!updateData.id) {
|
||||
return;
|
||||
}
|
||||
|
||||
loading.value = true;
|
||||
// @ts-ignore TODO Modify mealpan types to be from auto-generated files
|
||||
const { data } = await api.mealplans.updateOne(updateData.id, updateData);
|
||||
if (data) {
|
||||
this.refreshAll();
|
||||
|
@ -87,8 +84,8 @@ export const useMealplans = function (range: Ref<DateRange>) {
|
|||
}
|
||||
},
|
||||
|
||||
async setType(payload: UpdateMealPlan, typ: MealType) {
|
||||
payload.entryType = typ;
|
||||
async setType(payload: UpdatePlanEntry, type: PlanEntryType) {
|
||||
payload.entryType = type;
|
||||
await this.updateOne(payload);
|
||||
},
|
||||
};
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { useAsync, ref } from "@nuxtjs/composition-api";
|
||||
import { useAsyncKey } from "./use-utils";
|
||||
import { useUserApi } from "~/composables/api";
|
||||
import { GroupWebhook } from "~/api/class-interfaces/group-webhooks";
|
||||
import { ReadWebhook } from "~/types/api-types/group";
|
||||
|
||||
export const useGroupWebhooks = function () {
|
||||
const api = useUserApi();
|
||||
|
@ -47,7 +47,7 @@ export const useGroupWebhooks = function () {
|
|||
|
||||
loading.value = false;
|
||||
},
|
||||
async updateOne(updateData: GroupWebhook) {
|
||||
async updateOne(updateData: ReadWebhook) {
|
||||
if (!updateData.id) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { useAsync, ref } from "@nuxtjs/composition-api";
|
||||
import { useAsyncKey } from "./use-utils";
|
||||
import { useUserApi } from "~/composables/api";
|
||||
import { CreateGroup } from "~/api/class-interfaces/groups";
|
||||
import { GroupBase } from "~/types/api-types/user";
|
||||
|
||||
export const useGroupSelf = function () {
|
||||
const api = useUserApi();
|
||||
|
@ -17,7 +17,7 @@ export const useGroupSelf = function () {
|
|||
return group;
|
||||
},
|
||||
async updatePreferences() {
|
||||
if (!group.value) {
|
||||
if (!group.value?.preferences) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -65,7 +65,7 @@ export const useGroups = function () {
|
|||
return data;
|
||||
}
|
||||
|
||||
async function createGroup(payload: CreateGroup) {
|
||||
async function createGroup(payload: GroupBase) {
|
||||
loading.value = true;
|
||||
const { data } = await api.groups.createOne(payload);
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { ref, Ref } from "@nuxtjs/composition-api";
|
||||
import { RequestResponse } from "~/types/api";
|
||||
import { Validation } from "~/api/public/validators";
|
||||
import { ValidationResponse } from "~/types/api-types/response";
|
||||
|
||||
const EMAIL_REGEX =
|
||||
/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@(([[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
|
||||
|
@ -23,7 +23,7 @@ export const validators = {
|
|||
*/
|
||||
export const useAsyncValidator = (
|
||||
value: Ref<string>,
|
||||
validatorFunc: (v: string) => Promise<RequestResponse<Validation>>,
|
||||
validatorFunc: (v: string) => Promise<RequestResponse<ValidationResponse>>,
|
||||
validatorMessage: string,
|
||||
errorMessages: Ref<string[]>
|
||||
) => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue