diff --git a/public/favicon.svg b/public/favicon.svg new file mode 100644 index 0000000..af5e4f3 --- /dev/null +++ b/public/favicon.svg @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/public/images/consulting.webp b/public/images/consulting.webp new file mode 100644 index 0000000..8818053 Binary files /dev/null and b/public/images/consulting.webp differ diff --git a/public/images/security.webp b/public/images/security.webp new file mode 100644 index 0000000..db45321 Binary files /dev/null and b/public/images/security.webp differ diff --git a/public/images/solutions.webp b/public/images/solutions.webp new file mode 100644 index 0000000..66da949 Binary files /dev/null and b/public/images/solutions.webp differ diff --git a/public/images/support.webp b/public/images/support.webp new file mode 100644 index 0000000..70d9384 Binary files /dev/null and b/public/images/support.webp differ diff --git a/src/app/ads/hooks/useAdsData.ts b/src/app/ads/hooks/useAdsData.ts new file mode 100644 index 0000000..1f53e5d --- /dev/null +++ b/src/app/ads/hooks/useAdsData.ts @@ -0,0 +1,10 @@ +import * as api from "../service/AdsService"; +import { useQuery } from "@tanstack/react-query"; + +export const useGetAds = (location: string) => { + return useQuery({ + queryKey: ["ads", location], + queryFn: () => api.getAds(location), + enabled: !!location, + }); +}; diff --git a/src/app/ads/service/AdsService.ts b/src/app/ads/service/AdsService.ts new file mode 100644 index 0000000..3010aa6 --- /dev/null +++ b/src/app/ads/service/AdsService.ts @@ -0,0 +1,8 @@ +import axios from "@/config/axios"; + +export const getAds = async (location: string) => { + const { data } = await axios.get( + `/advertise/by-location?location=${location}` + ); + return data; +}; diff --git a/src/app/ads/types/AdsTypes.ts b/src/app/ads/types/AdsTypes.ts new file mode 100644 index 0000000..7d54a17 --- /dev/null +++ b/src/app/ads/types/AdsTypes.ts @@ -0,0 +1,23 @@ +export enum AdsDisplayLocation { + HOMEPAGE_TOP = "HOMEPAGE_TOP", + SINGLE_SERVICE_PAGE = "SINGLE_SERVICE_PAGE", + MY_SERVICES_PAGE = "MY_SERVICES_PAGE", + OTHER_SERVICES_TOP = "OTHER_SERVICES_TOP", + OTHER_SERVICES_LEFT = "OTHER_SERVICES_LEFT", + SERVICE = "SERVICE", + BLOG_PAGE_TOP_RIGHT = "BLOG_PAGE_TOP_RIGHT", + BLOG_PAGE_BOTTOM_RIGHT = "BLOG_PAGE_BOTTOM_RIGHT", + BLOG_PAGE_TOP_LEFT = "BLOG_PAGE_TOP_LEFT", +} + +export type AdsItemType = { + id: string; + title: string; + imageUrl: string; + link: string; + isActive: boolean; + createdAt: string; + startDate: string; + endDate: string; + displayLocation: AdsDisplayLocation; +}; diff --git a/src/app/blogs/components/BlogList.tsx b/src/app/blogs/components/BlogList.tsx index d993431..0482fd4 100644 --- a/src/app/blogs/components/BlogList.tsx +++ b/src/app/blogs/components/BlogList.tsx @@ -7,10 +7,15 @@ import MostVisited from './MostVisited' import ContactUs from './ContactUs' import { useGetBlogs } from '../hooks/useBlogsData' import { useBlogStore } from '../store/BlogStore' +import { useGetAds } from '@/app/ads/hooks/useAdsData' +import { AdsDisplayLocation } from '@/app/ads/types/AdsTypes' +import Image from 'next/image' const BlogList: FC = () => { const { selectedCategory } = useBlogStore() const { data } = useGetBlogs(selectedCategory) + const getAds = useGetAds(AdsDisplayLocation.BLOG_PAGE_TOP_RIGHT) + const getAdsBottom = useGetAds(AdsDisplayLocation.BLOG_PAGE_BOTTOM_RIGHT) return (
@@ -23,6 +28,46 @@ const BlogList: FC = () => {
+ + + { + getAds.isSuccess && getAds.data.data.ads[0] && + + {getAds.data.data.ads[0].title} + +
+
+ {getAds.data.data.ads[0].title} +
+
+
+ } + + { + getAdsBottom.isSuccess && getAdsBottom.data.data.ads[0] && + + {getAdsBottom.data.data.ads[0].title} + +
+
+ {getAdsBottom.data.data.ads[0].title} +
+
+
+ } +
diff --git a/src/app/blogs/components/HeroSection.tsx b/src/app/blogs/components/HeroSection.tsx index 55a8a92..9091035 100644 --- a/src/app/blogs/components/HeroSection.tsx +++ b/src/app/blogs/components/HeroSection.tsx @@ -2,40 +2,62 @@ import BlogItem from '@/components/BlogItem' import Image from 'next/image' import { FC } from 'react' import { useGetBlogCombined } from '../hooks/useBlogsData' +import { AdsDisplayLocation } from '@/app/ads/types/AdsTypes' +import { useGetAds } from '@/app/ads/hooks/useAdsData' const HeroSection: FC = () => { const { data } = useGetBlogCombined() - + const getAdsTopLeft = useGetAds(AdsDisplayLocation.BLOG_PAGE_TOP_LEFT) return (
- { - data?.data?.pinnedBlogs?.map((item, index: number) => { - if (index === 0) { - return ( -
- {item.title} +
+ { + data?.data?.pinnedBlogs?.map((item, index: number) => { + if (index === 0) { + return ( +
+ {item.title} -
-

- {item.title} -

+
+

+ {item.title} +

-
- {item.previewContent.replace(/<\/?[^>]+(>|$)/g, "")} +
+ {item.previewContent.replace(/<\/?[^>]+(>|$)/g, "")} +
+ ) + } + }) + } + { + getAdsTopLeft.isSuccess && getAdsTopLeft.data.data.ads[0] && + + {getAdsTopLeft.data.data.ads[0].title} + +
+
+ {getAdsTopLeft.data.data.ads[0].title}
- ) - } - }) - } +
+
+ } +
diff --git a/src/app/contact/page.tsx b/src/app/contact/page.tsx index e697d26..f5cb1c8 100644 --- a/src/app/contact/page.tsx +++ b/src/app/contact/page.tsx @@ -100,11 +100,13 @@ const Contact: NextPage = () => { placeholder='نام و نام خانوادگی' {...formik.getFieldProps('fullName')} error_text={formik.touched.fullName && formik.errors.fullName ? formik.errors.fullName : undefined} + className='border-t-0 border-x-0 rounded-none place-black' />
@@ -112,19 +114,22 @@ const Contact: NextPage = () => { placeholder='شماره تماس' {...formik.getFieldProps('phone')} error_text={formik.touched.phone && formik.errors.phone ? formik.errors.phone : undefined} + className='border-t-0 border-x-0 rounded-none place-black' />