Skip to content

Commit

Permalink
fix: css messed up after return to dashboard from interview route
Browse files Browse the repository at this point in the history
app router by default uses soft navigation. we want to force hard navigation here using window.location.href on navigation from /interview to /dashboard so that the styles will reload. this fixes bug where interview styles were being applied to /dashboard
  • Loading branch information
buckhalt committed Dec 20, 2023
1 parent cb24ff7 commit 0268dae
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions components/Banner/BannerContent.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
'use client';

import { LogOut } from 'lucide-react';
import Link from 'next/link';
import { Button } from '~/components/ui/Button';
import { useSession } from '~/providers/SessionProvider';
import FeedbackBanner from './FeedbackBanner';
Expand All @@ -15,6 +14,11 @@ const BannerContent = () => {
const [openSignOutModal, setOpenSignOutModal] = useState(false);
const pathname = usePathname();

const returnToDashboard = () => {
// hard redirect to dashboard to avoid issues with stale styling from interviewer
window.location.href = '/dashboard';
};

if (session && pathname.startsWith('/interview/')) {
return (
<>
Expand All @@ -23,17 +27,16 @@ const BannerContent = () => {
setOpenSignOutModal={setOpenSignOutModal}
/>
<div className="flex w-full items-center justify-between px-4">
<Link href="/dashboard">
<Button
className="rounded-full"
variant="default"
color="primary"
size="sm"
>
Return to Dashboard{' '}
<LogOut className="ml-2" size={16} strokeWidth={3} />
</Button>
</Link>
<Button
className="rounded-full"
variant="default"
color="primary"
size="sm"
onClick={returnToDashboard}
>
Return to Dashboard{' '}
<LogOut className="ml-2" size={16} strokeWidth={3} />
</Button>
<FeedbackBanner />
<CloseButton onClick={() => setOpenSignOutModal(true)} />
</div>
Expand Down

0 comments on commit 0268dae

Please sign in to comment.