Skip to content

Commit

Permalink
#147 feature/visibility (#148)
Browse files Browse the repository at this point in the history
* check git status

* handle conflict

* reabsed

* goto search page if login

* delete logo withrouter header

* update riot api key

* header visibility implement

* delete header component from login page

* Updated search API call into front

* handle errors in commonsearch
  • Loading branch information
ericagong authored Dec 3, 2021
1 parent f4886fb commit ec4eddd
Show file tree
Hide file tree
Showing 10 changed files with 81 additions and 46 deletions.
2 changes: 1 addition & 1 deletion backend/gaejosim/report/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"region": "https://kr.api.riotgames.com",
"asia": "https://asia.api.riotgames.com", # korea server
# api key : needs to regenerate every 24hr
"key": "RGAPI-7fd97294-d6a6-403f-8a8f-5ca33beaa59e", # updated 11/26
"key": "RGAPI-927e5e6c-bb20-4a24-b9b8-993fc7ff9d07", # updated 12/3
}

tag_dict = {
Expand Down
2 changes: 1 addition & 1 deletion backend/gaejosim/search/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"asia": "https://asia.api.riotgames.com", # asia server
"korea": "https://kr.api.riotgames.com", # korea server
# api key : needs to regenerate every 24hr
"key": "RGAPI-7fd97294-d6a6-403f-8a8f-5ca33beaa59e", # updated 11/26
"key": "RGAPI-927e5e6c-bb20-4a24-b9b8-993fc7ff9d07", # updated 12/3
}


Expand Down
2 changes: 1 addition & 1 deletion backend/gaejosim/user/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
api_default = {
"region": "https://kr.api.riotgames.com", # korea server
# api key : needs to regenerate every 24hr
"key": "RGAPI-7fd97294-d6a6-403f-8a8f-5ca33beaa59e", # updated 11/26
"key": "RGAPI-927e5e6c-bb20-4a24-b9b8-993fc7ff9d07", # updated 12/3
}


Expand Down
12 changes: 5 additions & 7 deletions frontend/gaejosim/src/Component/CommonSearch/CommonSearch.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ import tagdiagram_5 from "./tagDiagrams/diagram_5.png";
import './CommonSearch.css';

// TODO: tag diagram 형성하기
// TODO: rank 값 위치 CSS에서 조정하기
// TODO : css로 박스값 위치조정하기

