mirror of
https://github.com/vercel/commerce.git
synced 2025-05-11 20:27:51 +00:00
46 lines
1.2 KiB
TypeScript
46 lines
1.2 KiB
TypeScript
'use client';
|
|
|
|
import Price from 'components/price';
|
|
import { cn } from 'lib/utils';
|
|
import { ReactNode, useState } from 'react';
|
|
|
|
const options = ['Included', 'Premium Labor', '+1 Year'] as const;
|
|
type Option = (typeof options)[number];
|
|
|
|
const plans: Array<{
|
|
key: Option;
|
|
template: ReactNode;
|
|
price: number;
|
|
}> = [
|
|
{
|
|
template: <span className="font-bold">3-Year Warranty</span>,
|
|
price: 0,
|
|
key: 'Included'
|
|
}
|
|
];
|
|
const WarrantySelector = () => {
|
|
const [selectedOptions, setSelectedOptions] = useState<Option>('Included');
|
|
return (
|
|
<ul className="flex min-h-16 flex-row space-x-4 pt-2">
|
|
{plans.map((plan) => (
|
|
<li key={plan.key} className="flex w-32">
|
|
<button
|
|
onClick={() => setSelectedOptions(plan.key)}
|
|
className={cn(
|
|
'font-base flex w-full flex-col flex-wrap items-center justify-center space-y-0.5 rounded border text-center text-xs',
|
|
{
|
|
'border-0 ring-2 ring-secondary': plan.key === selectedOptions
|
|
}
|
|
)}
|
|
>
|
|
{plan.template}
|
|
<Price amount={String(plan.price)} currencyCode="USD" />
|
|
</button>
|
|
</li>
|
|
))}
|
|
</ul>
|
|
);
|
|
};
|
|
|
|
export default WarrantySelector;
|