import React from "react";
import strapiApi from "@/api/strapi/strapi-api";
import {BlocksContent, BlocksRenderer} from "@strapi/blocks-react-renderer";
import SubscribeComponent from "@/components/subscribe.component";
import FooterComponent from "@/components/footer.component";
import SubHeaderComponent from "@/components/subHeader.component";
import AosComponent from "@/components/aos.component";
import styles from './page.module.css'
import NextBlocksRenderer from "@/components/next.blocks.renderer";

export default async function ServiceArticlePage({params}: {
    params: Promise<{ slug: string }>
}) {
    const {slug} = await params
    const {header, description, footer, subscribeNow} = await strapiApi.getServicePage();
    const servicesByName = await strapiApi.getService(slug);
    const selectedService = servicesByName[0];
    const article = selectedService.article;
    console.info(article);

    selectedService.article
    return (
        <>
            {selectedService && selectedService.header && selectedService.description &&
                <SubHeaderComponent header1={selectedService.header} description={selectedService.description}/>}
            <section className={styles.article}>
                <div className="container">
                    <div className={"row"}>
                        <div className={"col-lg-12 col-md-12 col-sm-12 col-xs-12"}>
                            <NextBlocksRenderer
                                content={article as BlocksContent}
                            />
                        </div>
                    </div>
                </div>

            </section>
            {subscribeNow && <SubscribeComponent config={subscribeNow}/>}
            {footer && <FooterComponent config={footer}/>}
            <AosComponent/>
        </>
    );
}

export const dynamic = 'force-dynamic'
