diff --git a/.env b/.env index 681570c..f78f2d6 100644 --- a/.env +++ b/.env @@ -1,7 +1,6 @@ -REACT_APP_API_KEY="AIzaSyAF0pdgtSx3boMRUnIcN3Op0lrySJH_6Ng" -REACT_APP_AOUT_DOMAIN="growthmemory-1ea05.firebaseapp.com" -REACT_APP_PROJECT_ID="growthmemory-1ea05" -REACT_APP_STORAGE_BUCKET="growthmemory-1ea05.appspot.com" -REACT_APP_MESSAGEING_SENDER_ID="1051732433529" -REACT_APP_APP_ID="1:1051732433529:web:7d1d844cf3df322eded2a8" - +REACT_APP_API_KEY="AIzaSyD_HOQiMwjoWg5pSnKb332UCVxE8C_Tl_k" +REACT_APP_AOUT_DOMAIN="growth-memory.firebaseapp.com" +REACT_APP_PROJECT_ID="growth-memory" +REACT_APP_STORAGE_BUCKET="growth-memory.appspot.com" +REACT_APP_MESSAGEING_SENDER_ID="875889764726" +REACT_APP_APP_ID="1:875889764726:web:47ad150f915d82f2beb257" \ No newline at end of file diff --git a/src/pages/CollectPersonalData.jsx b/src/pages/CollectPersonalData.jsx index eeec1dc..fc16a9f 100644 --- a/src/pages/CollectPersonalData.jsx +++ b/src/pages/CollectPersonalData.jsx @@ -1,7 +1,7 @@ import HeaderBox from "../components/common/header/HeaderBox"; import Button from "../components/common/Button"; import Terms from "../components/common/Terms"; -import TermsBox from "../components/collectPersonalData/TermsBox"; +import TermsBox from "../components/CollectPersonalData/TermsBox"; import styled from "styled-components"; import { Context } from "../components/context/context"; import { useContext } from "react"; @@ -9,30 +9,30 @@ import SignUpProvider from "../components/provider/SignUpPovider"; import BackHeader from "../components/common/header/BackHeader"; export default function CollectPersonalData() { - return ( - <> - - - - - 서비스 이용을 위해 - {"약관 동의를 해주세요 :)"} - - - - - - - > - ); + return ( + <> + + + + + 서비스 이용을 위해 + {"약관 동의를 해주세요 :)"} + + + + + + + > + ); } const Section = styled.section` - width: 360px; - height: 500px; - display: flex; - flex-direction: column; - align-items: center; - justify-content: space-between; - /* background-color: aqua; */ + width: 360px; + height: 500px; + display: flex; + flex-direction: column; + align-items: center; + justify-content: space-between; + /* background-color: aqua; */ `; diff --git a/src/pages/Home.jsx b/src/pages/Home.jsx index ba4b814..beb0582 100644 --- a/src/pages/Home.jsx +++ b/src/pages/Home.jsx @@ -10,106 +10,107 @@ import { BiSolidMedal } from "react-icons/bi"; //예비1 import { IoRibbonSharp } from "react-icons/io5"; //예비2 import { SlBadge } from "react-icons/sl"; import Navigation from "../components/common/Navigation"; +import { onSignOut } from "../service/auth"; export default function Home() { - return ( - - - - - - 오늘의 회고를 작성해주세요 - - - - - - 얼마나 꾸준히 했는지 - 살펴보세요 - - - - - - - - - 성과를 확인해보세요 - - - - - - - - ); + return ( + + + + + + 오늘의 회고를 작성해주세요 + + + + + + 얼마나 꾸준히 + 했는지 살펴보세요 + + + + + + + + + 성과를 확인해보세요 + + + + + + + + ); } const Section = styled.section` - width: 100%; - height: 421px; - display: flex; - flex-direction: column; - align-items: center; + width: 100%; + height: 421px; + display: flex; + flex-direction: column; + align-items: center; `; const Btn = styled.button` - margin-bottom: 27px; - width: 311px; - height: 45px; - border: none; - border-radius: 5px; - color: #f9f9f9; - font-size: 14px; - box-shadow: 0px 0px 8px 0px rgba(0, 0, 0, 0.25); - display: flex; - align-items: center; - position: relative; - background-color: #5ac479; + margin-bottom: 27px; + width: 311px; + height: 45px; + border: none; + border-radius: 5px; + color: #f9f9f9; + font-size: 14px; + box-shadow: 0px 0px 8px 0px rgba(0, 0, 0, 0.25); + display: flex; + align-items: center; + position: relative; + background-color: #5ac479; - .leftIcon { - margin: 0 14px 0 17px; - } - .rigntIcon { - position: absolute; - right: 12px; - } + .leftIcon { + margin: 0 14px 0 17px; + } + .rigntIcon { + position: absolute; + right: 12px; + } `; const CalendarDiv = styled.div` - margin-bottom: 26px; - width: 312px; - height: 200px; + margin-bottom: 26px; + width: 312px; + height: 200px; - .title { - width: 100%; - height: 30px; - font-size: 16px; - font-weight: 600; - } - .pinIcon { - margin-right: 2px; - color: red; - font-size: 18px; - position: relative; - top: 4px; - } + .title { + width: 100%; + height: 30px; + font-size: 16px; + font-weight: 600; + } + .pinIcon { + margin-right: 2px; + color: red; + font-size: 18px; + position: relative; + top: 4px; + } `; const PerformanceDiv = styled.div` - width: 312px; - height: 110px; + width: 312px; + height: 110px; - .title { - width: 100%; - height: 30px; - font-size: 16px; - font-weight: 600; - } - .medalIcon { - margin-right: 2px; - color: #ecef5a; - font-size: 18px; - position: relative; - top: 4px; - } + .title { + width: 100%; + height: 30px; + font-size: 16px; + font-weight: 600; + } + .medalIcon { + margin-right: 2px; + color: #ecef5a; + font-size: 18px; + position: relative; + top: 4px; + } `; diff --git a/src/pages/IsLoginTemplate.jsx b/src/pages/IsLoginTemplate.jsx index eba0b97..1ce1607 100644 --- a/src/pages/IsLoginTemplate.jsx +++ b/src/pages/IsLoginTemplate.jsx @@ -1,17 +1,22 @@ import { useNavigate } from "react-router-dom"; import { useEffect } from "react"; -import { firebaseAuth } from "../service/firebaseConfig"; +import { onAuthStateChanged } from "firebase/auth"; +import { auth } from "../service/auth"; function IsLoginTemplate(props) { - const navigate = useNavigate(); + const navigate = useNavigate(); - useEffect(() => { - if (firebaseAuth.currentUser) { - navigate("/Home"); - } - }, []); + useEffect(() => { + onAuthStateChanged(auth, (user) => { + if (user) { + navigate("/Home"); + } else { + navigate("/Login"); + } + }); + }, [auth]); - return <>{props.children}>; + return <>{props.children}>; } export default IsLoginTemplate; diff --git a/src/service/auth.js b/src/service/auth.js index 1613b36..6f93841 100644 --- a/src/service/auth.js +++ b/src/service/auth.js @@ -1,21 +1,45 @@ -import { GoogleAuthProvider, getAuth, signInWithPopup } from "firebase/auth"; +import { + GoogleAuthProvider, + getAuth, + signInWithPopup, + signOut, + updateProfile, +} from "firebase/auth"; import { firebaseAuth } from "./firebaseConfig"; const provider = new GoogleAuthProvider(); -const auth = firebaseAuth; +export const auth = firebaseAuth; export const signInWithGoogle = () => { - signInWithPopup(auth, provider) - .then((result) => { - const credential = GoogleAuthProvider.credentialFromResult(result); - const token = credential.accessToken; - const user = result.user; + signInWithPopup(auth, provider) + .then((result) => { + const credential = GoogleAuthProvider.credentialFromResult(result); + const token = credential.accessToken; + const user = result.user; + }) + .catch((err) => { + const errorCode = err.code; + const errorMessage = err.message; + const email = err.customData.email; + const credential = GoogleAuthProvider.credentialFromError(err); + }); +}; + +export const onSignOut = async () => { + try { + await signOut(auth); + } catch (error) { + console.log(error); + } +}; + +export const setDisplayName = async (displayName) => { + updateProfile(auth.currentUser, { + displayName: displayName, }) - .catch((err) => { - const errorCode = err.code; - const errorMessage = err.message; - const email = err.customData.email; - const credential = GoogleAuthProvider.credentialFromError(err); - }); + .then(() => {}) + .catch((error) => { + console.log(error); + }); };