diff --git a/src/app/api-utlities/@types/about-us.ts b/src/app/api-utlities/@types/about-us.ts deleted file mode 100644 index 8d5ea67..0000000 --- a/src/app/api-utlities/@types/about-us.ts +++ /dev/null @@ -1,8 +0,0 @@ -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 8be73a6..c180017 100644 --- a/src/app/api-utlities/@types/index.ts +++ b/src/app/api-utlities/@types/index.ts @@ -1,4 +1,6 @@ import { + presentCertificates, + presentCharities, presentDiscounts, presentHistoryItems, presentJobs, @@ -83,6 +85,22 @@ export type Review = Root<{ _rejting: number; }>; +export type Charity = Root<{ + _name: string; + _opisanie: string; + _data: string; + _lokaciya: string; + _foto: Image[]; +}>; + +export type Certificate = Root<{ + _name: string; + _opisanie: string; + _dataVydachi: string; + _dejstvitelenDo: string; + _foto: Image[]; +}>; + export type TeamMembers = ReturnType; export type HistoryItems = ReturnType; export type Stations = ReturnType; @@ -90,3 +108,5 @@ export type Partners = ReturnType; export type Jobs = ReturnType; export type Discounts = ReturnType; export type Reviews = ReturnType; +export type Charities = ReturnType; +export type Certificates = ReturnType; diff --git a/src/app/api-utlities/@types/main.ts b/src/app/api-utlities/@types/main.ts deleted file mode 100644 index e128c92..0000000 --- a/src/app/api-utlities/@types/main.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { Discounts, Jobs, Partners, Stations } from '.'; - -export type MainPageData = { - discounts: Discounts; - jobs: Jobs; - partners: Partners; - stations: Stations; -}; diff --git a/src/app/api-utlities/@types/pages.ts b/src/app/api-utlities/@types/pages.ts new file mode 100644 index 0000000..851a551 --- /dev/null +++ b/src/app/api-utlities/@types/pages.ts @@ -0,0 +1,33 @@ +import { + Certificates, + Charities, + Discounts, + HistoryItems, + Jobs, + Partners, + Reviews, + Stations, + TeamMembers, +} from '.'; + +export type AboutUsPageData = { + team: TeamMembers; + history: HistoryItems; + stations: Stations; + reviews: Reviews; +}; + +export type MainPageData = { + discounts: Discounts; + jobs: Jobs; + partners: Partners; + stations: Stations; +}; + +export type CharityPageData = { + charities: Charities; +}; + +export type CertificatesPageData = { + certificates: Certificates; +}; diff --git a/src/app/api-utlities/presenters/index.ts b/src/app/api-utlities/presenters/index.ts index c13e57a..622bae1 100644 --- a/src/app/api-utlities/presenters/index.ts +++ b/src/app/api-utlities/presenters/index.ts @@ -1,6 +1,8 @@ import { isEmpty } from 'lodash'; import { + Certificate, + Charity, Discount, History, Image, @@ -92,3 +94,23 @@ export const presentReviews = (reviews: Review) => review: review._otzyv, rating: review._rejting, })); + +export const presentCharities = (charities: Charity) => + charities.records.map((charity, index) => ({ + id: index + 1, + name: charity._name, + description: charity._opisanie, + date: charity._data, + location: charity._lokaciya, + image: presentImage(charity._foto), + })); + +export const presentCertificates = (certificates: Certificate) => + certificates.records.map((certificate, index) => ({ + id: index + 1, + name: certificate._name, + description: certificate._opisanie, + issuedAt: certificate._dataVydachi, + validUntil: certificate._dejstvitelenDo, + image: presentImage(certificate._foto), + })); diff --git a/src/app/api-utlities/requests/about-us-page.request.ts b/src/app/api-utlities/requests/about-us-page.request copy.ts similarity index 100% rename from src/app/api-utlities/requests/about-us-page.request.ts rename to src/app/api-utlities/requests/about-us-page.request copy.ts diff --git a/src/app/api-utlities/requests/certificates-page.request.ts b/src/app/api-utlities/requests/certificates-page.request.ts new file mode 100644 index 0000000..f69d4e3 --- /dev/null +++ b/src/app/api-utlities/requests/certificates-page.request.ts @@ -0,0 +1,5 @@ +import { certificatesRequest } from './common'; + +export const certificatesPageRequest = { + ...certificatesRequest, +}; diff --git a/src/app/api-utlities/requests/charity-page.request copy.ts b/src/app/api-utlities/requests/charity-page.request copy.ts new file mode 100644 index 0000000..9e005de --- /dev/null +++ b/src/app/api-utlities/requests/charity-page.request copy.ts @@ -0,0 +1,5 @@ +import { charityRequest } from './common'; + +export const charityPageRequest = { + ...charityRequest, +}; diff --git a/src/app/api-utlities/requests/common.ts b/src/app/api-utlities/requests/common.ts index 3d4ab14..d936c5a 100644 --- a/src/app/api-utlities/requests/common.ts +++ b/src/app/api-utlities/requests/common.ts @@ -153,3 +153,31 @@ export const reviewsRequest = { }, }, }; + +export const charityRequest = { + _blagotvoriteln: { + records: { + _name: true, + _opisanie: true, + _data: true, + _lokaciya: true, + _foto: { + url: true, + }, + }, + }, +}; + +export const certificatesRequest = { + _sertifikaty: { + records: { + _name: true, + _opisanie: true, + _dataVydachi: true, + _dejstvitelenDo: true, + _foto: { + url: true, + }, + }, + }, +}; diff --git a/src/app/api/bonus/transactions/route.ts b/src/app/api/bonus/transactions/route.ts index d710705..f13d29b 100644 --- a/src/app/api/bonus/transactions/route.ts +++ b/src/app/api/bonus/transactions/route.ts @@ -41,7 +41,6 @@ const routeHandler = async (req: NextRequest, requestCookie: RequestCookie) => { }); }; -export const GET = authorizationMiddleware( - validationErrorHandler(routeHandler), - 'bonus__token', +export const GET = validationErrorHandler( + authorizationMiddleware(routeHandler, 'bonus__token'), ); diff --git a/src/app/api/corporate/info/route.ts b/src/app/api/corporate/info/route.ts index 575d652..9b48b06 100644 --- a/src/app/api/corporate/info/route.ts +++ b/src/app/api/corporate/info/route.ts @@ -13,7 +13,6 @@ const routeHandler = async (req: NextRequest, requestCookie: RequestCookie) => { }); }; -export const GET = authorizationMiddleware( - validationErrorHandler(routeHandler), - 'corporate__token', +export const GET = validationErrorHandler( + authorizationMiddleware(routeHandler, 'corporate__token'), ); diff --git a/src/app/charity/page.tsx b/src/app/charity/page.tsx index 4fc8510..55f31e9 100644 --- a/src/app/charity/page.tsx +++ b/src/app/charity/page.tsx @@ -1,5 +1,17 @@ -import { CharityPage } from "@/pages-templates/charity" +import { CharityPage } from '@/pages-templates/charity'; -export default function Charity() { - return -} \ No newline at end of file +import { mainPageApi } from '@/features/pages/api/pages.api'; + +import { makeStore } from '@/shared/store'; + +export default async function Charity() { + const store = makeStore(); + + const { data, isLoading, error } = await store.dispatch( + mainPageApi.endpoints.fetchCharityPageContent.initiate(), + ); + + if (isLoading || !data) return null; + + return ; +} diff --git a/src/app/clients/certificates/page.tsx b/src/app/clients/certificates/page.tsx index 5d63d14..3ba557c 100644 --- a/src/app/clients/certificates/page.tsx +++ b/src/app/clients/certificates/page.tsx @@ -1,5 +1,17 @@ import { CertificatesPage } from '@/pages-templates/clients/certificates'; -export default function Certificates() { - return ; +import { mainPageApi } from '@/features/pages/api/pages.api'; + +import { makeStore } from '@/shared/store'; + +export default async function Certificates() { + const store = makeStore(); + + const { data, isLoading, error } = await store.dispatch( + mainPageApi.endpoints.fetchCertificatesPageContent.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 index 6909d11..1a2bc40 100644 --- a/src/features/pages/api/pages.api.ts +++ b/src/features/pages/api/pages.api.ts @@ -1,8 +1,14 @@ import { jsonToGraphQLQuery } from 'json-to-graphql-query'; -import { AboutUsPageData } from '@/app/api-utlities/@types/about-us'; -import { MainPageData } from '@/app/api-utlities/@types/main'; import { + AboutUsPageData, + CertificatesPageData, + CharityPageData, + MainPageData, +} from '@/app/api-utlities/@types/pages'; +import { + presentCertificates, + presentCharities, presentDiscounts, presentHistoryItems, presentJobs, @@ -11,7 +17,9 @@ import { presentStations, presentTeamMembers, } from '@/app/api-utlities/presenters'; -import { aboutUsPageRequest } from '@/app/api-utlities/requests/about-us-page.request'; +import { aboutUsPageRequest } from '@/app/api-utlities/requests/about-us-page.request copy'; +import { certificatesPageRequest } from '@/app/api-utlities/requests/certificates-page.request'; +import { charityPageRequest } from '@/app/api-utlities/requests/charity-page.request copy'; import { mainPageRequest } from '@/app/api-utlities/requests/main-page.request'; import { taylorAPI } from '@/shared/api/taylor-api'; @@ -37,7 +45,7 @@ export const mainPageApi = taylorAPI.injectEndpoints({ }, }), - fetchAboutUsPageContent: builder.mutation({ + fetchAboutUsPageContent: builder.query({ query: () => ({ url: '', method: 'POST', @@ -55,5 +63,37 @@ export const mainPageApi = taylorAPI.injectEndpoints({ }; }, }), + + fetchCharityPageContent: builder.query({ + query: () => ({ + url: '', + method: 'POST', + body: { + query: jsonToGraphQLQuery({ query: charityPageRequest }), + }, + }), + + transformResponse: (response: any) => { + return { + charities: presentCharities(response.data._blagotvoriteln), + }; + }, + }), + + fetchCertificatesPageContent: builder.query({ + query: () => ({ + url: '', + method: 'POST', + body: { + query: jsonToGraphQLQuery({ query: certificatesPageRequest }), + }, + }), + + transformResponse: (response: any) => { + return { + certificates: presentCertificates(response.data._sertifikaty), + }; + }, + }), }), }); diff --git a/src/pages-templates/charity/index.tsx b/src/pages-templates/charity/index.tsx index e949daa..0132ced 100644 --- a/src/pages-templates/charity/index.tsx +++ b/src/pages-templates/charity/index.tsx @@ -10,6 +10,8 @@ import { } from 'lucide-react'; import Image from 'next/image'; +import { CharityPageData } from '@/app/api-utlities/@types/pages'; + import { Container } from '@/shared/components/container'; import { useTextController } from '@/shared/language/hooks/use-text-controller'; import { @@ -27,32 +29,11 @@ export const metadata = { 'Благотворительные проекты и инициативы Ориё. Мы помогаем обществу и заботимся о будущем.', }; -const events = [ - { - title: 'Благотворительный марафон', - description: - 'Ежегодный благотворительный марафон в поддержку детей с особыми потребностями.', - date: '15 июня 2023', - location: 'Парк Рудаки, Душанбе', - image: '/placeholder.svg?height=200&width=300&text=Марафон', - }, - { - title: 'Экологическая акция', - description: 'Очистка берегов реки Варзоб от мусора и посадка деревьев.', - date: '22 июля 2023', - location: 'Река Варзоб, Душанбе', - image: '/placeholder.svg?height=200&width=300&text=Экологическая+акция', - }, - { - title: 'Сбор школьных принадлежностей', - description: 'Сбор школьных принадлежностей для детей из малообеспеченных семей к новому учебному году.', - date: '1-20 августа 2023', - location: 'Все заправки GasNetwork', - image: '/placeholder.svg?height=200&width=300&text=Школьные+принадлежности', - }, -]; +export interface CharityPageProps { + content: CharityPageData; +} -export function CharityPage() { +export function CharityPage({ content }: CharityPageProps) { const { t } = useTextController(); return ( @@ -177,7 +158,7 @@ export function CharityPage() {
- {events.map((event, index) => ( + {content.charities.map((event, index) => ( {event.title}
- {event.title} + {event.name} @@ -256,7 +237,7 @@ export function CharityPage() { { title: 'Распространять информацию', description: - 'Расскажите о нашем фонде и его деятельности своим друзьям и знакомым.', + 'Расскажите о нашем фонде и его деятельности своим друзьям и знакомым.', icon: , }, ].map((item, index) => ( diff --git a/src/pages-templates/clients/certificates/index.tsx b/src/pages-templates/clients/certificates/index.tsx index 8b6ae63..32a08c8 100644 --- a/src/pages-templates/clients/certificates/index.tsx +++ b/src/pages-templates/clients/certificates/index.tsx @@ -3,69 +3,20 @@ import { Download, Eye } from 'lucide-react'; import Image from 'next/image'; +import { CertificatesPageData } from '@/app/api-utlities/@types/pages'; + import { Container } from '@/shared/components/container'; import { useTextController } from '@/shared/language/hooks/use-text-controller'; import { Button } from '@/shared/shadcn-ui/button'; import { Card, CardContent } from '@/shared/shadcn-ui/card'; -export function CertificatesPage() { +export interface CertificatesPageProps { + content: CertificatesPageData; +} + +export function CertificatesPage({ content }: CertificatesPageProps) { const { t } = useTextController(); - // This data would typically come from an API or CMS - // We're keeping it as-is since it's dynamic content - const certificates = [ - { - id: 1, - title: 'ISO 9001:2015', - description: 'Сертификат системы менеджмента качества', - image: '/placeholder.svg?height=400&width=300', - issueDate: '15.03.2022', - expiryDate: '15.03.2025', - }, - { - id: 2, - title: 'ISO 14001:2015', - description: 'Сертификат экологического менеджмента', - image: '/placeholder.svg?height=400&width=300', - issueDate: '10.05.2022', - expiryDate: '10.05.2025', - }, - { - id: 3, - title: 'OHSAS 18001', - description: 'Сертификат системы управления охраной труда', - image: '/placeholder.svg?height=400&width=300', - issueDate: '22.07.2022', - expiryDate: '22.07.2025', - }, - { - id: 4, - title: 'Сертификат качества топлива', - description: 'Подтверждение соответствия топлива стандартам качества', - image: '/placeholder.svg?height=400&width=300', - issueDate: '05.01.2023', - expiryDate: '05.01.2024', - }, - { - id: 5, - title: 'Сертификат соответствия', - description: 'Соответствие услуг национальным стандартам', - image: '/placeholder.svg?height=400&width=300', - issueDate: '18.09.2022', - expiryDate: '18.09.2025', - }, - { - id: 6, - title: 'Лицензия на хранение ГСМ', - description: 'Разрешение на хранение горюче-смазочных материалов', - image: '/placeholder.svg?height=400&width=300', - issueDate: '30.11.2021', - expiryDate: '30.11.2026', - }, - ]; - - certificates.length = 0; - return (
@@ -77,7 +28,7 @@ export function CertificatesPage() {
- {certificates.map((certificate) => ( + {content.certificates.map((certificate) => ( {certificate.title}
-

{certificate.title}

+

{certificate.name}

{certificate.description}

- {t('certificates.issueDate')}: {certificate.issueDate} + {t('certificates.issueDate')}: {certificate.issuedAt}

- {t('certificates.expiryDate')}: {certificate.expiryDate} + {t('certificates.expiryDate')}: {certificate.validUntil}