fix: add dashboard header border on scroll

This commit is contained in:
Mythie
2023-09-14 12:51:59 +10:00
parent b255eb21e5
commit f8534b2c3d
2 changed files with 23 additions and 8 deletions

View File

@ -21,16 +21,18 @@ export default async function BillingSettingsPage() {
redirect('/settings/profile'); redirect('/settings/profile');
} }
let subscription = await getSubscriptionByUserId({ userId: user.id }); const subscription = await getSubscriptionByUserId({ userId: user.id }).then(async (sub) => {
if (sub) {
return sub;
}
// If we don't have a customer record, create one as well as an empty subscription. // If we don't have a customer record, create one as well as an empty subscription.
if (!subscription?.customerId) { return createCustomer({ user });
subscription = await createCustomer({ user }); });
}
let billingPortalUrl = ''; let billingPortalUrl = '';
if (subscription?.customerId) { if (subscription.customerId) {
billingPortalUrl = await getPortalSession({ billingPortalUrl = await getPortalSession({
customerId: subscription.customerId, customerId: subscription.customerId,
returnUrl: `${process.env.NEXT_PUBLIC_SITE_URL}/settings/billing`, returnUrl: `${process.env.NEXT_PUBLIC_SITE_URL}/settings/billing`,

View File

@ -1,6 +1,6 @@
'use client'; 'use client';
import { HTMLAttributes } from 'react'; import { HTMLAttributes, useEffect, useState } from 'react';
import Link from 'next/link'; import Link from 'next/link';
@ -17,10 +17,23 @@ export type HeaderProps = HTMLAttributes<HTMLDivElement> & {
}; };
export const Header = ({ className, user, ...props }: HeaderProps) => { export const Header = ({ className, user, ...props }: HeaderProps) => {
const [scrollY, setScrollY] = useState(0);
useEffect(() => {
const onScroll = () => {
setScrollY(window.scrollY);
};
window.addEventListener('scroll', onScroll);
return () => window.removeEventListener('scroll', onScroll);
}, []);
return ( return (
<header <header
className={cn( className={cn(
'supports-backdrop-blur:bg-background/60 bg-background/95 sticky top-0 z-50 flex h-16 w-full items-center border-b backdrop-blur', 'supports-backdrop-blur:bg-background/60 bg-background/95 sticky top-0 z-50 flex h-16 w-full items-center border-b border-b-transparent backdrop-blur duration-200',
scrollY > 5 && 'border-b-border',
className, className,
)} )}
{...props} {...props}