import { Metadata } from 'next';
import { defaultMeta } from '../defaultMeta';
import { pathnames } from '../../../../pathnames';
import { getLocale } from 'next-intl/server';

export const getSupplyChainManagerMeta = async (t: (key: string) => string): Promise<Metadata> => {
    const locale = await getLocale();
    const path = pathnames['/roles-dans-l-entreprise/responsable-supply-chain'][locale as 'en' | 'fr'];
    const fullUrl = `${process.env.NEXT_PUBLIC_FRONTEND_HOST}${locale === 'en' ? '/en' : ''}${path}`;

    const frUrl = `${process.env.NEXT_PUBLIC_FRONTEND_HOST}${pathnames['/roles-dans-l-entreprise/responsable-supply-chain'].fr}`;
    const enUrl = `${process.env.NEXT_PUBLIC_FRONTEND_HOST}/en${pathnames['/roles-dans-l-entreprise/responsable-supply-chain'].en}`;

    return {
        ...defaultMeta,
        title: t("Responsable Supply Chain - Logistique & Transport"),
        description: t("Améliorez la gestion et l'efficacité de votre chaîne d'approvisionnement grâce à un suivi précis"),
        keywords: t('supply chain, logistique, optimisation transport'),
        openGraph: {
            ...defaultMeta.openGraph,
            title: t("Responsable Supply Chain - Logistique & Transport"),
            description: t("Améliorez la gestion et l'efficacité de votre chaîne d'approvisionnement grâce à un suivi précis"),
            url: fullUrl,
        },
        twitter: {
            ...defaultMeta.twitter,
            title: t("Responsable Supply Chain - Logistique & Transport"),
            description: t("Améliorez la gestion et l'efficacité de votre chaîne d'approvisionnement grâce à un suivi précis"),
        },
        alternates: {
            canonical: fullUrl,
            languages: {
                'fr': frUrl,
                'en': enUrl,
                'x-default': frUrl,
            },
        },
    };
};