Skip to content

Commit

Permalink
fix: #142 fix session status 2
Browse files Browse the repository at this point in the history
  • Loading branch information
KartVen committed Dec 3, 2024
1 parent 8d26939 commit c979699
Show file tree
Hide file tree
Showing 12 changed files with 161 additions and 160 deletions.
2 changes: 0 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,3 @@ networks:
volumes:
frontend_vol:
driver: local


116 changes: 75 additions & 41 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,5 @@
"prettier-plugin-tailwindcss": "^0.6.6",
"tailwindcss": "^3.4.1",
"typescript": "^5"
},
"overrides": {
"ajv": "^8.17.1"
}
}
7 changes: 3 additions & 4 deletions src/app/api/logout/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@ export async function GET(req: NextRequest) {
const baseUrl = req.nextUrl.origin;

const headers: HeadersInit = {
'Set-Cookie': [
`${ACCESS_TOKEN_COOKIE}=; Path=/; Max-Age=0;`,
`${REFRESH_TOKEN_COOKIE}=; Path=/; Max-Age=0;`
].join(', ')
'Set-Cookie': [`${ACCESS_TOKEN_COOKIE}=; Path=/; Max-Age=0;`, `${REFRESH_TOKEN_COOKIE}=; Path=/; Max-Age=0;`].join(
', ',
),
};

await AuthService.logout();
Expand Down
43 changes: 22 additions & 21 deletions src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,37 +19,38 @@ const poppins = Poppins({
subsets: ['latin'],
display: 'swap',
variable: '--font-poppins',
weight: ['100', '200', '300', '400', '500', '600', '700', '800', '900'],
weight: ['100', '200', '300', '400', '500', '600', '700', '800', '900']
});

export const metadata: Metadata = {
title: METADATA.TITLE,
description: METADATA.DESCRIPTION,
keywords: METADATA.KEYWORDS,
assets: METADATA.ASSETS,
assets: METADATA.ASSETS
};

export default function RootLayout({ children }: ComponentParentProps) {
return (
<html lang="pl" data-color-mode="single" data-theme="light-default">
<ToastProvider>
<body>
<ThemeInitializer>
<SessionProvider signUri="/auth">
<SidebarProvider>
<div id="container" className="h-auto min-h-fullContent w-full overflow-x-hidden">
<Header />
<Sidebar />
<Main>{children}</Main>
<Footer />
<div id="modal"></div>
</div>
<ToastContainer />
</SidebarProvider>
</SessionProvider>
</ThemeInitializer>
</body>
</ToastProvider>
<ToastProvider>
<body>
<SessionProvider signUri="/auth">
<ThemeInitializer>
<SidebarProvider>
<div id="container" className="h-auto min-h-fullContent w-full overflow-x-hidden">
<Header />
<Sidebar />
<Main>{children}</Main>
<Footer />
<div id="modal"></div>
</div>
<ToastContainer />
</SidebarProvider>
</ThemeInitializer>
</SessionProvider>
</body>
</ToastProvider>
</html>
);
)
;
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ interface NotificationDropDownMenuProps {

export default function NotificationDropDownMenu({ menuClassName }: NotificationDropDownMenuProps) {
return (
<div className={`${menuClassName} w-60 bg-bg px-2 pb-2 pt-1 text-base font-normal text-secondary shadow-md`}>
</div>
<div className={`${menuClassName} w-60 bg-bg px-2 pb-2 pt-1 text-base font-normal text-secondary shadow-md`}></div>
);
}
15 changes: 5 additions & 10 deletions src/components/layout/navbar/right/UserActionBlock.tsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,17 @@
'use client';
import { useSessionContext } from '@/contexts/SessionContext';
import React, { useEffect, useState } from 'react';
import React from 'react';
import { TEXT } from '@/utils/constant';
import { useRouter } from 'next/navigation';
import UserActionBtns from '@/components/layout/navbar/right/UserActionBtns';

export default function UserActionBlock() {
const { session, sessionStatus } = useSessionContext();
const [stateStatus, setStateStatus] = useState(sessionStatus);
const sessionContext = useSessionContext();
const router = useRouter();

useEffect(() => {
setStateStatus(sessionStatus);
}, [sessionStatus]);

return (
<>
{stateStatus === 'UNAUTHENTICATED' && (
{sessionContext.sessionStatus === 'UNAUTHENTICATED' && (
<div className="pr-2">
<button
className="flex h-[2.5rem] cursor-pointer items-center rounded-md bg-primary px-4 py-2 text-sm font-semibold text-textOnPrimary hover:bg-primaryHover"
Expand All @@ -27,7 +22,7 @@ export default function UserActionBlock() {
</div>
)}

{stateStatus === 'AUTHENTICATED' && <UserActionBtns />}
{sessionContext.sessionStatus === 'AUTHENTICATED' && <UserActionBtns />}
</>
);
}
}
18 changes: 8 additions & 10 deletions src/components/materials/add_modal/AddMaterialModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -163,16 +163,14 @@ export default function AddMaterialModal({ isOpen, onClose }: { isOpen: boolean;
return;
}

await MaterialService.publishMaterial(
{
title: data.details!.title,
description: data.details!.description,
link: data.details!.link,
typeId: data.sectionId!,
categoryId: data.categoryId!,
tagsIds: data.details!.tagsIds,
}
);
await MaterialService.publishMaterial({
title: data.details!.title,
description: data.details!.description,
link: data.details!.link,
typeId: data.sectionId!,
categoryId: data.categoryId!,
tagsIds: data.details!.tagsIds,
});

addToast(`Dodano materiał`, 'success', 5000);
handleClose();
Expand Down
Loading

0 comments on commit c979699

Please sign in to comment.