File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -113,7 +113,7 @@ export default async function Page({
113113
114114 const accountLocked = ! ! profile . BannedUsers ;
115115 const session = await getServerAuthSession ( ) ;
116- const isOwner = session ?. user ?. username === username ;
116+ const isOwner = session ?. user ?. id === profile . id ;
117117
118118 type MakeOptional < Type , Key extends keyof Type > = Omit < Type , Key > &
119119 Partial < Type > ;
Original file line number Diff line number Diff line change @@ -8,6 +8,9 @@ import AuthProvider from "@/context/AuthProvider";
88import ProgressBar from "@/components/ProgressBar/ProgressBar" ;
99import React from "react" ;
1010import { PromptProvider } from "@/components/PromptService" ;
11+ import { db } from "@/server/db" ;
12+ import { eq } from "drizzle-orm" ;
13+ import { user } from "@/server/db/schema" ;
1114
1215export const metadata = {
1316 title : "Codú - Join Our Web Developer Community" ,
@@ -67,6 +70,12 @@ export default async function RootLayout({
6770 children : React . ReactNode ;
6871} ) {
6972 const session = await getServerAuthSession ( ) ;
73+ const userData = session ?. user ?. id
74+ ? await db . query . user . findFirst ( {
75+ where : eq ( user . id , session . user . id ) ,
76+ columns : { username : true } ,
77+ } )
78+ : null ;
7079
7180 return (
7281 < >
@@ -78,6 +87,7 @@ export default async function RootLayout({
7887 < Nav
7988 session = { session }
8089 algoliaSearchConfig = { algoliaSearchConfig }
90+ username = { userData ?. username || null }
8191 />
8292 { children }
8393 < Footer />
Original file line number Diff line number Diff line change @@ -64,7 +64,7 @@ const SavedPosts = () => {
6464 excerpt = { excerpt }
6565 name = { name }
6666 image = { image }
67- date = { updatedAt . toISOString ( ) }
67+ date = { new Date ( updatedAt ) . toISOString ( ) }
6868 readTime = { readTimeMins }
6969 showBookmark = { false }
7070 menuOptions = { [
Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ import { type UserNavigationItem } from "@/types/types";
22import { Disclosure , Transition } from "@headlessui/react" ;
33import { type Session } from "next-auth" ;
44import { PromptLink as Link } from "../PromptService/PromptLink" ;
5- import { MutableRefObject , useRef , type FunctionComponent } from "react" ;
5+ import { type MutableRefObject , useRef , type FunctionComponent } from "react" ;
66import { navigation , subNav , userSubNav } from "../../config/site_settings" ;
77
88function classNames ( ...classes : string [ ] ) {
@@ -12,12 +12,7 @@ function classNames(...classes: string[]) {
1212interface MobileNavProps {
1313 session : Session | null ;
1414 userNavigation : UserNavigationItem [ ] ;
15- close ?: (
16- focusableElement ?:
17- | HTMLElement
18- | MutableRefObject < HTMLElement | null >
19- | undefined ,
20- ) => void ;
15+ close ?: ( ) => void ;
2116}
2217
2318const MobileNav : FunctionComponent < MobileNavProps > = ( {
Original file line number Diff line number Diff line change @@ -22,9 +22,11 @@ type AlgoliaConfig = {
2222const Nav = ( {
2323 session,
2424 algoliaSearchConfig,
25+ username,
2526} : {
2627 session : Session | null ;
2728 algoliaSearchConfig : AlgoliaConfig ;
29+ username : string | null ;
2830} ) => {
2931 const { data : count } = api . notification . getCount . useQuery ( undefined , {
3032 enabled : session ? true : false ,
@@ -33,7 +35,7 @@ const Nav = ({
3335 const userNavigation = [
3436 {
3537 name : "Your Profile" ,
36- href : `/${ ( session && session . user ?. username ) || "settings" } ` ,
38+ href : `/${ username || "settings" } ` ,
3739 } ,
3840 {
3941 name : "Saved posts" ,
Original file line number Diff line number Diff line change @@ -54,10 +54,6 @@ export const authOptions: NextAuthOptions = {
5454 async session ( { session, user } ) {
5555 if ( session . user ) {
5656 session . user . id = user . id ;
57- if ( user . username ) {
58- session . user . username = user . username ;
59- session . user . role = user . role ;
60- }
6157 }
6258 return session ;
6359 } ,
You can’t perform that action at this time.
0 commit comments