Skip to content
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

Merged
merged 11 commits into from
Jul 13, 2024
Merged

added Auth react context #91

merged 11 commits into from
Jul 13, 2024

Conversation

NancyAanchal
Copy link
Contributor

Added auth react context as instructed and it works
Fixed a minor error related to fontAwesome in Card.tsx

Copy link

cloudflare-workers-and-pages bot commented Jul 11, 2024

Deploying nepalingo with  Cloudflare Pages  Cloudflare Pages

Latest commit: 775344e
Status: ✅  Deploy successful!
Preview URL: https://12de0173.nepalingo.pages.dev
Branch Preview URL: https://auth-react-context.nepalingo.pages.dev

View logs

Copy link
Member

@christikaes christikaes left a 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

<Route path="/" element={<Navigate to="/login" />} />
</Routes>
</Router>
<UserProvider>
Copy link
Member

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();
Copy link
Member

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",
Copy link
Member

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",
Copy link
Member

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);
Copy link
Member

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!
Copy link
Member

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>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great

Copy link
Member

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

@christikaes christikaes merged commit 66b1eed into main Jul 13, 2024
2 checks passed
@christikaes christikaes deleted the auth-react-context branch July 13, 2024 14:50
@christikaes christikaes mentioned this pull request Jul 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants