ReadReplicaPricingDialog.tsx 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. import {
  2. cn,
  3. Dialog,
  4. DialogContent,
  5. DialogFooter,
  6. DialogHeader,
  7. DialogSection,
  8. DialogSectionSeparator,
  9. DialogTitle,
  10. DialogTrigger,
  11. Table,
  12. TableBody,
  13. TableCell,
  14. TableHead,
  15. TableHeader,
  16. TableRow,
  17. } from 'ui'
  18. import { useGetReplicaCost } from './useGetReplicaCost'
  19. import { TaxDisclaimer } from '@/components/interfaces/Billing/TaxDisclaimer'
  20. import { DocsButton } from '@/components/ui/DocsButton'
  21. import { InlineLinkClassName } from '@/components/ui/InlineLink'
  22. import { useSelectedProjectQuery } from '@/hooks/misc/useSelectedProject'
  23. import { DOCS_URL } from '@/lib/constants'
  24. export const ReadReplicaPricingDialog = () => {
  25. const { data: project } = useSelectedProjectQuery()
  26. const { compute, disk, iops, throughput } = useGetReplicaCost()
  27. const showNewDiskManagementUI = project?.cloud_provider === 'AWS'
  28. return (
  29. <Dialog>
  30. <DialogTrigger asChild>
  31. <button className={cn(InlineLinkClassName, 'text-sm text-foreground-light')}>
  32. Learn more
  33. </button>
  34. </DialogTrigger>
  35. <DialogContent
  36. size={showNewDiskManagementUI ? 'medium' : 'small'}
  37. aria-describedby={undefined}
  38. >
  39. <DialogHeader>
  40. <DialogTitle>Calculating costs for a new read replica</DialogTitle>
  41. </DialogHeader>
  42. <DialogSectionSeparator />
  43. <DialogSection>
  44. {showNewDiskManagementUI ? (
  45. <>
  46. <p className="text-foreground-light text-sm mb-2">
  47. Read replicas will match the compute size of your primary database and will include
  48. 25% more disk size than the primary database to accommodate WAL files.
  49. </p>
  50. <p className="text-foreground-light text-sm">
  51. The additional cost for the replica breaks down to:
  52. </p>
  53. <Table>
  54. <TableHeader className="font-mono uppercase text-xs [&_th]:h-auto [&_th]:pb-2 [&_th]:pt-4">
  55. <TableRow>
  56. <TableHead className="w-[140px] pl-0">Item</TableHead>
  57. <TableHead>Description</TableHead>
  58. <TableHead className="text-right pr-0">Cost (/month)</TableHead>
  59. </TableRow>
  60. </TableHeader>
  61. <TableBody className="[&_td]:py-0 [&_tr]:h-[50px] [&_tr]:border-dotted">
  62. <TableRow>
  63. <TableCell className="pl-0">Compute size</TableCell>
  64. <TableCell>{compute.label}</TableCell>
  65. <TableCell className="text-right font-mono pr-0" translate="no">
  66. {compute.cost}
  67. </TableCell>
  68. </TableRow>
  69. <TableRow>
  70. <TableCell className="pl-0">Disk size</TableCell>
  71. <TableCell>{disk.label}</TableCell>
  72. <TableCell className="text-right font-mono pr-0" translate="no">
  73. {disk.cost}
  74. </TableCell>
  75. </TableRow>
  76. <TableRow>
  77. <TableCell className="pl-0">IOPS</TableCell>
  78. <TableCell>{iops.label}</TableCell>
  79. <TableCell className="text-right font-mono pr-0" translate="no">
  80. {iops.cost}
  81. </TableCell>
  82. </TableRow>
  83. {disk.type === 'gp3' && (
  84. <TableRow>
  85. <TableCell className="pl-0">Throughput</TableCell>
  86. <TableCell>{throughput.label}</TableCell>
  87. <TableCell className="text-right font-mono pr-0">{throughput.cost}</TableCell>
  88. </TableRow>
  89. )}
  90. </TableBody>
  91. </Table>
  92. </>
  93. ) : (
  94. <p className="text-foreground-light text-sm">
  95. Read replicas will be on the same compute size as your primary database. Deploying a
  96. read replica on the <span className="text-foreground">{compute.label}</span> size
  97. incurs additional{' '}
  98. <span className="text-foreground" translate="no">
  99. {compute?.priceDescription}
  100. </span>
  101. .
  102. </p>
  103. )}
  104. <TaxDisclaimer className="mt-3" />
  105. </DialogSection>
  106. <DialogFooter>
  107. <DocsButton href={`${DOCS_URL}/guides/platform/manage-your-usage/read-replicas`} />
  108. </DialogFooter>
  109. </DialogContent>
  110. </Dialog>
  111. )
  112. }