-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
added Auth react context #91
Conversation
Deploying nepalingo with Cloudflare Pages
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had a few comments but I think it might be because this diff is weird... let's merge it and if the issue is still there we'll figure it out again seperately
nepalingo-web/src/App.tsx
Outdated
<Route path="/" element={<Navigate to="/login" />} /> | ||
</Routes> | ||
</Router> | ||
<UserProvider> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome!!
// Cleanup subscription on component unmount | ||
return () => subscription.unsubscribe(); | ||
}, []); | ||
const { user } = useAuth(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yessss!! This code looks much cleaner now!
@@ -17,6 +17,7 @@ | |||
"react-dom": "^18.3.1", | |||
"react-ga4": "^2.1.0", | |||
"react-router-dom": "^6.24.1", | |||
"react-supabase": "^0.2.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you still using react-supabase? You can run pnpm remove react-supabase
to get rid of it if you don't need it anymore
https://chatgpt.com/share/04fc4457-0e8f-40f1-b135-e59fe0c94d16
@@ -37,6 +38,7 @@ | |||
"ts-node": "^10.9.2", | |||
"typescript": "^5.5.2", | |||
"vite": "^5.3.1", | |||
"vite-plugin-string": "^1.2.3", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
did you add this? what is it for?
|
||
export const AuthProvider = ({ children }: { children: ReactNode }) => { | ||
const [user, setUser] = useState<User | null>(null); | ||
const [, setIsAuthenticated] = useState(false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you don't need isAuthenticated anymore - you can get rid of this. Since you can figure out whether the user is authenticated from the user data
|
||
return ( | ||
<div className="flex flex-col items-center justify-between h-screen bg-gradient-to-r from-black via-gray-800 to-black text-white p-10"> | ||
<div className="mt-10"> | ||
<h1 className="text-5xl font-bold text-center"> | ||
Hello {username}, welcome to Nepalingo! | ||
Hello {user?.user_metadata?.username}, welcome to Nepalingo! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yesss!!! nice!
<App /> | ||
</React.StrictMode>, | ||
) | ||
<AuthProvider> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm something is wierd about this PR stil... I guess we'll merge it and then before you start the next ticket pull a fresh one from main
Added auth react context as instructed and it works
Fixed a minor error related to fontAwesome in Card.tsx