import React, { Suspense } from 'react'; import type { Metadata } from 'next'; import { unstable_setRequestLocale } from 'next-intl/server'; import { notFound } from 'next/navigation'; import { getExpertById, getExpertsList } from '../../../../actions/experts'; import { ExpertCard, ExpertCertificate, ExpertInformation, ExpertPractice } from '../../../../components/Experts/ExpertDetails'; import { Details } from '../../../../types/experts'; import { BackButton } from '../../../../components/view/BackButton'; import { i18nText } from '../../../../i18nKeys'; export const metadata: Metadata = { title: 'Bbuddy - Experts item', description: 'Bbuddy desc experts' }; export async function generateStaticParams({ params: { locale }, }: { params: { locale: string } }) { unstable_setRequestLocale(locale); const result: { locale: string, expertId: string }[] = []; const experts = await getExpertsList(locale, { themesTagIds: [] }); experts?.coaches?.forEach(({ id }) => { result.push({ locale, expertId: id.toString() }); }); return result; } export default async function ExpertItem({ params: { expertId = '', locale } }: { params: { expertId: string, locale: string } }) { if (!expertId) notFound(); const expert = await getExpertById(expertId, locale); console.log(expert); const getAssociationLevel = (accLevelId?: number) => { if (accLevelId) { const [cur] = (expert?.associationLevels || []).filter(({ id }) => id === accLevelId) || []; return cur?.name || ''; } return ''; }; const getAssociation = (accLevelId?: number) => { if (accLevelId) { const [curLevel] = (expert?.associationLevels || []).filter(({ id }) => id === accLevelId) || []; if (curLevel) { const [cur] = (expert?.associations || []).filter(({ id }) => id === curLevel.associationId) || []; return cur?.name || ''; } } return ''; }; const generateDescription = ({ id, title, description, document }: Details) => (
{description}
{document && (Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam aliquet, lectus nec viverra malesuada, ligula sem tempor risus, non posuere urna diam a libero.
{expert?.publicCoachDetails?.educations && expert.publicCoachDetails.educations?.map(generateDescription)} {expert?.publicCoachDetails?.certificates && expert.publicCoachDetails.certificates.length > 0 && ({`${getAssociationLevel(cert?.associationLevelId)} ${getAssociation(cert?.associationLevelId)}`}
{cert.document && (