PITRNotice.tsx 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. import { PermissionAction } from '@supabase/shared-types/out/constants'
  2. import { useParams } from 'common'
  3. import { Calendar } from 'lucide-react'
  4. import Link from 'next/link'
  5. import { getPITRRetentionDuration } from './PITR.utils'
  6. import { ButtonTooltip } from '@/components/ui/ButtonTooltip'
  7. import { FormPanel } from '@/components/ui/Forms/FormPanel'
  8. import { useProjectAddonsQuery } from '@/data/subscriptions/project-addons-query'
  9. import { useAsyncCheckPermissions } from '@/hooks/misc/useCheckPermissions'
  10. export const PITRNotice = () => {
  11. const { ref: projectRef } = useParams()
  12. const { data: addonsResponse } = useProjectAddonsQuery({ projectRef })
  13. const retentionPeriod = getPITRRetentionDuration(addonsResponse?.selected_addons ?? [])
  14. const { can: canUpdateSubscription } = useAsyncCheckPermissions(
  15. PermissionAction.BILLING_WRITE,
  16. 'stripe.subscriptions'
  17. )
  18. return (
  19. <FormPanel
  20. disabled={true}
  21. footer={
  22. <div className="flex items-center justify-between p-6">
  23. <span className="text-sm text-foreground-light">
  24. You can also increase your recovery retention period updating your PITR add-on
  25. </span>
  26. <ButtonTooltip
  27. asChild
  28. disabled={!canUpdateSubscription}
  29. type="default"
  30. tooltip={{
  31. content: {
  32. side: 'bottom',
  33. text: !canUpdateSubscription
  34. ? 'You need additional permissions to amend subscriptions'
  35. : undefined,
  36. },
  37. }}
  38. >
  39. <Link href={`/project/${projectRef}/settings/addons?panel=pitr`}>
  40. Increase retention period
  41. </Link>
  42. </ButtonTooltip>
  43. </div>
  44. }
  45. >
  46. <div className="flex p-6 space-x-6">
  47. <div className="flex items-center justify-center w-10 h-10 rounded-sm bg-border-strong">
  48. <Calendar strokeWidth={2} />
  49. </div>
  50. <div className="space-y-2">
  51. <p className="text-sm">Recovery retention period</p>
  52. <p className="text-sm text-foreground-light">
  53. Database changes are logged every <span className="text-foreground">2 minutes</span>,
  54. with a total recovery period of up to{' '}
  55. <span className="text-brand">{retentionPeriod} days</span>.
  56. </p>
  57. </div>
  58. </div>
  59. </FormPanel>
  60. )
  61. }