MethodologySection.tsx 2.27 KB
import type { Methodology, MethodologyStep } from '../types/home';

export interface MethodologySectionProps {
  methodology: Methodology;
  currentStep: number;
  onStepChange: (index: number) => void;
}

export function MethodologySection({
  methodology,
  currentStep,
  onStepChange,
}: MethodologySectionProps) {
  if (!methodology.display_status || methodology.steps.length === 0) {
    return null;
  }

  const currentStepData: MethodologyStep | undefined = methodology.steps[currentStep];

  if (!currentStepData) {
    return null;
  }

  return (
    <section className="py-24 relative overflow-hidden bg-surface-container-lowest" data-testid="methodology-section">
      <div className="max-w-container-max mx-auto px-margin-mobile tablet:px-margin-desktop relative z-10">
        <div className="mb-16">
          <h2 className="text-headline-md mb-2">{methodology.main_title}</h2>
          <p className="text-body-md text-on-surface-variant">{methodology.sub_title}</p>
        </div>

        <div className="grid grid-cols-1 tablet:grid-cols-2 lg:grid-cols-4 gap-8">
          {methodology.steps.map((step, index) => (
            <div
              key={index}
              onClick={() => onStepChange(index)}
              data-testid={`step-${index}`}
              className={`flex flex-col bg-white rounded-3xl border shadow-sm hover:shadow-xl hover:-translate-y-2 transition-all duration-300 overflow-hidden cursor-pointer ${
                index === currentStep
                  ? 'border-primary/40'
                  : 'border-outline-variant/30'
              }`}
            >
              <div className="w-full h-48 bg-primary/5 flex items-center justify-center overflow-hidden">
                <img
                  src={step.step_image}
                  alt={step.step_name}
                  className="w-full h-full object-cover"
                />
              </div>
              <div className="p-8 pt-6">
                <h4 className="text-headline-sm text-[20px] font-bold text-primary mb-3">{step.step_name}</h4>
                <p className="text-body-md text-on-surface-variant text-sm leading-relaxed">
                  {step.step_description}
                </p>
              </div>
            </div>
          ))}
        </div>
      </div>
    </section>
  );
}