Skip to content

Open-source social media scheduler built for AI agents and the teams behind them. Create, schedule and publish posts to every network through MCP or the REST API, or write them yourself in a composer your team will love.

fix: yearly billing interval display in UpgradeDialog and Billing page

Paulo Castellanodad4ab21c316
diff --git a/app/Http/Middleware/App/HandleInertiaRequests.php b/app/Http/Middleware/App/HandleInertiaRequests.php
index 1ffcb50f6..f17aa60e0 100644
--- a/app/Http/Middleware/App/HandleInertiaRequests.php
+++ b/app/Http/Middleware/App/HandleInertiaRequests.php
@@ -8,7 +8,6 @@ use App\Http\Resources\App\HandleInertiaRequests\AuthAccountResource;
use App\Http\Resources\App\HandleInertiaRequests\AuthPlanResource;
use App\Http\Resources\App\HandleInertiaRequests\AuthUserResource;
use App\Http\Resources\App\HandleInertiaRequests\AuthWorkspaceResource;
-use App\Models\Account;
use App\Models\Plan;
use Illuminate\Http\Request;
use Inertia\Middleware;
@@ -45,7 +44,6 @@ class HandleInertiaRequests extends Middleware
'account' => $account ? AuthAccountResource::make($account) : null,
'plan' => $account && $account->plan ? AuthPlanResource::make($account, $account->plan) : null,
'hasActiveSubscription' => $account ? $account->hasActiveSubscription() : false,
- 'currentPriceId' => $account?->subscription(Account::SUBSCRIPTION_NAME)?->stripe_price,
],
'usage' => $account && ! $isSelfHosted ? $account->usage() : null,
'features' => $account && ! $isSelfHosted ? $account->featureLimits() : null,
diff --git a/resources/js/components/UpgradeDialog.vue b/resources/js/components/UpgradeDialog.vue
index e5ca83f4b..b23dc1a8e 100644
--- a/resources/js/components/UpgradeDialog.vue
+++ b/resources/js/components/UpgradeDialog.vue
@@ -9,6 +9,7 @@ import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '@/comp
import { useFeatureAccess } from '@/composables/useFeatureAccess';
import { useUpgradeDialog } from '@/composables/useUpgradeDialog';
import { checkout, swap } from '@/routes/app/billing';
+import type { AuthPlan } from '@/types';
type PlanSlug = 'starter' | 'plus' | 'pro' | 'max';
@@ -34,21 +35,17 @@ const { usage } = useFeatureAccess();
const page = usePage();
const plans = computed<Plan[]>(() => (page.props.plans as Plan[]) ?? []);
-const currentPlan = computed<Plan | null>(() => (page.props.auth as { plan: Plan | null }).plan ?? null);
-const currentPriceId = computed<string | null>(() => (page.props.auth as { currentPriceId?: string | null }).currentPriceId ?? null);
+const currentPlan = computed<AuthPlan | null>(() => (page.props.auth as { plan: AuthPlan | null }).plan ?? null);
const hasActiveSubscription = computed<boolean>(() => Boolean((page.props.auth as { hasActiveSubscription?: boolean }).hasActiveSubscription));
-const isOnYearly = computed(() => {
- if (!currentPriceId.value || !currentPlan.value) return false;
- return currentPriceId.value === currentPlan.value.stripe_yearly_price_id;
-});
+const isOnYearly = computed(() => currentPlan.value?.interval === 'yearly');
-const isYearly = ref(false);
+const isYearly = ref(true);
const processing = ref<string | null>(null);
watch(open, (isOpen) => {
if (isOpen) {
- isYearly.value = isOnYearly.value;
+ isYearly.value = true;
}
});
@@ -175,8 +172,8 @@ const onOpenChange = (value: boolean) => {
</DialogDescription>
</div>
- <!-- Billing toggle pill (hidden when user is already on yearly) -->
- <div v-if="!isOnYearly" class="flex justify-center pt-6 pb-2">
+ <!-- Billing toggle pill -->
+ <div class="flex justify-center pt-6 pb-2">
<div class="relative">
<div
class="inline-flex items-center gap-1 rounded-full border-2 border-foreground bg-card p-1 shadow-xs"
diff --git a/resources/js/pages/settings/account/Billing.vue b/resources/js/pages/settings/account/Billing.vue
index be99570f5..2ef8b59e5 100644
--- a/resources/js/pages/settings/account/Billing.vue
+++ b/resources/js/pages/settings/account/Billing.vue
@@ -1,5 +1,5 @@
<script setup lang="ts">
-import { Head } from '@inertiajs/vue3';
+import { Head, usePage } from '@inertiajs/vue3';
import { IconCreditCard, IconDownload, IconFileText, IconSparkles } from '@tabler/icons-vue';
import { trans } from 'laravel-vue-i18n';
import { computed } from 'vue';
@@ -16,6 +16,7 @@ import { settings as settingsHub } from '@/routes/app';
import { edit as accountEdit } from '@/routes/app/account';
import { index as billingIndex, portal } from '@/routes/app/billing';
import { index as usageIndex } from '@/routes/app/usage';
+import type { AuthPlan } from '@/types';
interface Plan {
name: string;
@@ -59,9 +60,14 @@ const tabs = computed(() => [
{ name: 'billing', label: trans('settings.account.tabs.billing'), href: billingIndex().url },
]);
-const monthlyPrice = (slug: string | undefined): string => {
+const page = usePage();
+const authPlan = computed<AuthPlan | null>(() => (page.props.auth as { plan: AuthPlan | null }).plan ?? null);
+const isYearly = computed(() => authPlan.value?.interval === 'yearly');
+
+const displayPrice = (slug: string | undefined): string => {
if (! slug) return 'Free';
- return trans(`billing.subscribe.prices.${slug}.monthly`);
+ const key = isYearly.value ? 'yearly_per_month' : 'monthly';
+ return trans(`billing.subscribe.prices.${slug}.${key}`);
};
const { openUpgrade } = useUpgradeDialog();
@@ -106,9 +112,12 @@ const { openUpgrade } = useUpgradeDialog();
<Badge v-else-if="subscription?.ends_at" variant="secondary">{{ $t('billing.plan.cancelling') }}</Badge>
</div>
<p class="text-base text-foreground/70">
- <span class="text-2xl font-bold tabular-nums text-foreground">{{ monthlyPrice(plan?.slug) }}</span>
+ <span class="text-2xl font-bold tabular-nums text-foreground">{{ displayPrice(plan?.slug) }}</span>
<span class="ml-1">/{{ $t('billing.plan.month') }}</span>
</p>
+ <p v-if="plan" class="text-xs font-medium text-foreground/60">
+ {{ isYearly ? $t('billing.subscribe.billed_yearly') : $t('billing.subscribe.billed_monthly') }}
+ </p>
<p
v-if="onTrial && trialEndsAt"
class="text-sm font-semibold text-foreground/70"
diff --git a/resources/js/types/index.d.ts b/resources/js/types/index.d.ts
index 483026bc2..6e6a81168 100644
--- a/resources/js/types/index.d.ts
+++ b/resources/js/types/index.d.ts
@@ -32,7 +32,6 @@ export interface Auth {
account: AuthAccount | null;
plan: AuthPlan | null;
hasActiveSubscription: boolean;
- currentPriceId: string | null;
}
export interface Usage {