Prefetch product data on ssrz
This commit is contained in:
@@ -1,5 +1,25 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
|
|
||||||
import ChatButton from "~/components/product/ChatBox/ChatButton.vue";
|
import ChatButton from "~/components/product/ChatBox/ChatButton.vue";
|
||||||
|
import useGetProduct from "~/composables/api/product/useGetProduct";
|
||||||
|
|
||||||
|
const route = useRoute();
|
||||||
|
|
||||||
|
const id = route.params.id as string | undefined;
|
||||||
|
|
||||||
|
const { suspense } = useGetProduct(id);
|
||||||
|
|
||||||
|
onServerPrefetch(async () => {
|
||||||
|
const response = await suspense();
|
||||||
|
|
||||||
|
if (response.isError) {
|
||||||
|
throw createError({
|
||||||
|
statusCode: 404,
|
||||||
|
statusMessage: `error : ${response.error.message}`,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@@ -8,7 +28,7 @@ import ChatButton from "~/components/product/ChatBox/ChatButton.vue";
|
|||||||
<ProductVideo />
|
<ProductVideo />
|
||||||
<ProductComments />
|
<ProductComments />
|
||||||
<ProductDetails />
|
<ProductDetails />
|
||||||
<RelatedProducts title="محصولات مشابه" />
|
<ProductsSlider title="محصولات مشابه" />
|
||||||
<ChatButton />
|
<ChatButton />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
Reference in New Issue
Block a user