'use client'
import React, { useState } from 'react'
import BackButton from '@/components/common/BackButton';
import { FMCG_DATA } from '@/constants';
import { useLocale, useTranslations } from 'next-intl';
import Head from 'next/head';
import TabsRender from '@/components/industries/TabsRender';
import Image from 'next/image';
import { META_AR } from '@/seo/seo-ar';
import { META_EN } from '@/seo/seo-en';
import { ROUTES, DOMAIN } from '@/routes';

const Fmcg = () => {
    const t = useTranslations('Common');
    const locale = useLocale();
    const data = FMCG_DATA(t)
    const META = locale === 'ar' ? META_AR : META_EN;
    const [imageError, setImageError] = useState(false);

    return (
        <>
            <Head>
                <title>{META.INDUSTRIES.FMCG.title}</title>
                <meta name="description" content={META.INDUSTRIES.FMCG.description} />
                {/* Canonical URL */}
                <link rel="canonical" href={`${DOMAIN}${ROUTES.FMCG}`} />
                {/* Open Graph Meta Tags */}
                <meta property="og:title" content={META.INDUSTRIES.FMCG.title} />
                <meta property="og:description" content={META.INDUSTRIES.FMCG.description} />
                <meta property="og:type" content="website" />
                <meta property="og:url" content={`${DOMAIN}${ROUTES.FMCG}`} />
                {/* Twitter Meta Tags */}
                <meta name="twitter:title" content={META.INDUSTRIES.FMCG.title} />
                <meta name="twitter:description" content={META.INDUSTRIES.FMCG.description} />
                {/* Keywords */}
                <meta name="keywords" content={META.INDUSTRIES.FMCG.keywords} />
            </Head>

            <div className="max-w-section m-auto pt-10 lg:pt-20">
                <div className="grid grid-cols-12 gap-4">
                    <div className='col-span-12'>
                        <BackButton />
                    </div>

                    <div className="col-span-12 lg:col-span-8">
                        <h2 className='main-heading  max-w-[700px]'>
                            {t('indust_fmcg_h')}
                        </h2>
                        <p className='caption  mt-8'>
                            {t('indust_fmcg_b')}
                        </p>
                    </div>

                    <div className="col-span-12 lg:col-span-4">
                        {imageError ? (
                            <div className="w-full h-[500px] bg-gray-200 flex items-center justify-center">
                                <span className="text-gray-500">Image unavailable</span>
                            </div>
                        ) : (
                            <Image
                                src="/images/fpg.png"
                                alt="Market analysis and consulting for fast-moving consumer goods"
                                width={500}
                                height={500}
                                loading="lazy"
                                quality={80}
                                placeholder="blur"
                                blurDataURL="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI0MDAiIGhlaWdodD0iMzAwIj48cmVjdCB3aWR0aD0iNDAwIiBoZWlnaHQ9IjMwMCIgZmlsbD0iI2VlZWVlZSIvPjwvc3ZnPg=="
                                onError={() => setImageError(true)}
                            />
                        )}
                    </div>
                </div>

                <div className="grid grid-cols-12 gap-4">
                    <div className="col-span-12">
                        <TabsRender defaultValue={'indust_fmcg_s1_h'} data={data} />
                    </div>
                </div>
            </div>
        </>
    )
}

export default Fmcg