mirror of
https://github.com/yusufipk/OpenFrame.git
synced 2026-09-11 09:36:08 +00:00
Add a "Cancel subscription" button beside "Manage Subscription" in Settings. It opens a dialog with one optional question (five answers, no default, a note box under the two that want detail), then schedules the Stripe subscription to end at the close of the current period without a trip to the portal. The answer is stored in a new subscription_cancellations table and shown, with an all-time tally, on the admin dashboard; the category is also mirrored onto Stripe's cancellation feedback, the free text stays local. The cancel route claims the local cancel flag with a conditional update before calling Stripe, so two racing requests cannot both write a reason row, and hands the claim back when Stripe refuses. A subscription Stripe no longer knows answers 409 with a pointer to the portal instead of a 500. The route carries an account-keyed rate limit on top of the shared IP one. Two fixes found on the way: the pinned Stripe API version reports current_period_end on the subscription item rather than the subscription, so the sync stored null for every period end; a shared helper now reads the item first. And the RadioGroup styles targeted a data-checked attribute radix never writes, so the checked state was invisible in the light theme.
46 lines
1.7 KiB
TypeScript
46 lines
1.7 KiB
TypeScript
'use client';
|
|
|
|
import * as React from 'react';
|
|
import { RadioGroup as RadioGroupPrimitive } from 'radix-ui';
|
|
|
|
import { cn } from '@/lib/utils';
|
|
import { CircleIcon } from 'lucide-react';
|
|
|
|
function RadioGroup({
|
|
className,
|
|
...props
|
|
}: React.ComponentProps<typeof RadioGroupPrimitive.Root>) {
|
|
return (
|
|
<RadioGroupPrimitive.Root
|
|
data-slot="radio-group"
|
|
className={cn('grid gap-2 w-full', className)}
|
|
{...props}
|
|
/>
|
|
);
|
|
}
|
|
|
|
function RadioGroupItem({
|
|
className,
|
|
...props
|
|
}: React.ComponentProps<typeof RadioGroupPrimitive.Item>) {
|
|
return (
|
|
<RadioGroupPrimitive.Item
|
|
data-slot="radio-group-item"
|
|
className={cn(
|
|
'border-input text-primary dark:bg-input/30 focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:aria-invalid:border-destructive/50 data-[state=checked]:bg-primary data-[state=checked]:border-primary flex size-4 rounded-full focus-visible:ring-1 aria-invalid:ring-1 group/radio-group-item peer relative aspect-square shrink-0 border outline-none after:absolute after:-inset-x-3 after:-inset-y-2 disabled:cursor-not-allowed disabled:opacity-50',
|
|
className
|
|
)}
|
|
{...props}
|
|
>
|
|
<RadioGroupPrimitive.Indicator
|
|
data-slot="radio-group-indicator"
|
|
className="group-aria-invalid/radio-group-item:text-destructive flex size-4 items-center justify-center text-white"
|
|
>
|
|
<CircleIcon className="absolute top-1/2 left-1/2 size-2 -translate-x-1/2 -translate-y-1/2 fill-current" />
|
|
</RadioGroupPrimitive.Indicator>
|
|
</RadioGroupPrimitive.Item>
|
|
);
|
|
}
|
|
|
|
export { RadioGroup, RadioGroupItem };
|