diff --git a/src/app/about/page.tsx b/src/app/about/page.tsx index 418c7de..7b72902 100644 --- a/src/app/about/page.tsx +++ b/src/app/about/page.tsx @@ -1,5 +1,17 @@ -import AboutPage from "@/pages-templates/about"; +import AboutPage from '@/pages-templates/about'; -export default function About(){ - return +import { mainPageApi } from '@/features/pages/api/pages.api'; + +import { makeStore } from '@/shared/store'; + +export default async function About() { + const store = makeStore(); + + const { data, isLoading } = await store.dispatch( + mainPageApi.endpoints.fetchAboutUsPageContent.initiate(), + ); + + if (isLoading || !data) return null; + + return ; } diff --git a/src/app/api-utlities/@types/about-us.ts b/src/app/api-utlities/@types/about-us.ts new file mode 100644 index 0000000..8d5ea67 --- /dev/null +++ b/src/app/api-utlities/@types/about-us.ts @@ -0,0 +1,8 @@ +import { HistoryItems, Reviews, Stations, TeamMembers } from '.'; + +export type AboutUsPageData = { + team: TeamMembers; + history: HistoryItems; + stations: Stations; + reviews: Reviews; +}; diff --git a/src/app/api-utlities/@types/index.ts b/src/app/api-utlities/@types/index.ts index 09f3862..8be73a6 100644 --- a/src/app/api-utlities/@types/index.ts +++ b/src/app/api-utlities/@types/index.ts @@ -1,3 +1,13 @@ +import { + presentDiscounts, + presentHistoryItems, + presentJobs, + presentPartners, + presentReviews, + presentStations, + presentTeamMembers, +} from '../presenters'; + export type Root = { records: T[] }; export interface Image { @@ -65,3 +75,18 @@ export type History = Root<{ _god: string; _opisanie: string; }>; + +export type Review = Root<{ + id: number; + _name: string; + _otzyv: string; + _rejting: number; +}>; + +export type TeamMembers = ReturnType; +export type HistoryItems = ReturnType; +export type Stations = ReturnType; +export type Partners = ReturnType; +export type Jobs = ReturnType; +export type Discounts = ReturnType; +export type Reviews = ReturnType; diff --git a/src/app/api-utlities/@types/main.ts b/src/app/api-utlities/@types/main.ts index 881fcc3..e128c92 100644 --- a/src/app/api-utlities/@types/main.ts +++ b/src/app/api-utlities/@types/main.ts @@ -1,14 +1,4 @@ -import { - presentDiscounts, - presentJobs, - presentPartners, - presentStations, -} from '../presenters'; - -export type Partners = ReturnType; -export type Jobs = ReturnType; -export type Discounts = ReturnType; -export type Stations = ReturnType; +import { Discounts, Jobs, Partners, Stations } from '.'; export type MainPageData = { discounts: Discounts; diff --git a/src/app/api-utlities/presenters/index.ts b/src/app/api-utlities/presenters/index.ts index 0054675..c13e57a 100644 --- a/src/app/api-utlities/presenters/index.ts +++ b/src/app/api-utlities/presenters/index.ts @@ -6,6 +6,7 @@ import { Image, Job, Partner, + Review, Select, Station, Team, @@ -83,3 +84,11 @@ export const presentTexts = (texts: TextResponse) => key: item._name, value: item._znachenie, })); + +export const presentReviews = (reviews: Review) => + reviews.records.map((review) => ({ + id: review.id, + fullname: review._name, + review: review._otzyv, + rating: review._rejting, + })); diff --git a/src/app/api-utlities/requests/about-us-page.request.ts b/src/app/api-utlities/requests/about-us-page.request.ts index 2504158..ee16f00 100644 --- a/src/app/api-utlities/requests/about-us-page.request.ts +++ b/src/app/api-utlities/requests/about-us-page.request.ts @@ -1,6 +1,13 @@ -import { historyRequest, teamRequest } from './common'; +import { + historyRequest, + reviewsRequest, + stationsWithImageRequest, + teamRequest, +} from './common'; export const aboutUsPageRequest = { ...teamRequest, ...historyRequest, + ...stationsWithImageRequest, + ...reviewsRequest, }; diff --git a/src/app/api-utlities/requests/common.ts b/src/app/api-utlities/requests/common.ts index 30d6abd..3d4ab14 100644 --- a/src/app/api-utlities/requests/common.ts +++ b/src/app/api-utlities/requests/common.ts @@ -1,3 +1,5 @@ +import { EnumType } from 'json-to-graphql-query'; + export const stationsRequest = { _azs: { records: { @@ -27,6 +29,48 @@ export const stationsRequest = { }, }; +export const stationsWithImageRequest = { + _azs: { + __args: { + filtersSet: { + conjunction: new EnumType('and'), + filtersSet: [ + { + field: new EnumType('_foto'), + operator: 'isNotEmpty', + value: [], + }, + ], + }, + }, + + records: { + _name: true, + _opisanie: true, + _adress: true, + _chasyRaboty: { + name: true, + }, + _lat: true, + _long: true, + _avtomojka: true, + _dtCopy: true, // ai92 + _ai92Copy: true, // ai95 + _ai95Copy: true, // z100 + _z100Copy: true, // propan + _propanCopy: true, // electricCharge + _zaryadnayaStanci: true, // miniMarket + _miniMarketCop: true, // toilet + _region: { + name: true, + }, + _foto: { + url: true, + }, + }, + }, +}; + export const partnersRequest = { _partners: { records: { @@ -98,3 +142,14 @@ export const historyRequest = { }, }, }; + +export const reviewsRequest = { + _otzyvy: { + records: { + id: true, + _name: true, + _otzyv: true, + _rejting: true, + }, + }, +}; diff --git a/src/app/api/pages/about-us/route.ts b/src/app/api/pages/about-us/route.ts index fbba11c..31363d9 100644 --- a/src/app/api/pages/about-us/route.ts +++ b/src/app/api/pages/about-us/route.ts @@ -1,5 +1,7 @@ import { presentHistoryItems, + presentReviews, + presentStations, presentTeamMembers, } from '@/app/api-utlities/presenters'; import { aboutUsPageRequest } from '@/app/api-utlities/requests/about-us-page.request'; @@ -14,6 +16,8 @@ const routeHandler = async () => { JSON.stringify({ team: presentTeamMembers(response.data._komanda), history: presentHistoryItems(response.data._istoriya), + stations: presentStations(response.data._azs), + reviews: presentReviews(response.data._otzyvy), }), { headers: { 'Content-Type': 'application/json' }, diff --git a/src/app/page.tsx b/src/app/page.tsx index 9322edb..e66b1f8 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -1,3 +1,7 @@ +import { mainPageApi } from '@/features/pages/api/pages.api'; + +import { makeStore } from '@/shared/store'; + import { AboutSection } from '@/widgets/about-section'; import { CharitySection } from '@/widgets/charity-section'; import { CtaSection } from '@/widgets/cta-section'; @@ -8,23 +12,24 @@ import { PromotionsSection } from '@/widgets/promotions-section'; import { StatsSection } from '@/widgets/stats-section'; import { VacanciesSection } from '@/widgets/vacancies-section'; -import { MainPageData } from './api-utlities/@types/main'; - export default async function Home() { - const mainPageData = (await fetch( - `${process.env.NEXT_PUBLIC_BASE_URL}/api/pages/main`, - { method: 'GET' }, - ).then((res) => res.json())) as MainPageData; + const store = makeStore(); + + const { data, isLoading } = await store.dispatch( + mainPageApi.endpoints.fetchMainPageContent.initiate(), + ); + + if (isLoading || !data) return null; return (
- + - - - + + +
diff --git a/src/features/pages/api/pages.api.ts b/src/features/pages/api/pages.api.ts new file mode 100644 index 0000000..e0f4d45 --- /dev/null +++ b/src/features/pages/api/pages.api.ts @@ -0,0 +1,19 @@ +import { AboutUsPageData } from '@/app/api-utlities/@types/about-us'; +import { MainPageData } from '@/app/api-utlities/@types/main'; + +import { baseAPI } from '@/shared/api/base-api'; + +export const mainPageApi = baseAPI.injectEndpoints({ + endpoints: (builder) => ({ + fetchMainPageContent: builder.query({ + query: () => '/pages/main', + }), + + fetchAboutUsPageContent: builder.query({ + query: () => '/pages/about-us', + }), + }), +}); + +export const { useFetchMainPageContentQuery, useFetchAboutUsPageContentQuery } = + mainPageApi; diff --git a/src/pages-templates/about/index.tsx b/src/pages-templates/about/index.tsx index 0990226..728f78c 100644 --- a/src/pages-templates/about/index.tsx +++ b/src/pages-templates/about/index.tsx @@ -3,24 +3,28 @@ import { Fuel, History, MapPin, Star, Target, Users } from 'lucide-react'; import Image from 'next/image'; -// import { useTranslation } from 'next-i18next'; +import { AboutUsPageData } from '@/app/api-utlities/@types/about-us'; import AnimatedCounter from '@/shared/components/animated-counter'; import { useTextController } from '@/shared/language/hooks/use-text-controller'; import { Button } from '@/shared/shadcn-ui/button'; import { Card, CardContent } from '@/shared/shadcn-ui/card'; +import Container from '@/shared/shadcn-ui/conteiner'; import { CompanyTimeline } from '@/widgets/about-page/company-timeline'; import { StationGallery } from '@/widgets/about-page/station-gallery'; import { CtaSection } from '@/widgets/cta-section'; -import Container from '@/shared/shadcn-ui/conteiner'; export const metadata = { title: 'about.metadata.title', description: 'about.metadata.description', }; -export default function AboutPage() { +export interface AboutPageProps { + content: AboutUsPageData; +} + +export default function AboutPage({ content }: AboutPageProps) { const { t } = useTextController(); return ( @@ -38,7 +42,11 @@ export default function AboutPage() { priority />
-
+

{t('about.hero.title')} @@ -53,7 +61,7 @@ export default function AboutPage() { {/* Company Overview */} - +
@@ -74,7 +82,7 @@ export default function AboutPage() { {t('about.overview.description3')}

-
+
{[0, 1, 2, 3].map((index) => (
@@ -92,7 +100,10 @@ export default function AboutPage() { ))}
-
+
{t('about.overview.imageAlt')}
-
+
{[0, 1, 2, 3].map((index) => (

@@ -157,9 +168,8 @@ export default function AboutPage() { - + -

@@ -179,7 +189,7 @@ export default function AboutPage() {

- +

@@ -210,7 +220,11 @@ export default function AboutPage() {

-
+
{[0, 1, 2].map((index) => (
-
- {[0, 1, 2, 3].map((index) => ( +
+ {content.team.map((member, index) => (
- {t(`about.team.members.${index}.name`)} + {member.photo && ( + {t(`about.team.members.${index}.name`)} + )}
-

- {t(`about.team.members.${index}.name`)} -

-

- {t(`about.team.members.${index}.position`)} -

+

{member.name}

+

{member.profession}

))} @@ -281,7 +297,6 @@ export default function AboutPage() { {/* Testimonials */} -
@@ -296,8 +311,11 @@ export default function AboutPage() {

-
- {[0, 1, 2].map((index) => ( +
+ {content.reviews.map((review, index) => ( ( ))}

- "{t(`about.testimonials.items.${index}.text`)}" -

-

- {t(`about.testimonials.items.${index}.name`)} + "{review.review}"

+

{review.fullname}

))} diff --git a/src/widgets/about-page/company-timeline.tsx b/src/widgets/about-page/company-timeline.tsx index ea6e15d..3142061 100644 --- a/src/widgets/about-page/company-timeline.tsx +++ b/src/widgets/about-page/company-timeline.tsx @@ -3,64 +3,19 @@ import { Calendar, ChevronDown, ChevronUp } from 'lucide-react'; import { useState } from 'react'; +import { HistoryItems } from '@/app/api-utlities/@types/about-us'; + import { useTextController } from '@/shared/language/hooks/use-text-controller'; import { Button } from '@/shared/shadcn-ui/button'; import { Card, CardContent } from '@/shared/shadcn-ui/card'; -const timelineEvents = [ - { - year: '2008', - title: 'Основание компании', - description: - 'GasNetwork была основана с открытием первых трех заправочных станций в Душанбе. С самого начала компания поставила перед собой цель предоставлять качественное топливо и отличный сервис.', - }, - { - year: '2010', - title: 'Расширение сети', - description: - 'Открытие еще пяти заправочных станций в различных регионах Таджикистана. Начало формирования единого стандарта обслуживания на всех станциях сети.', - }, - { - year: '2012', - title: 'Внедрение программы лояльности', - description: - 'Запуск первой в Таджикистане программы лояльности для клиентов сети заправок. Введение карт постоянного клиента с накопительной системой бонусов.', - }, - { - year: '2014', - title: 'Модернизация оборудования', - description: - 'Масштабная программа по обновлению оборудования на всех заправочных станциях сети. Внедрение современных технологий для повышения качества обслуживания.', - }, - { - year: '2016', - title: 'Открытие 15-й заправки', - description: - 'Значительное расширение сети с открытием юбилейной 15-й заправочной станции. GasNetwork становится одной из крупнейших сетей заправок в Таджикистане.', - }, - { - year: '2018', - title: 'Запуск мобильного приложения', - description: - 'Разработка и запуск мобильного приложения для клиентов сети. Возможность отслеживать бонусы, находить ближайшие заправки и получать специальные предложения.', - }, - { - year: '2020', - title: 'Создание благотворительного фонда', - description: - 'Основание благотворительного фонда GasNetwork для поддержки социальных проектов в Таджикистане. Начало активной социальной деятельности компании.', - }, - { - year: '2023', - title: 'Современное развитие', - description: - 'Сегодня GasNetwork - это 25+ современных заправочных станций по всему Таджикистану, более 150 сотрудников и тысячи довольных клиентов ежедневно.', - }, -]; +export interface CompanyTimelineProps { + timeline: HistoryItems; +} -export function CompanyTimeline() { +export function CompanyTimeline({ timeline }: CompanyTimelineProps) { const [expanded, setExpanded] = useState(false); - const displayEvents = expanded ? timelineEvents : timelineEvents.slice(0, 4); + const displayEvents = expanded ? timeline : timeline.slice(0, 4); const { t } = useTextController(); @@ -80,7 +35,7 @@ export function CompanyTimeline() {

{event.year}

-

{event.title}

+

{event.name}

- {timelineEvents.length > 4 && ( + {timeline.length > 4 && (