Skip to content

Commit

Permalink
feat: loading screen complete
Browse files Browse the repository at this point in the history
  • Loading branch information
RupaakSrinivas committed Dec 31, 2023
1 parent f367cb4 commit 6c7cece
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 20 deletions.
4 changes: 2 additions & 2 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const App: React.FC = () => {
const { initializeFromLocalStorge, login, isLoggedIn, name } = useAuthStore();
const { showProfile } = useShowProfileStore();
const { isLoading } = useLoadingStore();

const uuid = localStorage.getItem("uuid") || "";
useEffect(() => {
const auth = getAuth();
onAuthStateChanged(auth, (user1) => {
Expand Down Expand Up @@ -65,7 +65,7 @@ const App: React.FC = () => {
{
isLoading
? <Loader />
: !isLoggedIn
: uuid === ""
?<LoginPage />
:name === ''
? <Loader />
Expand Down
34 changes: 17 additions & 17 deletions src/components/Auth.tsx
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
/* eslint-disable @typescript-eslint/no-unused-vars */
/* eslint-disable react-hooks/exhaustive-deps */
/* eslint-disable @typescript-eslint/no-explicit-any */
import {
getAuth,
getRedirectResult,
GoogleAuthProvider,
OAuthProvider,
// onAuthStateChanged,
signInWithRedirect,
} from "firebase/auth";
import { getAuth, getRedirectResult, GoogleAuthProvider, OAuthProvider, signInWithRedirect } from "firebase/auth";
import { FaApple } from "react-icons/fa";
import { FcGoogle } from "react-icons/fc";
import { useLoadingStore } from "../store/useLoadingStore";

const Auth = () => {
const auth = getAuth();
const googleProvider = new GoogleAuthProvider();
const appleProvider = new OAuthProvider("apple.com");
const { setLoading } = useLoadingStore();

appleProvider.addScope("email");
appleProvider.addScope("name");
const logIn = (auth: any, provider: any) => {
void signInWithRedirect(auth, provider).then(() => {
setLoading(true);
});
setLoading(true);
void signInWithRedirect(auth, provider)
localStorage.setItem("uuid", "something");
getRedirectResult(auth)
.then((result) => {
if (result !== null) {
localStorage.setItem("uuid", result.user.uid);
}
})
.catch((error) => {
const errorCode = error.code;
const errorMessage = error.message;
const email = error.email;
console.log(errorCode, errorMessage, email);
});
};

return (
Expand Down
2 changes: 1 addition & 1 deletion src/store/authStore.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export const useAuthStore = create<AuthStore>((set) => ({
profile: "",
username: null,
email: "",
name: "loading",
name: "",
token: "",
timetable: {},
regNo: "", // Initialize timetable as an empty object
Expand Down

0 comments on commit 6c7cece

Please sign in to comment.