Files
myeasycms-v2/apps/web/app/(marketing)/_components/site-header-account-section.tsx
giancarlo 5b837d2fa8 Update UI style and enhance billing services
Several changes have been made in this commit. Firstly, updates have been made to the site-header-account-section and the pricing-table components to enhance UI aesthetics. Secondly, billing services have been significantly improved. A new method for retrieving plan information by an ID has been introduced. This method is available for all strategy services, including Stripe and Lemon-Squeezy. Furthermore, the way context and logging are handled during the billing process has been streamlined for better readability and efficiency.
2024-04-11 10:29:52 +08:00

79 lines
1.9 KiB
TypeScript

'use client';
import Link from 'next/link';
import type { User } from '@supabase/supabase-js';
import { ChevronRight } from 'lucide-react';
import { PersonalAccountDropdown } from '@kit/accounts/personal-account-dropdown';
import { useSignOut } from '@kit/supabase/hooks/use-sign-out';
import { useUser } from '@kit/supabase/hooks/use-user';
import { Button } from '@kit/ui/button';
import { ModeToggle } from '@kit/ui/mode-toggle';
import { Trans } from '@kit/ui/trans';
import featuresFlagConfig from '~/config/feature-flags.config';
import pathsConfig from '~/config/paths.config';
const paths = {
home: pathsConfig.app.home,
};
const features = {
enableThemeToggle: featuresFlagConfig.enableThemeToggle,
};
export function SiteHeaderAccountSection({
user,
}: React.PropsWithChildren<{
user: User | null;
}>) {
if (!user) {
return <AuthButtons />;
}
return <SuspendedPersonalAccountDropdown user={user} />;
}
function SuspendedPersonalAccountDropdown(props: { user: User | null }) {
const signOut = useSignOut();
const user = useUser(props.user);
if (user.data) {
return (
<PersonalAccountDropdown
paths={paths}
features={features}
user={user.data}
signOutRequested={() => signOut.mutateAsync()}
/>
);
}
return <AuthButtons />;
}
function AuthButtons() {
return (
<div className={'flex space-x-0.5'}>
<div className={'hidden space-x-0.5 md:flex'}>
<ModeToggle />
<Link href={pathsConfig.auth.signIn}>
<Button className={'rounded-full'} variant={'ghost'}>
<Trans i18nKey={'auth:signIn'} />
</Button>
</Link>
</div>
<Link href={pathsConfig.auth.signUp}>
<Button className={'rounded-full'}>
<Trans i18nKey={'auth:getStarted'} />
<ChevronRight className={'h-4'} />
</Button>
</Link>
</div>
);
}