import { Box, HoverCard, SelectProps, Typography } from '@tidbcloud/uikit'
import { FormSelect, FormTextInput } from '@tidbcloud/uikit/biz'
import { IconInfoCircle } from '@tidbcloud/uikit/icons'

interface AwsFormContentProps {
  disabled: boolean
  regions: SelectProps['data']
}

const AwsFormContent = ({ disabled, regions }: AwsFormContentProps) => {
  return (
    <>
      <FormTextInput
        name="bucket_uri"
        autoComplete="off"
        placeholder={`Example: s3://bucket-name/path/to/dump/`}
        label={`Bucket URI`}
        disabled={disabled}
      />

      <FormSelect
        name="bucket_region_id"
        label="Bucket Region"
        placeholder="Select a region"
        data={regions}
        my={24}
        disabled={true}
      />

      <FormTextInput
        disabled={disabled}
        name="role_arn"
        autoComplete="off"
        placeholder="arn:aw:iam:001234567890:role/myrole"
        label={
          <Box
            sx={{
              display: 'inline-flex',
              alignItems: 'center'
            }}
          >
            <Typography variant="label-lg">Role ARN</Typography>
            <HoverCard
              withArrow
              withinPortal
              shadow="md"
              position="top"
              width={500}
            >
              <HoverCard.Target>
                <IconInfoCircle size={14} ml={4} />
              </HoverCard.Target>
              <HoverCard.Dropdown>
                <Typography mb={8}>
                  Enter your AWS S3 IAM Role ARN Information, refer to{' '}
                  <a
                    href="https://docs.pingcap.com/tidbcloud/tidb-cloud-auditing/#step-2-configure-amazon-s3-access"
                    target="_blank"
                    rel="noopener noreferrer"
                  >
                    documentation
                  </a>
                  .
                </Typography>
              </HoverCard.Dropdown>
            </HoverCard>
          </Box>
        }
      />
    </>
  )
}

export default AwsFormContent
