'use client'
import type { FC } from 'react'
import { useSuspenseQuery } from '@tanstack/react-query'
import * as React from 'react'
import { useCallback } from 'react'
import { useTranslation } from 'react-i18next'
import UpgradeBtn from '@/app/components/billing/upgrade-btn'
import { useModalContext } from '@/context/modal-context'
import { systemFeaturesQueryOptions } from '@/features/system-features/client'

const UpgradeCard: FC = () => {
  const { t } = useTranslation()
  const { data: deploymentEdition } = useSuspenseQuery({
    ...systemFeaturesQueryOptions(),
    select: ({ deployment_edition }) => deployment_edition,
  })
  const { setShowPricingModal } = useModalContext()

  const handleUpgrade = useCallback(() => {
    setShowPricingModal()
  }, [setShowPricingModal])

  if (deploymentEdition !== 'CLOUD') return null

  return (
    <div className="flex items-center justify-between rounded-xl border-[0.5px] border-components-panel-border-subtle bg-components-panel-on-panel-item-bg py-3 pr-3.5 pl-4 shadow-xs backdrop-blur-[5px]">
      <div>
        <div className="bg-[linear-gradient(92deg,var(--components-input-border-active-prompt-1,#0BA5EC)_0%,var(--components-input-border-active-prompt-2,#155AEF)_99.21%)] bg-clip-text title-md-semi-bold text-transparent">
          {t(($) => $['upgrade.uploadMultipleFiles.title'], { ns: 'billing' })}
        </div>
        <div className="system-xs-regular text-text-tertiary">
          {t(($) => $['upgrade.uploadMultipleFiles.description'], { ns: 'billing' })}
        </div>
      </div>
      <UpgradeBtn
        size="custom"
        isShort
        className="ml-3 h-8! rounded-lg! px-2"
        labelKey="triggerLimitModal.upgrade"
        loc="upload-multiple-files"
        onClick={handleUpgrade}
      />
    </div>
  )
}
export default React.memo(UpgradeCard)
