UpgradePrompt.tsx 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. import Link from 'next/link'
  2. import { Button, Modal } from 'ui'
  3. import { TIER_QUERY_LIMITS } from './Logs.constants'
  4. import { useSelectedOrganizationQuery } from '@/hooks/misc/useSelectedOrganization'
  5. interface Props {
  6. show: boolean
  7. setShowUpgradePrompt: (value: boolean) => void
  8. title?: string
  9. description?: string
  10. source?: string
  11. }
  12. /**
  13. * @param show - whether to show the modal
  14. * @param setShowUpgradePrompt - function to set the show state
  15. * @param title - title of the modal
  16. * @param description - description of the modal
  17. * @param source - source of the upgrade prompt used to track the source of the upgrade prompt in the billing page
  18. * @returns
  19. */
  20. const UpgradePrompt: React.FC<Props> = ({
  21. show,
  22. setShowUpgradePrompt,
  23. title = 'Log retention',
  24. description = 'Logs can be retained up to a duration of 3 months depending on the plan that your project is on.',
  25. source = 'logsRetentionUpgradePrompt',
  26. }) => {
  27. const { data: organization } = useSelectedOrganizationQuery()
  28. return (
  29. <Modal
  30. hideFooter
  31. visible={show}
  32. size="medium"
  33. header={title}
  34. onCancel={() => setShowUpgradePrompt(false)}
  35. >
  36. <Modal.Content>
  37. <div className="space-y-4">
  38. <p className="text-sm">{description}</p>
  39. <div className="border-control bg-surface-300 rounded-sm border">
  40. <div className="flex items-center px-4 pt-2 pb-1">
  41. <p className="text-foreground-light w-[40%] text-sm">Plan</p>
  42. <p className="text-foreground-light w-[60%] text-sm">Retention duration</p>
  43. </div>
  44. <div className="py-1">
  45. <div className="flex items-center px-4 py-1">
  46. <p className="w-[40%] text-sm">Free</p>
  47. <p className="w-[60%] text-sm">{TIER_QUERY_LIMITS.FREE.text}</p>
  48. </div>
  49. <div className="flex items-center px-4 py-1">
  50. <p className="w-[40%] text-sm">Pro</p>
  51. <p className="w-[60%] text-sm">{TIER_QUERY_LIMITS.PRO.text}</p>
  52. </div>
  53. <div className="flex items-center px-4 py-1">
  54. <p className="w-[40%] text-sm">Team</p>
  55. <p className="w-[60%] text-sm">{TIER_QUERY_LIMITS.TEAM.text}</p>
  56. </div>
  57. <div className="flex items-center px-4 py-1">
  58. <p className="w-[40%] text-sm">Enterprise</p>
  59. <p className="w-[60%] text-sm">{TIER_QUERY_LIMITS.ENTERPRISE.text}</p>
  60. </div>
  61. </div>
  62. </div>
  63. </div>
  64. </Modal.Content>
  65. <Modal.Separator />
  66. <Modal.Content className="flex justify-end gap-3">
  67. <Button type="default" onClick={() => setShowUpgradePrompt(false)}>
  68. Close
  69. </Button>
  70. <Button asChild size="tiny">
  71. <Link href={`/org/${organization?.slug}/billing?panel=subscriptionPlan&source=${source}`}>
  72. Upgrade
  73. </Link>
  74. </Button>
  75. </Modal.Content>
  76. </Modal>
  77. )
  78. }
  79. export default UpgradePrompt