fix "no data" error on create meal plan modal (#2263)

This commit is contained in:
Sören 2023-03-24 17:21:12 +01:00 committed by GitHub
parent 905b2ad8a9
commit 82ce4b5e7a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 4 deletions

View File

@ -8,6 +8,7 @@ export interface UseRecipeSearchReturn {
error: Ref<string>;
loading: Ref<boolean>;
data: Ref<Recipe[]>;
trigger(): Promise<void>;
}
/**
@ -40,7 +41,7 @@ export function useRecipeSearch(api: UserApi): UseRecipeSearchReturn {
}
if (data) {
recipes.value= data.items;
recipes.value = data.items;
}
loading.value = false;
@ -54,11 +55,15 @@ export function useRecipeSearch(api: UserApi): UseRecipeSearchReturn {
{ debounce: 500 }
);
async function trigger() {
await searchRecipes(query.value);
}
return {
query,
error,
loading,
data: recipes,
}
trigger,
};
}

View File

@ -206,7 +206,7 @@
</template>
<script lang="ts">
import { defineComponent, computed, reactive, ref, watch } from "@nuxtjs/composition-api";
import { defineComponent, computed, reactive, ref, watch, onMounted } from "@nuxtjs/composition-api";
import { format } from "date-fns";
import { SortableEvent } from "sortablejs";
import draggable from "vuedraggable";
@ -332,8 +332,11 @@ export default defineComponent({
// Search
const search = useRecipeSearch(api);
const planTypeOptions = usePlanTypeOptions();
onMounted(async () => {
await search.trigger();
});
return {
state,