mirror of
https://github.com/hay-kot/mealie.git
synced 2025-08-22 14:33:33 -07:00
add optional i18n param to all stores
This commit is contained in:
parent
87aaa45932
commit
d1137fa2ad
7 changed files with 29 additions and 22 deletions
|
@ -1,6 +1,7 @@
|
|||
import { useData, useReadOnlyStore, useStore } from "../partials/use-store-factory";
|
||||
import type { RecipeCategory } from "~/lib/api/types/recipe";
|
||||
import { usePublicExploreApi, useUserApi } from "~/composables/api";
|
||||
import type { Composer } from "vue-i18n";
|
||||
|
||||
const store: Ref<RecipeCategory[]> = ref([]);
|
||||
const loading = ref(false);
|
||||
|
@ -14,12 +15,12 @@ export const useCategoryData = function () {
|
|||
});
|
||||
};
|
||||
|
||||
export const useCategoryStore = function () {
|
||||
const api = useUserApi();
|
||||
export const useCategoryStore = function (i18n?: Composer) {
|
||||
const api = useUserApi(i18n);
|
||||
return useStore<RecipeCategory>(store, loading, api.categories);
|
||||
};
|
||||
|
||||
export const usePublicCategoryStore = function (groupSlug: string) {
|
||||
const api = usePublicExploreApi(groupSlug).explore;
|
||||
export const usePublicCategoryStore = function (groupSlug: string, i18n?: Composer) {
|
||||
const api = usePublicExploreApi(groupSlug, i18n).explore;
|
||||
return useReadOnlyStore<RecipeCategory>(store, publicLoading, api.categories);
|
||||
};
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import { useData, useReadOnlyStore, useStore } from "../partials/use-store-factory";
|
||||
import type { IngredientFood } from "~/lib/api/types/recipe";
|
||||
import { usePublicExploreApi, useUserApi } from "~/composables/api";
|
||||
import type { Composer } from "vue-i18n";
|
||||
|
||||
const store: Ref<IngredientFood[]> = ref([]);
|
||||
const loading = ref(false);
|
||||
|
@ -15,12 +16,12 @@ export const useFoodData = function () {
|
|||
});
|
||||
};
|
||||
|
||||
export const useFoodStore = function () {
|
||||
const api = useUserApi();
|
||||
export const useFoodStore = function (i18n?: Composer) {
|
||||
const api = useUserApi(i18n);
|
||||
return useStore<IngredientFood>(store, loading, api.foods);
|
||||
};
|
||||
|
||||
export const usePublicFoodStore = function (groupSlug: string) {
|
||||
const api = usePublicExploreApi(groupSlug).explore;
|
||||
export const usePublicFoodStore = function (groupSlug: string, i18n?: Composer) {
|
||||
const api = usePublicExploreApi(groupSlug, i18n).explore;
|
||||
return useReadOnlyStore<IngredientFood>(store, publicLoading, api.foods);
|
||||
};
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import { useData, useStore } from "../partials/use-store-factory";
|
||||
import type { MultiPurposeLabelOut } from "~/lib/api/types/labels";
|
||||
import { useUserApi } from "~/composables/api";
|
||||
import type { Composer } from "vue-i18n";
|
||||
|
||||
const store: Ref<MultiPurposeLabelOut[]> = ref([]);
|
||||
const loading = ref(false);
|
||||
|
@ -14,7 +15,7 @@ export const useLabelData = function () {
|
|||
});
|
||||
};
|
||||
|
||||
export const useLabelStore = function () {
|
||||
const api = useUserApi();
|
||||
export const useLabelStore = function (i18n?: Composer) {
|
||||
const api = useUserApi(i18n);
|
||||
return useStore<MultiPurposeLabelOut>(store, loading, api.multiPurposeLabels);
|
||||
};
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import { useData, useReadOnlyStore, useStore } from "../partials/use-store-factory";
|
||||
import type { RecipeTag } from "~/lib/api/types/recipe";
|
||||
import { usePublicExploreApi, useUserApi } from "~/composables/api";
|
||||
import type { Composer } from "vue-i18n";
|
||||
|
||||
const store: Ref<RecipeTag[]> = ref([]);
|
||||
const loading = ref(false);
|
||||
|
@ -14,12 +15,12 @@ export const useTagData = function () {
|
|||
});
|
||||
};
|
||||
|
||||
export const useTagStore = function () {
|
||||
const api = useUserApi();
|
||||
export const useTagStore = function (i18n?: Composer) {
|
||||
const api = useUserApi(i18n);
|
||||
return useStore<RecipeTag>(store, loading, api.tags);
|
||||
};
|
||||
|
||||
export const usePublicTagStore = function (groupSlug: string) {
|
||||
const api = usePublicExploreApi(groupSlug).explore;
|
||||
export const usePublicTagStore = function (groupSlug: string, i18n?: Composer) {
|
||||
const api = usePublicExploreApi(groupSlug, i18n).explore;
|
||||
return useReadOnlyStore<RecipeTag>(store, publicLoading, api.tags);
|
||||
};
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import { useData, useReadOnlyStore, useStore } from "../partials/use-store-factory";
|
||||
import type { RecipeTool } from "~/lib/api/types/recipe";
|
||||
import { usePublicExploreApi, useUserApi } from "~/composables/api";
|
||||
import type { Composer } from "vue-i18n";
|
||||
|
||||
interface RecipeToolWithOnHand extends RecipeTool {
|
||||
onHand: boolean;
|
||||
|
@ -20,12 +21,12 @@ export const useToolData = function () {
|
|||
});
|
||||
};
|
||||
|
||||
export const useToolStore = function () {
|
||||
const api = useUserApi();
|
||||
export const useToolStore = function (i18n?: Composer) {
|
||||
const api = useUserApi(i18n);
|
||||
return useStore<RecipeTool>(store, loading, api.tools);
|
||||
};
|
||||
|
||||
export const usePublicToolStore = function (groupSlug: string) {
|
||||
const api = usePublicExploreApi(groupSlug).explore;
|
||||
export const usePublicToolStore = function (groupSlug: string, i18n?: Composer) {
|
||||
const api = usePublicExploreApi(groupSlug, i18n).explore;
|
||||
return useReadOnlyStore<RecipeTool>(store, publicLoading, api.tools);
|
||||
};
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import { useData, useStore } from "../partials/use-store-factory";
|
||||
import type { IngredientUnit } from "~/lib/api/types/recipe";
|
||||
import { useUserApi } from "~/composables/api";
|
||||
import type { Composer } from "vue-i18n";
|
||||
|
||||
const store: Ref<IngredientUnit[]> = ref([]);
|
||||
const loading = ref(false);
|
||||
|
@ -15,7 +16,7 @@ export const useUnitData = function () {
|
|||
});
|
||||
};
|
||||
|
||||
export const useUnitStore = function () {
|
||||
const api = useUserApi();
|
||||
export const useUnitStore = function (i18n?: Composer) {
|
||||
const api = useUserApi(i18n);
|
||||
return useStore<IngredientUnit>(store, loading, api.units);
|
||||
};
|
||||
|
|
|
@ -2,6 +2,7 @@ import { useReadOnlyStore } from "../partials/use-store-factory";
|
|||
import { useRequests } from "../api/api-client";
|
||||
import type { UserSummary } from "~/lib/api/types/user";
|
||||
import { BaseCRUDAPIReadOnly } from "~/lib/api/base/base-clients";
|
||||
import type { Composer } from "vue-i18n";
|
||||
|
||||
const store: Ref<UserSummary[]> = ref([]);
|
||||
const loading = ref(false);
|
||||
|
@ -11,8 +12,8 @@ class GroupUserAPIReadOnly extends BaseCRUDAPIReadOnly<UserSummary> {
|
|||
itemRoute = (idOrUsername: string | number) => `/groups/members/${idOrUsername}`;
|
||||
}
|
||||
|
||||
export const useUserStore = function () {
|
||||
const requests = useRequests();
|
||||
export const useUserStore = function (i18n?: Composer) {
|
||||
const requests = useRequests(i18n);
|
||||
const api = new GroupUserAPIReadOnly(requests);
|
||||
|
||||
return useReadOnlyStore<UserSummary>(store, loading, api, { orderBy: "full_name" });
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue