Files
supabase/apps/studio/components/interfaces/DiskManagement/BillingChangeBadge.tsx
Joshen LimandKevin Grüneberg bcb847bbbb Chore/update rr pricing for new disk mgt (#29278)
* Update pricing details in DeployNewReplicaPanel

* Update disk mgt review modal to consider RR pricing

* Update tests

* Hide utilization bar for read replicas in new disk mgt ui

* Add guard

* Update link to docs for deploy replica panel

* Address feedback

* Ensure IOPS and throughput prices are considered for replicas

* Prettier

* Attempt to fix tests

* Attempt to fix tests

* Fix calculateDiskSizePrice for replicas

* Fixes

* Prettier

* Add ternary

* Feeeex

* Various small updates from Kevin's feedback

* smol stuff

* fixes

* Update DiskManagementPanelSchema.ts

---------

Co-authored-by: Kevin Grüneberg <k.grueneberg1994@gmail.com>
2024-09-18 18:38:58 +08:00

53 lines
1.7 KiB
TypeScript

import { AnimatePresence, motion } from 'framer-motion'
import { formatCurrency } from 'lib/helpers'
import { ChevronRight } from 'lucide-react'
import { Badge, Tooltip_Shadcn_, TooltipContent_Shadcn_, TooltipTrigger_Shadcn_ } from 'ui'
interface BillingChangeBadgeProps {
beforePrice?: number
afterPrice?: number
show: boolean | undefined
tooltip?: string
}
const BillingChangeBadge = ({
beforePrice,
afterPrice,
show,
tooltip,
}: BillingChangeBadgeProps) => {
return (
<AnimatePresence>
{beforePrice !== undefined && afterPrice !== undefined && show && (
<motion.div
initial={{ opacity: 0, x: -4 }}
animate={{ opacity: 1, x: 0 }}
exit={{ opacity: 0, x: -4 }}
transition={{ duration: 0.15 }}
>
<Badge variant="default" className="bg-alternative bg-opacity-100">
<Tooltip_Shadcn_>
<TooltipTrigger_Shadcn_ asChild>
<div className="flex items-center gap-1">
<span className="text-xs font-mono text-foreground-muted">
{formatCurrency(beforePrice)}
</span>
<ChevronRight size={12} strokeWidth={2} className="text-foreground-muted" />
<span className="text-xs font-mono text-foreground">
{formatCurrency(afterPrice)}
</span>
</div>
</TooltipTrigger_Shadcn_>
{tooltip !== undefined && (
<TooltipContent_Shadcn_ side="bottom">{tooltip}</TooltipContent_Shadcn_>
)}
</Tooltip_Shadcn_>
</Badge>
</motion.div>
)}
</AnimatePresence>
)
}
export default BillingChangeBadge