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

로그인 상태/라운지 참여여부 #114

Open
wants to merge 13 commits into
base: develop
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 36 additions & 3 deletions src/pages/lounge/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import styled from 'styled-components';
import Router from 'next/router';
import useRouter from 'next/router';
import { useState, useEffect, useRef } from 'react';
import { scrollTo } from 'seamless-scroll-polyfill';
import Axios from 'axios';
import { getCookie } from '~lib/Cookie';

import DoorBottom from '~components/icons/DoorBottom.svg';
Expand All @@ -25,14 +26,46 @@ const LoungeHome = () => {
dispatch(showNotice('로그인 혹은 회원가입을 진행해주세요!'));
};

const returnLoungeSelect = async () => {
dispatch(showNotice('라운지 생성을 먼저 진행해주세요!'));
};

// 로그인 하지 않은 상태로 라운지 진입시
useEffect(() => {
if (!getCookie('jwt')) {
Router.push('/sign-in');
if (getCookie('jwt')) {
useRouter.push('/sign-in');
JJongsKim marked this conversation as resolved.
Show resolved Hide resolved
returnMessage();
}
statusVerify();
}, []);

// 로그인 O 상태, 라운지 소속일 때 /라운지 소속이 아닐 때
const statusVerify = async () => {
try {
// 내가 소속된 라운지 리스트
const loungeList = await Axios.get(`https://api.liontown.city/api/lounges`, {
withCredentials: true,
});
// 선택한 라운지 정보 -> {id} 부분에 임시로 값 넣음
const selectLounge = await Axios.get(`https://api.liontown.city/api/lounges/sgIG8L`, {
withCredentials: true,
});
// console.log(selectLounge.data.data.roomData);
// 내가 소속된 라운지 리스트명과 선택한 라운지가 같지 않을 때
// 혹은 해당 라운지가 없는 경우 라운지 생성페이지로 보내기
if (
loungeList.data.data[0].name !== selectLounge.data.data.loungeName.name ||
selectLounge.status === 404
) {
useRouter.push('/lounge-select');
setTimeout(() => returnLoungeSelect(), 2000);
Copy link
Member

Choose a reason for hiding this comment

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

clear함수가 필요해보여요~

}
} catch (err) {
// console.log 없앨 예정 ..
console.log('error');
}
};
Copy link
Contributor

@Bhanjo Bhanjo Aug 11, 2022

Choose a reason for hiding this comment

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

get 요청은 리액트 쿼리를 써주세요
api 패치를 한번에 두 개를 하는데 이 둘을 동기적으로 다룰 것이 아니라면 분리해주세요


const handleScrollUp = () => {
if (currentFloor === 0) {
setCurrentFloor(totalFloor);
Expand Down