Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import { Button } from '@mui/material';
  2. import { getSession, signOut, useSession } from 'next-auth/react';
  3. import ProfileContent from '../../components/profile-content/ProfileContent';
  4. import { LOGIN_PAGE } from '../../constants/pages';
  5. const ProfilePage = () => {
  6. const { data: session } = useSession();
  7. console.log(session);
  8. function logoutHandler() {
  9. signOut();
  10. }
  11. return (
  12. <>
  13. <ProfileContent></ProfileContent>
  14. <Button color="inherit" onClick={logoutHandler}>
  15. Logout
  16. </Button>
  17. </>
  18. );
  19. };
  20. export async function getServerSideProps(context) {
  21. const session = await getSession({ req: context.req });
  22. if (!session) {
  23. return {
  24. redirect: {
  25. destination: LOGIN_PAGE,
  26. permanent: false,
  27. },
  28. };
  29. }
  30. return {
  31. props: { session },
  32. };
  33. }
  34. export default ProfilePage;