trypost/resources/js/components/UserMenuContent.vue
Paulo Castellano ded1c998ec feat: redesign billing, onboarding, sidebar, and settings architecture
- Sidebar reorganized: Workspace group (connections, hashtags, labels,
  API keys, settings) and Account group (settings, usage, billing)
- Account group only visible to owner and hidden in self-hosted mode
- Onboarding simplified: role -> account (connect socials) -> completed
  -> redirect to /subscribe. Removed Subscription setup step.
- Subscribe page redesigned with 4 plan cards, monthly/yearly toggle,
  trial info, and per-plan features list
- Billing page redesigned following Sendkit layout (sections with
  sidebar labels)
- Processing page uses usePoll with immediate watch for subscription
  activation
- Cancel URL redirects directly to /subscribe
- Account settings page with name and billing_email (syncs with Stripe)
- Usage page with ring meters for all plan limits
- Settings layout tabs only for user pages (profile, password,
  notifications). Workspace/API keys/billing are standalone pages.
- GoogleAuthButton extracted as reusable component
- WorkspaceRole TypeScript enum for type-safe role checks in frontend
- Trial period changed to 7 days
- Fixed onboarding loop when user confirms email
- All 1101 tests passing
2026-04-15 00:33:38 -03:00

159 lines
5.5 KiB
Vue

<script setup lang="ts">
import { Link, router, usePage } from '@inertiajs/vue3';
import {
IconBrightnessUp,
IconDeviceDesktop,
IconLanguage,
IconLogout,
IconMoon,
IconUser,
} from '@tabler/icons-vue';
import { loadLanguageAsync } from 'laravel-vue-i18n';
import { computed } from 'vue';
import { updateLanguage } from '@/actions/App/Http/Controllers/App/Settings/ProfileController';
import {
DropdownMenuGroup,
DropdownMenuItem,
DropdownMenuLabel,
DropdownMenuPortal,
DropdownMenuSeparator,
DropdownMenuSub,
DropdownMenuSubContent,
DropdownMenuSubTrigger,
} from '@/components/ui/dropdown-menu';
import UserInfo from '@/components/UserInfo.vue';
import { useAppearance } from '@/composables/useAppearance';
import dayjs from '@/dayjs';
import { logout } from '@/routes';
import { edit } from '@/routes/app/profile';
import type { User } from '@/types';
interface Language {
code: string;
name: string;
}
type Props = {
user: User;
};
defineProps<Props>();
const page = usePage();
const languages = computed<Language[]>(() => page.props.languages as Language[]);
const currentLanguage = computed(() => languages.value?.find((l: Language) => l.code === page.props.locale));
const { appearance, updateAppearance } = useAppearance();
const switchLanguage = (code: string) => {
const previousCode = currentLanguage.value?.code || 'en';
loadLanguageAsync(code);
dayjs.locale(code.toLowerCase());
router.put(updateLanguage.url(), { locale: code }, {
preserveScroll: true,
preserveState: false,
onError: () => {
loadLanguageAsync(previousCode);
dayjs.locale(previousCode.toLowerCase());
},
});
};
const handleLogout = () => {
router.flushAll();
};
</script>
<template>
<DropdownMenuLabel class="p-0 font-normal">
<div class="flex items-center gap-2 px-1 py-1.5 text-left text-sm">
<UserInfo
:user="user"
:show-email="true"
fallback-class="bg-neutral-200 text-neutral-600 dark:bg-neutral-700 dark:text-neutral-200"
/>
</div>
</DropdownMenuLabel>
<DropdownMenuSeparator />
<DropdownMenuGroup>
<DropdownMenuItem :as-child="true">
<Link class="block w-full cursor-pointer" :href="edit()" prefetch>
<IconUser class="size-4" />
{{ $t('sidebar.profile') }}
</Link>
</DropdownMenuItem>
</DropdownMenuGroup>
<DropdownMenuSeparator />
<DropdownMenuGroup>
<DropdownMenuSub>
<DropdownMenuSubTrigger class="gap-2">
<IconBrightnessUp
v-if="appearance === 'light'"
class="size-4 text-muted-foreground"
/>
<IconMoon
v-else-if="appearance === 'dark'"
class="size-4 text-muted-foreground"
/>
<IconDeviceDesktop
v-else
class="size-4 text-muted-foreground"
/>
{{ $t('sidebar.theme', { name: appearance === 'light' ? $t('sidebar.theme_light') : appearance === 'dark' ? $t('sidebar.theme_dark') : $t('sidebar.theme_system') }) }}
</DropdownMenuSubTrigger>
<DropdownMenuPortal>
<DropdownMenuSubContent>
<DropdownMenuItem @click="updateAppearance('light')">
<IconBrightnessUp class="size-4" />
{{ $t('sidebar.theme_light') }}
</DropdownMenuItem>
<DropdownMenuItem @click="updateAppearance('dark')">
<IconMoon class="size-4" />
{{ $t('sidebar.theme_dark') }}
</DropdownMenuItem>
<DropdownMenuItem @click="updateAppearance('system')">
<IconDeviceDesktop class="size-4" />
{{ $t('sidebar.theme_system') }}
</DropdownMenuItem>
</DropdownMenuSubContent>
</DropdownMenuPortal>
</DropdownMenuSub>
</DropdownMenuGroup>
<DropdownMenuSeparator />
<DropdownMenuGroup>
<DropdownMenuSub v-if="languages && languages.length > 1">
<DropdownMenuSubTrigger class="gap-2">
<IconLanguage class="size-4 text-muted-foreground" />
{{ $t('sidebar.language', { name: currentLanguage?.name ?? 'English' }) }}
</DropdownMenuSubTrigger>
<DropdownMenuPortal>
<DropdownMenuSubContent>
<DropdownMenuItem
v-for="language in languages"
:key="language.code"
:class="language.code === currentLanguage?.code ? 'bg-accent' : ''"
@click="switchLanguage(language.code)"
>
{{ language.name }}
</DropdownMenuItem>
</DropdownMenuSubContent>
</DropdownMenuPortal>
</DropdownMenuSub>
</DropdownMenuGroup>
<DropdownMenuSeparator />
<DropdownMenuItem :as-child="true">
<Link
class="block w-full cursor-pointer"
:href="logout()"
@click="handleLogout"
as="button"
data-test="logout-button"
>
<IconLogout class="size-4" />
{{ $t('sidebar.log_out') }}
</Link>
</DropdownMenuItem>
</template>