Skip to content

Commit

Permalink
fix: only call the fetch template endpoint if there is a categoryId i… (
Browse files Browse the repository at this point in the history
#917)

Co-authored-by: clincu-plenty <cristian.lincu@plentysystems.com>
  • Loading branch information
clincu-plenty and clincu-plenty authored Dec 19, 2024
1 parent 506200c commit 43c0b81
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
4 changes: 3 additions & 1 deletion apps/web/composables/useHomepage/useHomepage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@ export const useHomepage: UseHomepageDataReturn = () => {

const { $i18n } = useNuxtApp();
const runtimeConfig = useRuntimeConfig();
const { fetchCategoryTemplate } = useCategoryTemplate();
const { fetchHomepageTemplate } = useFetchHome();

const currentLocale = ref($i18n.locale.value);
const fetchPageTemplate = (): void => {
state.value.loading = true;
const homepageCategoryId = runtimeConfig.public.homepageCategoryId;
if (typeof homepageCategoryId === 'number') {
const { fetchHomepageTemplate } = useFetchHome();
fetchCategoryTemplate(runtimeConfig.public.homepageCategoryId);
state.value.data = fetchHomepageTemplate();
if (
(!state.value.data.blocks || state.value.data.blocks.length === 0) &&
Expand Down
4 changes: 0 additions & 4 deletions apps/web/pages/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ const {
} = useBlockManager();
const { data, fetchPageTemplate, dataIsEmpty } = useHomepage();
const { fetchCategoryTemplate } = useCategoryTemplate();
const { showNewsletter } = useNewsletter();
const { $i18n } = useNuxtApp();
Expand All @@ -73,9 +72,6 @@ const getComponent = (name: string) => {
if (name === 'UiMediaCard') return resolveComponent('UiMediaCard');
if (name === 'ProductRecommendedProducts') return resolveComponent('ProductRecommendedProducts');
};
const runtimeConfig = useRuntimeConfig();
await fetchCategoryTemplate(runtimeConfig.public.homepageCategoryId);
fetchPageTemplate();
</script>

0 comments on commit 43c0b81

Please sign in to comment.