Skip to content

πŸ“¨ The ultimate agentic social media scheduling tool πŸ€–

feat(billing): make finishing the trial discoverable

Gilad Resisie092f165155d
diff --git a/apps/frontend/src/components/billing/main.billing.component.tsx b/apps/frontend/src/components/billing/main.billing.component.tsx
index 1e3d4f017..f5984d893 100644
--- a/apps/frontend/src/components/billing/main.billing.component.tsx
+++ b/apps/frontend/src/components/billing/main.billing.component.tsx
@@ -237,6 +237,21 @@ export const MainBillingComponent: FC<{
!!queryParams.get('finishTrial')
);
+ const finishTrialNow = useCallback(async () => {
+ if (
+ await deleteDialog(
+ t(
+ 'finish_trial_confirmation',
+ 'Finishing the trial will charge your plan immediately, are you sure?'
+ ),
+ t('finish_trial_charge_me_now', 'Finish the trial, charge me now'),
+ t('trial', 'Trial')
+ )
+ ) {
+ setFinishTrial(true);
+ }
+ }, []);
+
const [subscription, setSubscription] = useState<SubscriptionWithPlatform | undefined>(
sub
);
@@ -495,7 +510,14 @@ export const MainBillingComponent: FC<{
</div>
</div>
- {finishTrial && <FinishTrial close={() => setFinishTrial(false)} />}
+ {finishTrial && (
+ <FinishTrial
+ close={() => {
+ setFinishTrial(false);
+ mutate('/user/self');
+ }}
+ />
+ )}
<div className="flex gap-[16px] [@media(max-width:1024px)]:flex-col [@media(max-width:1024px)]:text-center">
{Object.entries(pricing)
.filter((f) => !isGeneral || f[0] !== 'FREE')
@@ -590,6 +612,11 @@ export const MainBillingComponent: FC<{
'Update Payment Method / Invoices History'
)}
</Button>
+ {user?.isTrailing && (
+ <Button onClick={finishTrialNow}>
+ {t('finish_trial', 'Finish trial')}
+ </Button>
+ )}
{isGeneral && !subscription?.cancelAt && (
<Button
className="bg-red-500"
diff --git a/libraries/nestjs-libraries/src/database/prisma/clipping/clipping.service.ts b/libraries/nestjs-libraries/src/database/prisma/clipping/clipping.service.ts
index 60c517482..e08be3835 100644
--- a/libraries/nestjs-libraries/src/database/prisma/clipping/clipping.service.ts
+++ b/libraries/nestjs-libraries/src/database/prisma/clipping/clipping.service.ts
@@ -191,7 +191,10 @@ export class ClippingService {
}
if (org.isTrailing) {
- throw new HttpException('Clipping is not available in trial mode', 406);
+ throw new HttpException(
+ `Clipping is not available in trial mode. To use it now, open ${process.env.FRONTEND_URL}/billing and click "Finish trial" (this charges the plan immediately)`,
+ 406
+ );
}
if ((await this.balance(org.id)) <= 0) {
diff --git a/libraries/nestjs-libraries/src/database/prisma/media/media.service.ts b/libraries/nestjs-libraries/src/database/prisma/media/media.service.ts
index bdeaf1f8d..331b93f6d 100644
--- a/libraries/nestjs-libraries/src/database/prisma/media/media.service.ts
+++ b/libraries/nestjs-libraries/src/database/prisma/media/media.service.ts
@@ -477,7 +477,10 @@ export class MediaService {
}
if (!video.trial && org.isTrailing) {
- throw new HttpException('This video is not available in trial mode', 406);
+ throw new HttpException(
+ `This video is not available in trial mode. To use it now, open ${process.env.FRONTEND_URL}/billing and click "Finish trial" (this charges the plan immediately)`,
+ 406
+ );
}
return true;
@@ -502,7 +505,10 @@ export class MediaService {
}
if (!video.trial && org.isTrailing) {
- throw new HttpException('This video is not available in trial mode', 406);
+ throw new HttpException(
+ `This video is not available in trial mode. To use it now, open ${process.env.FRONTEND_URL}/billing and click "Finish trial" (this charges the plan immediately)`,
+ 406
+ );
}
await video.instance.processAndValidate(body.customParams);
diff --git a/libraries/react-shared-libraries/src/translation/locales/en/translation.json b/libraries/react-shared-libraries/src/translation/locales/en/translation.json
index 06d4971c1..2341246e0 100644
--- a/libraries/react-shared-libraries/src/translation/locales/en/translation.json
+++ b/libraries/react-shared-libraries/src/translation/locales/en/translation.json
@@ -770,5 +770,9 @@
"republish_the_post": "Republish the post",
"post_already_published_republish_warning": "This post was already published. Republishing will publish it again to",
"republish_at": "at",
- "republish_recurring_note": "This is a recurring post: your changes apply to all future recurrences starting now."
+ "republish_recurring_note": "This is a recurring post: your changes apply to all future recurrences starting now.",
+ "finish_trial": "Finish trial",
+ "finish_trial_confirmation": "Finishing the trial will charge your plan immediately, are you sure?",
+ "finish_trial_charge_me_now": "Finish the trial, charge me now",
+ "trial": "Trial"
}