import { createFileRoute, useNavigate, useSearch } from '@tanstack/react-router'
import { p, MyButton } from 'web-components'
import { Zap } from 'lucide-react'

export const Route = createFileRoute('/flash/order-success')({
  component: FlashOrderSuccessPage,
  validateSearch: (search: Record<string, string>) => ({
    orderId: search.orderId || '',
    totalAmount: search.totalAmount || '0',
  }),
})

function FlashOrderSuccessPage() {
  const navigate = useNavigate()
  const { orderId, totalAmount } = Route.useSearch()

  return (
    <div className="flex min-h-screen flex-col items-center justify-center bg-yellow-50 p-6">
      <div className="mb-6 flex h-20 w-20 items-center justify-center rounded-full bg-yellow-100">
        <Zap className="h-10 w-10 text-yellow-600" />
      </div>
      <p className="font-bold mb-2 text-2xl text-gray-900">
        1 Hr Order Placed!
      </p>
      <p className="mb-1 text-gray-600">Order ID: #{orderId}</p>
      <p className="mb-8 text-gray-600">Total: ₹{totalAmount}</p>
      <MyButton
        textContent="Continue Shopping"
        onClick={() => navigate({ to: '/flash' })}
        className="mb-3 bg-brand-500 text-white"
      />
      <MyButton
        textContent="View My Orders"
        onClick={() => navigate({ to: '/me/orders' })}
        className="bg-gray-100 text-gray-700"
      />
    </div>
  )
}
