update: get main-page-data

This commit is contained in:
BunyodL 2025-04-29 01:22:24 +05:00
parent 82018cea2c
commit 240aaa81ae
4 changed files with 28 additions and 3 deletions

View File

@ -45,6 +45,6 @@ export type Station = Root<{
_propanCopy: boolean;
_zaryadnayaStanci: boolean;
_miniMarketCop: boolean;
_region: Select;
_region: Select[];
_foto: Image[];
}>;

View File

@ -0,0 +1,18 @@
import {
presentDiscounts,
presentJobs,
presentPartners,
presentStations,
} from '../presenters';
export type Partners = ReturnType<typeof presentPartners>;
export type Jobs = ReturnType<typeof presentJobs>;
export type Discounts = ReturnType<typeof presentDiscounts>;
export type Stations = ReturnType<typeof presentStations>;
export type MainPageData = {
discounts: Discounts;
jobs: Jobs;
partners: Partners;
stations: Stations;
};

View File

@ -28,7 +28,7 @@ export const presentDiscounts = (discounts: Discount) =>
}));
export const presentStations = (stations: Station) =>
stations.records.map((station: any) => ({
stations.records.map((station) => ({
name: station._name,
description: station._opisanie,
address: station._adress,

View File

@ -8,7 +8,14 @@ import { PromotionsSection } from '@/widgets/promotions-section';
import { StatsSection } from '@/widgets/stats-section';
import { VacanciesSection } from '@/widgets/vacancies-section';
export default function Home() {
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;
return (
<main>
<HeroSection />