1
0
Fork 0
mirror of https://github.com/mealie-recipes/mealie.git synced 2025-07-25 08:09:41 +02:00

[Feat] Migrate from Pages to Cookbooks (#664)

* feat:  Add Description to Cookbooks

* feat(frontend):  Cookbook view page

* feat(frontend): 💄 Add final UI touches

* fix(backend): 🐛 Add get by slug or id

* fix linting issue

* test(backend):  Update tests from pages -> cookbooks

* refactor(backend): 🔥 Delete old page files

Co-authored-by: hay-kot <hay-kot@pm.me>
This commit is contained in:
Hayden 2021-08-31 18:51:34 -08:00 committed by GitHub
parent 165fd8efd6
commit 9b1bf56a5d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
22 changed files with 167 additions and 173 deletions

View file

@ -5,6 +5,22 @@ import { CookBook } from "~/api/class-interfaces/cookbooks";
let cookbookStore: Ref<CookBook[] | null> | null = null;
export const useCookbook = function () {
function getOne(id: string | number) {
const api = useApiSingleton();
const units = useAsync(async () => {
const { data } = await api.cookbooks.getOne(id);
return data;
}, useAsyncKey());
return units;
}
return { getOne };
};
export const useCookbooks = function () {
const api = useApiSingleton();
const loading = ref(false);
@ -45,10 +61,10 @@ export const useCookbooks = function () {
loading.value = true;
const { data } = await api.cookbooks.createOne({
// @ts-ignore. I"m thinking this will always be defined.
name: "New Cookbook" + String(cookbookStore?.value?.length + 1 || 1),
name: "Cookbook " + String(cookbookStore?.value?.length + 1 || 1),
});
if (data && cookbookStore?.value) {
cookbookStore.value.unshift(data);
cookbookStore.value.push(data);
} else {
this.refreshAll();
}