import { getDriverRepository } from '@/lib/di-container';
import { EntityMappers } from '@/application/mappers/EntityMappers';
import CreateDriverForm from '@/components/alpha/CreateDriverForm';
import DriverProfile from '@/components/alpha/DriverProfile';
import Card from '@/components/ui/Card';
import FeatureLimitationTooltip from '@/components/alpha/FeatureLimitationTooltip';

export default async function ProfilePage() {
  const driverRepo = getDriverRepository();
  const drivers = await driverRepo.findAll();
  const driver = EntityMappers.toDriverDTO(drivers[0] || null);

  return (
    <div className="max-w-4xl mx-auto">
          <div className="text-center mb-8">
            <h1 className="text-3xl font-bold text-white mb-2">Driver Profile</h1>
            <p className="text-gray-400">
              {driver ? 'Your GridPilot profile' : 'Create your GridPilot profile to get started'}
            </p>
          </div>

          {driver ? (
            <>
              <FeatureLimitationTooltip message="Profile editing coming in production">
                <div className="opacity-75 pointer-events-none">
                  <DriverProfile driver={driver} />
                </div>
              </FeatureLimitationTooltip>
            </>
          ) : (
            <Card className="max-w-2xl mx-auto">
              <div className="mb-6">
                <h2 className="text-xl font-semibold text-white mb-2">Create Your Profile</h2>
                <p className="text-gray-400 text-sm">
                  Create your driver profile. Alpha data resets on reload, so test freely.
                </p>
              </div>
              <CreateDriverForm />
            </Card>
          )}
    </div>
  );
}