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
Show file tree
Hide file tree
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
30 changes: 10 additions & 20 deletions src/components/lounge/LoungeDoor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,23 @@ import styled from 'styled-components';
import { useState, useEffect } from 'react';
import Axios from 'axios';

import TestDoor from '~components/lounge/LoungeDemoData';
import FloorNumber from '~components/lounge/FloorDemoData';

type RoomInfo = {
id: string;
name: string;
userId: string;
userName: string;
};

const LoungeDoor = () => {
const [roomsList, setRoomsList] = useState<RoomInfo[]>();
const [roomsList, setRoomsList] = useState<RoomInfo[]>([]);

const roomsLoading = async () => {
try {
const roomsRes = await Axios.get(`https://api.liontown.city/api/lounges/sgIG8L`, {
const roomRes = await Axios.get(`https://api.liontown.city/api/lounges/sgIG8L`, {
JJongsKim marked this conversation as resolved.
Show resolved Hide resolved
withCredentials: true,
});
setRoomsList(roomsRes.data.data.roomData);
setRoomsList(roomRes.data.data.roomData);
return roomsList;
} catch (err) {
console.log('test');
}
Expand All @@ -29,23 +29,13 @@ const LoungeDoor = () => {
}, []);

return (
<LoungeFloor roomsLength={TestDoor?.length}>
<LoungeFloor roomsLength={roomsList?.length}>
<Doors>
{/* {roomsList
{roomsList
.slice(0)
.reverse()
.map(room => (
<LoungeDoors key={room.roomId}>
<NameSpace>
<RoomName>{room.userName}</RoomName>
</NameSpace>
<Knob />
</LoungeDoors>
))} */}
{TestDoor.slice(0)
.reverse()
.map(room => (
<LoungeDoors key={room.userNum}>
<LoungeDoors key={room.userName}>
<NameSpace>
<RoomName>{room.userName}</RoomName>
</NameSpace>
Expand All @@ -68,7 +58,7 @@ const LoungeDoor = () => {
const LoungeFloor = styled.div`
position: relative;

/* 라운지 개인 방이 4개 이하인 경우에 붕 뜸 현상 > margin-top 속성 필요.. */
/* 라운지 개인 방이 4개 이하인 경우에 붕 뜸 현상 > margin-top 속성 필요.. */
margin-top: ${props => (props.roomsLength <= 4 ? '320px' : '0')};
`;

Expand Down
17 changes: 4 additions & 13 deletions src/pages/lounge/index.tsx → src/pages/lounge/[id].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import Notice from '~components/Notice/Notice';
const LoungeHome = () => {
const router = useRouter();
const [currentFloor, setCurrentFloor] = useState<number>(0);
// const [loungeId, setLoungeId] = useState<string>('');
const floorRef = useRef<HTMLDivElement>(null);
const dispatch = useAppDispatch();
// 0: 9-10F / 1: 7-8F / 2: 5-6F / 3: 3-4F / 4: 1-2F
Expand All @@ -37,24 +36,16 @@ const LoungeHome = () => {
// 로그인 O 상태, 라운지 소속일 때 / 라운지 소속이 아닐 때
const statusVerify = async () => {
try {
// 내가 소속된 라운지 리스트
const loungeList = await Axios.get(`https://api.liontown.city/api/lounges`, {
withCredentials: true,
});
// 선택한 라운지 정보 -> {id} 부분에 임시로 값 넣음
// 선택한 라운지 정보 -> {id} 부분에 임시로 값 넣음 : sgIG8L로 테스트 가능
const selectLounge = await Axios.get(`https://api.liontown.city/api/lounges/sgIG8L`, {
withCredentials: true,
});

// 내가 소속된 라운지 리스트명과 선택한 라운지가 같지 않을 때
// 혹은 해당 라운지가 없는 경우 라운지 생성페이지로 보내기
if (
loungeList.data.data[0].name !== selectLounge.data.data.loungeName.name ||
selectLounge.status === 404
) {
// 해당 라운지가 없는 경우 라운지 생성페이지로 보내기
if (selectLounge.status === 404) {
router.push('/lounge-select');
returnLoungeSelect();
// setTimeout(() => returnLoungeSelect(), 2000);
setTimeout(() => returnLoungeSelect(), 2000);
}
} catch (err) {
// console.log 없앨 예정 ..
Expand Down