feat: generate landing stub types outside (#33)

This commit is contained in:
RustamRu
2024-11-25 23:37:14 +03:00
parent 409c339b3c
commit 012de3c670
13 changed files with 78 additions and 189 deletions

View File

@@ -1,9 +1,17 @@
import React, { FC } from 'react';
import { Container, VStack } from '@chakra-ui/react';
import LandingSuccess from '../../../stubs/json/landing/landing-success.json';
import { BenefitsSection, Footer, HeroSection, SocialProofSection } from '../../components/landing';
import {
BenefitsSection,
Footer,
HeroSection,
SocialProofSection,
} from '../../components/landing';
import { LandingThemeProvider } from '../../containers';
import { LandingSuccessStub } from '../../models/landing';
const landingSuccessStub = import(
'../../../stubs/json/landing/success.json'
) as unknown as LandingSuccessStub;
import { isBenefitsSectionData, isSocialProofSectionData } from './types';
@@ -20,11 +28,11 @@ const Page: FC = () => {
>
<VStack w='full' h='full' alignItems='stretch' flexGrow={1}>
<HeroSection
data={LandingSuccess.body['hero-section']}
data={landingSuccessStub['body']['hero-section']}
flexShrink={0}
/>
<VStack as='main' flexGrow={1}>
{LandingSuccess.body.sections.map(({ type, ...data }, i) => {
{landingSuccessStub.body.sections.map(({ type, ...data }, i) => {
if (isBenefitsSectionData(type, data)) {
return <BenefitsSection key={i} data={data} />;
}

View File

@@ -1,8 +1,8 @@
import LandingSuccess from "../../../stubs/json/landing/landing-success.json";
import LandingSuccess from "../../../stubs/json/landing/success.json";
import { BenefitsSectionProps, SocialProofSectionProps } from "../../components/landing";
import { ArrElement } from "../../lib";
type SectionsItemData = ArrElement<LandingSuccess['body']['sections']>;
type SectionsItemData = ArrElement<typeof LandingSuccess['body']['sections']>;
type SectionType = SectionsItemData['type'];
type SectionData = Omit<SectionsItemData, 'type'>;