class CommonSearch extends Component {

Expand All @@ -37,7 +35,7 @@ class CommonSearch extends Component {
const resultViews = this.state.recentResults.map((result) => {
idx = idx + 1;
return (
<Result result={result} winLose={winLoseArr[idx]} />
<Result key={idx} result={result} winLose={winLoseArr[idx]} />
)
})
console.log(this.state.num)
Expand All @@ -56,13 +54,13 @@ class CommonSearch extends Component {

<div className = 'SummonerInfo'>
<p className = 'Summoner'>
<div className = 'nameStyle1'>{this.state.summonerName}</div>
<b className = 'nameStyle1'>{this.state.summonerName}</b>
<img className = 'tierImg' alt = 'tier_img' src = {process.env.PUBLIC_URL + `/images/tiers/tier_${this.state.tier}.png`} />
<text className = 'tier'>{this.state.tier}</text>
<text className = 'rank'>{this.state.rank}</text>
<b className = 'tier'>{this.state.tier}</b>
<b className = 'rank'>{this.state.rank}</b>
</p>
<div className = 'manner_point'>
<text className = 'manner_point_text'>MP: {this.state.mannerPoint}</text>
<div className = 'manner_point_text'>MP: {this.state.mannerPoint}</div>
</div>
</div>

Expand Down
17 changes: 7 additions & 10 deletions frontend/gaejosim/src/Component/MultiSearch.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import axios from "axios";

import "./MultiSearch.css";

// TODO: api call 시 type 요소 뺄지 논의하기

class MultiSearch extends Component {
constructor(props) {
super(props);
Expand All @@ -29,15 +27,14 @@ class MultiSearch extends Component {
console.log("call axios.get request");
const response = await axios.get(url, {
params: {
type: "multi",
summoners: this.state.summoners,
},
});

this.setState({
matchers: response.data.matchers,
getResult: true,
});
})
.then(res => {
console.log("response.data.matchers")
console.log(res.data.matchers)
this.setState({matchers: res.data.matchers, getResult: true})
})
};

render() {
Expand All @@ -50,7 +47,7 @@ class MultiSearch extends Component {
idx = idx + 1;
let summonerIdx = "summoner" + idx;
return (
<div className={summonerIdx}>
<div className={summonerIdx} key={summonerIdx}>
<CommonSearch
summonerName={matcher.summoner_name}
tier={matcher.tier}
Expand Down
2 changes: 1 addition & 1 deletion frontend/gaejosim/src/Component/Signup/Signup.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,4 +122,4 @@ class SignUp extends Component {
}

export default withRouter(SignUp)


75 changes: 54 additions & 21 deletions frontend/gaejosim/src/Container/Header/Header.js
Original file line number Diff line number Diff line change
@@ -1,52 +1,85 @@
import React, { Component } from "react";
import { Redirect } from "react-router-dom";
import { Redirect, withRouter } from "react-router-dom";
import axios from 'axios';
import { connect } from 'react-redux';

import * as actionTypes from '../../Store/Actions/ActionTypes';

import "./Header.css";
// import logo from './logo.png';

// TODO: login 상태일 때는 로그아웃 버튼으로 디스플레이, 아니면 login 버튼으로 디스플레이.
// TODO: css에 로그아웃 버튼 추가하기

class Header extends Component {
state = {
clickLogin: false,
clickMyPage: false,

postLogoutData = async () => {
console.log("postSignOutData")

axios.defaults.xsrfCookieName = 'csrftoken';
axios.defaults.xsrfHeaderName = 'X-CSRFToken';

axios.get('/api/token/').then()

const response = await axios.post('/api/logout/', {
})
.then((response) => {
console.log("로그아웃 완료")
this.props.onStoreLogout()
this.props.history.push('/search')
})
.catch((error) => {
alert(error.response.data.error)
})
}

onClickLogoutButton = () => {
this.postLogoutData()
};

onClickLoginButton = () => {
this.setState({ clickLogin: true });
this.props.history.push('/login')
};

onClickMyPageButton = () => {
this.setState({ clickMyPage: true });
this.props.history.push('/my')
};

render() {
let redirect = null;
if (this.state.clickLogin) {
redirect = <Redirect to="/login" />;
}
if (this.state.clickMyPage) {
redirect = <Redirect to="/my" />;
}
return (
<div className="Header">
{redirect}
{/* <img className='logoImage' alt='logo-img' src={logo} /> */}
<button
{!this.props.storedisLogin && <button
className="loginButton"
onClick={() => this.onClickLoginButton()}
>
로그인
</button>
<button
</button>}
{this.props.storedisLogin && <button
className="loginButton"
onClick={() => this.onClickLogoutButton()}
>
로그아웃
</button>}
{this.props.storedisLogin && <button
className="mypageButton"
onClick={() => this.onClickMyPageButton()}
>
마이페이지
</button>
</button>}
</div>
);
}
}

export default Header;
const mapDispatchToProps = dispatch => {
return {
onStoreLogout: () => dispatch({ type : actionTypes.SIGNOUT_USER }),
}
}

const mapStateToProps = state => {
return {
storedisLogin : state.userR.login,
}
}

export default connect(mapStateToProps, mapDispatchToProps)(withRouter(Header));
Binary file removed frontend/gaejosim/src/Container/Header/logo.png
Binary file not shown.
14 changes: 11 additions & 3 deletions frontend/gaejosim/src/Container/Login/Login.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { Component } from "react";
import { connect } from 'react-redux';
import { NavLink, withRouter } from 'react-router-dom'
import { NavLink, withRouter, Redirect } from 'react-router-dom'
import axios from 'axios';

import * as actionTypes from '../../Store/Actions/ActionTypes';
Expand Down Expand Up @@ -50,6 +50,8 @@ class Login extends Component {
}

render() {
let redirect = null
if(this.props.storedisLogin) redirect = <Redirect to = '/search'/>
return (
<div className = 'Login'>
<div className="LoginTitle">로그인</div>
Expand Down Expand Up @@ -84,8 +86,14 @@ class Login extends Component {

const mapDispatchToProps = dispatch => {
return {
onStoreLogin: () => dispatch({ type : actionTypes.SIGNIN_USER })
onStoreLogin: () => dispatch({ type : actionTypes.SIGNIN_USER }),
}
}

export default connect(null, mapDispatchToProps)(withRouter(Login))
const mapStateToProps = state => {
return {
storedisLogin : state.userR.login,
}
}

export default connect(mapStateToProps, mapDispatchToProps)(withRouter(Login))
1 change: 0 additions & 1 deletion frontend/gaejosim/src/Page/LoginPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ class LoginPage extends Component {
render () {
return (
<div className='FindUserInfoPage'>
<Header />
<Login />
</div>
)
Expand Down

0 comments on commit ec4eddd

Please sign in to comment.