'use client'
import { Dispatch, SetStateAction, useState } from 'react'
import { priceConfig } from '@a11ywatch/website-source-builder'
import { Link } from '@app/components/stateless/typo/link'
import { SectionContainer } from '@app/components/stateless/containers/section-container'
import { PriceCell } from './cells/price-cell'
import { PriceFeat } from './cells/price-feat'
import { Header3 } from './header'
import { Button } from './buttons'
const getStyles = (inactive: boolean) =>
inactive ? ' border-gray-700' : 'text-blue-700 border-blue-700'
const getPrimaryColor = (title: string) => {
let color = '#0E1116'
if (title === 'Premium') {
color = '#8956ef'
} else if (title === 'Free') {
color = '#00875b'
} else if (title === 'Basic') {
color = '#2b72e6'
}
return color
}
function MainButton({
title,
navigate,
yearly,
}: {
title: string
yearly: boolean
navigate: boolean
}) {
if (navigate) {
return (
Get started
)
}
return null
}
interface PriceProps {
onClick?(newState: string): Promise
yearly?: boolean // render the yearly price
setYearly?: Dispatch> // toggle yearly
pricingPage?: boolean // pricing page
initialIndex?: number // selected plan index
highPlan?: boolean // high plans
currentPlan?: string // users current plan
}
export function PaymentPlans({
onClick,
yearly: year,
setYearly: setYear,
pricingPage,
initialIndex = 0,
highPlan = false,
currentPlan,
}: PriceProps) {
const [yearly, onSetYear] = useState(!!year)
const [selectedPlan, onSelectPlan] = useState(initialIndex || 0)
const [selectHighPlans, onSelectHigh] = useState(highPlan)
const setYearly = (cb: (x: boolean) => boolean) => {
if (typeof setYear === 'function') {
setYear(cb)
}
// inner state
onSetYear(cb)
}
const onSetYearlyEvent = () => {
setYearly((x: boolean) => !x)
}
const onPlanClick = (title: string, index: number) => {
if (typeof onClick === 'function') {
onClick(title)
}
onSelectPlan(index)
}
const onTogglePlans = () => {
onSelectHigh((x: boolean) => !x)
if (typeof onClick === 'function') {
if (pricingPage) {
const p = !selectHighPlans ? priceConfig.hPlans : priceConfig.lPlans
const s = selectedPlan >= 0 && p[selectedPlan].title
s && onClick(s)
} else if (currentPlan) {
const resetPlan =
(!selectHighPlans && currentPlan[0] === 'L') ||
(selectHighPlans && currentPlan[0] === 'H')
if (resetPlan) {
onSelectPlan(-1)
} else {
onSelectPlan(Number(currentPlan[1]) - 1)
}
}
}
}
const plans = selectHighPlans ? priceConfig.hPlans : priceConfig.lPlans
const selected = selectedPlan >= 0 && plans[selectedPlan].title
return (
<>
{typeof onClick === 'undefined' && !pricingPage ? (
<>
{pricingPage ? 'Plans for everyone' : 'Pricing'}
Flexible plans that can be adjusted at any time.
>
) : null}
{plans.map((planProps, index) => {
const title = planProps.title
const onPriceClick = () => onPlanClick(title, index)
const textColor = getPrimaryColor(title)
const selectedItem = index === selectedPlan
const activePlan = currentPlan === title
return (
-
)
})}
-
All pricing is in USD.
Renews are auto until cancelled.
{pricingPage && selected ? (
) : null}
Need more? We can easily handle millions of scans per minute,{' '}
get in touch
{' '}
for a quote.
>
)
}
export const Price = (props: any) => {
return (
)
}