- Implemented `createTrialSubscription` action in the API for initiating trial subscriptions. - Enhanced the Pro page to include a `TryFreeButton` for users to activate their trial. - Updated GraphQL operations and types to support trial subscription features. - Improved subscription messaging and user experience across relevant components.
29 lines
1.1 KiB
TypeScript
29 lines
1.1 KiB
TypeScript
'use client';
|
|
import { useCreateTrialSubscriptionMutation } from '@/hooks/api/subscriptions';
|
|
import { Button } from '@repo/ui/components/ui/button';
|
|
import { Sparkles } from 'lucide-react';
|
|
import { useRouter } from 'next/navigation';
|
|
import { type ComponentProps } from 'react';
|
|
|
|
export function TryFreeButton({ className = '', size = 'lg' }: ComponentProps<typeof Button>) {
|
|
const router = useRouter();
|
|
const { isPending, mutateAsync: createTrialSubscription } = useCreateTrialSubscriptionMutation();
|
|
|
|
const handleTryFree = async () => {
|
|
await createTrialSubscription();
|
|
router.refresh();
|
|
};
|
|
|
|
return (
|
|
<Button
|
|
className={`w-full bg-gradient-to-r from-purple-600 to-blue-600 px-8 py-3 text-base font-semibold text-white shadow-lg transition-all duration-200 hover:from-purple-700 hover:to-blue-700 hover:shadow-xl sm:w-auto ${className}`}
|
|
disabled={isPending}
|
|
onClick={handleTryFree}
|
|
size={size}
|
|
>
|
|
<Sparkles className="mr-2 size-5" />
|
|
{isPending ? 'Активация...' : 'Попробовать бесплатно'}
|
|
</Button>
|
|
);
|
|
}
|