Skip to content

Commit

Permalink
Merge pull request 7eveloper#36 from 7eveloper/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
2njeong authored Mar 25, 2024
2 parents 099bf40 + 395eb31 commit f3247c3
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 14 deletions.
2 changes: 0 additions & 2 deletions src/app/login/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ const LoginPage = () => {
"이메일에서 회원가입을 완료해주세요💛",
]);
alertMsgWithAction("회원가입", new Date().toLocaleString());
setLoginMode(true);
} else {
if (
error.message ===
Expand Down Expand Up @@ -132,7 +131,6 @@ const LoginPage = () => {
router.refresh();
changeLoggedIn(!!data.session);
const userData = await fetchUser();
setMessage(["로그인완료", "이거는 되나?"]);
changeNickname(userData && userData[0].nickname);
alertMsgWithAction("로그인", new Date().toLocaleString());
} else if (error && error.message === "Invalid login credentials") {
Expand Down
26 changes: 17 additions & 9 deletions src/components/customUi/navUi/NavBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,27 @@ const NavBar = () => {

useEffect(() => {
const fetchSession = async () => {
const { data } = await supabase.auth.getSession();
changeLoggedIn(!!data.session);
const { data: user } = await supabase.auth.getSession();
changeLoggedIn(!!user.session);
};

fetchSession();
}, [supabase.auth, changeLoggedIn]);

if (data.session) {
const surveyResult = await fetchSurvey();
surveyResult?.length !== 0 && changeSurveyDone(true);
const userData = await fetchUser();
changeNickname(userData && userData[0].nickname);
useEffect(() => {
const fetchUserData = async () => {
const surveyResult = await fetchSurvey();
if (surveyResult?.length !== 1) {
changeSurveyDone(false);
}
const userData = await fetchUser();
changeNickname(userData && userData[0].nickname);
};

fetchSession();
}, [supabase.auth, changeLoggedIn, changeSurveyDone, changeNickname]);
if (loggedIn) {
fetchUserData();
}
}, [loggedIn, changeSurveyDone, changeNickname]);

const handleSignOut = async () => {
await supabase.auth.signOut();
Expand Down
4 changes: 2 additions & 2 deletions src/components/survey/AlertSurveyDemo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import SurveyDrawerBtn from "@/components/survey/SurveyDrawerBtn";

export function AlertSurveyDemo({ nickname }: { nickname: string }) {
return (
<Alert className="flex justify-between">
<Alert className="flex justify-between items-center">
<RocketIcon className="h-4 w-4" />
<div>
<div className="mt-2">
<AlertTitle>설문조사를 완료해주세요!</AlertTitle>
<AlertDescription>
{nickname}님 만의 맞춤형 건강관리가 시작됩니다.
Expand Down
2 changes: 1 addition & 1 deletion src/store/zustandStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ type Actions = {
export const zustandStore = create<UserState & Actions>((set) => ({
user: {
loggedIn: false,
surveyDone: false,
surveyDone: true,
nickname: "",
},
changeLoggedIn: (isSession) =>
Expand Down

0 comments on commit f3247c3

Please sign in to comment.