'use client'

import { useState } from 'react'
import { ProvisioningWizard } from './ProvisioningWizard'
import { Button } from '@/components/ui/button'
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'

export default function ResourceProvisioningPage() {
  const [showWizard, setShowWizard] = useState(false)
  const [provisionedResourceId, setProvisionedResourceId] = useState<string | null>(null)

  if (provisionedResourceId) {
    return (
      <div className="container mx-auto p-6">
        <Card>
          <CardHeader>
            <CardTitle>Provisioning Complete</CardTitle>
          </CardHeader>
          <CardContent>
            <p className="mb-4">
              Resource has been provisioned successfully! Resource ID: {provisionedResourceId}
            </p>
            <div className="flex gap-2">
              <Button
                variant="phoenix"
                onClick={() => {
                  setProvisionedResourceId(null)
                  setShowWizard(false)
                }}
              >
                Provision Another Resource
              </Button>
              <Button
                variant="outline"
                onClick={() => (window.location.href = '/resources')}
              >
                View Resources
              </Button>
            </div>
          </CardContent>
        </Card>
      </div>
    )
  }

  if (!showWizard) {
    return (
      <div className="container mx-auto p-6">
        <Card>
          <CardHeader>
            <CardTitle>Resource Provisioning</CardTitle>
          </CardHeader>
          <CardContent>
            <p className="mb-6 text-gray-400">
              Provision new compute, storage, or network resources for your infrastructure.
            </p>
            <Button variant="phoenix" onClick={() => setShowWizard(true)}>
              Start Provisioning
            </Button>
          </CardContent>
        </Card>
      </div>
    )
  }

  return (
    <ProvisioningWizard
      onComplete={(resourceId) => {
        setProvisionedResourceId(resourceId)
        setShowWizard(false)
      }}
      onCancel={() => setShowWizard(false)}
    />
  )
}

