blogs
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
'use client'
|
||||
import { FC } from 'react'
|
||||
import ServiceItem from '@/components/ServiceItem'
|
||||
import { useGetDanakServiceSuggested } from './hooks/useProductData'
|
||||
|
||||
const DanakSuggestedService: FC = () => {
|
||||
|
||||
const { data } = useGetDanakServiceSuggested()
|
||||
|
||||
return (
|
||||
<div className='max-w-maxWidth mx-auto xl:mt-20 mt-12'>
|
||||
<h2 className='xl:text-2xl text-sm font-bold text-center xl:text-right'>
|
||||
سرویس های پیشنهادی داناک
|
||||
</h2>
|
||||
|
||||
<div className='xl:mt-14 mt-10 flex xl:flex-row flex-col gap-8'>
|
||||
{
|
||||
data?.data?.danakServices?.map((item) => {
|
||||
return (
|
||||
<ServiceItem key={item.id} item={item} />
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default DanakSuggestedService
|
||||
@@ -2,7 +2,7 @@
|
||||
import { ArrowLeft } from 'iconsax-react'
|
||||
import Image from 'next/image'
|
||||
import { Swiper, SwiperSlide } from 'swiper/react'
|
||||
import DanakSuggestedService from '../home/DanakSuggestedService'
|
||||
import DanakSuggestedService from './DanakSuggestedService'
|
||||
import { FC } from 'react'
|
||||
import DanakServices from './DanakServices'
|
||||
|
||||
@@ -7,11 +7,22 @@ export const useGetServicesByCategory = (categoryId?: string) =>
|
||||
queryFn: () => api.getServicesByCategory(categoryId),
|
||||
});
|
||||
|
||||
export const useGetDanakServiceSuggested = () =>
|
||||
useQuery({
|
||||
queryKey: ["danak-service-suggested"],
|
||||
queryFn: () => api.getDanakServiceSuggested(),
|
||||
});
|
||||
|
||||
export const servicesQueryOptions = {
|
||||
queryKey: ["services", ""],
|
||||
queryFn: () => api.getServicesByCategory(undefined),
|
||||
};
|
||||
|
||||
export const danakServiceSuggestedQueryOptions = {
|
||||
queryKey: ["danak-service-suggested"],
|
||||
queryFn: () => api.getDanakServiceSuggested(),
|
||||
};
|
||||
|
||||
export const useGetCategories = () =>
|
||||
useQuery({
|
||||
queryKey: ["service-categories"],
|
||||
|
||||
@@ -2,12 +2,13 @@ import { NextPage } from 'next'
|
||||
import { HydrationBoundary } from '@tanstack/react-query'
|
||||
import { dehydrate } from '@tanstack/react-query'
|
||||
import { QueryClient } from '@tanstack/react-query'
|
||||
import { categoriesQueryOptions, servicesQueryOptions } from './hooks/useProductData'
|
||||
import Products from './Products'
|
||||
import { categoriesQueryOptions, danakServiceSuggestedQueryOptions, servicesQueryOptions } from './hooks/useProductData'
|
||||
import Products from './ProductsPage'
|
||||
const ProductsPage: NextPage = async () => {
|
||||
const queryClient = new QueryClient()
|
||||
await queryClient.prefetchQuery(servicesQueryOptions)
|
||||
await queryClient.prefetchQuery(categoriesQueryOptions)
|
||||
await queryClient.prefetchQuery(danakServiceSuggestedQueryOptions)
|
||||
return (
|
||||
<HydrationBoundary state={dehydrate(queryClient)}>
|
||||
<Products />
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
import axios from "@/config/axios";
|
||||
import { CategoryResponse, ServiceResponse } from "../types/ProductTypes";
|
||||
import {
|
||||
CategoryResponse,
|
||||
DanakServiceSuggestedResponse,
|
||||
ServiceResponse,
|
||||
} from "../types/ProductTypes";
|
||||
|
||||
export const getServicesByCategory = async (categoryId?: string) => {
|
||||
let query = ``;
|
||||
@@ -18,3 +22,10 @@ export const getCategoriesPublic = async () => {
|
||||
);
|
||||
return data;
|
||||
};
|
||||
|
||||
export const getDanakServiceSuggested = async () => {
|
||||
const { data } = await axios.get<DanakServiceSuggestedResponse>(
|
||||
`/danak-services/suggested`
|
||||
);
|
||||
return data;
|
||||
};
|
||||
|
||||
@@ -21,3 +21,7 @@ export type ServiceCategoryType = {
|
||||
parentId: string | null;
|
||||
deletedAt: string | null;
|
||||
};
|
||||
|
||||
export type DanakServiceSuggestedResponse = ApiResponse<{
|
||||
danakServices: DanakSuggestService[];
|
||||
}>;
|
||||
|
||||
Reference in New Issue
Block a user