-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dev' into feat/signUpandOut
- Loading branch information
Showing
5 changed files
with
144 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,65 +1,103 @@ | ||
import React from "react"; | ||
import styled from "styled-components"; | ||
import empty from "../empty.png" | ||
import empty from "../empty.png"; | ||
|
||
function SearchResult({data}){ | ||
// let result = data.sort((a,b)=>a.thumbsup-b.thumbsup).reverse().slice(0,3) | ||
let result = [] | ||
const ResultList = styled.ul` | ||
margin-top:20px; | ||
width:75%; | ||
margin: 0 auto; | ||
display:flex; | ||
flex-direction:column; | ||
li{ | ||
display:flex; | ||
height:8vh; | ||
margin-top:2vh; | ||
border:2px solid #000; | ||
border-radius:40px; | ||
text-align:center; | ||
line-height:8vh; | ||
background-color:#ffff8d; | ||
p{ | ||
flex:1 1 auto | ||
} | ||
p:nth-child(2){ | ||
flex: 3 1 auto | ||
} | ||
} | ||
li:nth-child(1){ | ||
margin-top:0px; | ||
} | ||
` | ||
const EmptyResult = styled.div` | ||
text-align:center; | ||
> img{ | ||
width:20vh; | ||
height:20vh; | ||
} | ||
` | ||
return( | ||
<> | ||
{result.length===0? | ||
<EmptyResult> | ||
<img src={empty} alt="empty"/> | ||
<p>검색 결과가 없습니다.</p> | ||
</EmptyResult> | ||
: | ||
<ResultList> | ||
{result.map((ele,idx)=>{ | ||
return ( | ||
<li key={idx}> | ||
<p>{ele.wordName}</p> | ||
<p>{ele.wordMean}</p> | ||
<p>{ele.thumbsup}</p> | ||
</li> | ||
) | ||
})} | ||
</ResultList> | ||
} | ||
</> | ||
) | ||
function SearchResult({ data }) { | ||
let result = data | ||
.sort((a, b) => a.thumbsup - b.thumbsup) | ||
.reverse() | ||
.slice(0, 3); | ||
//let result = []; | ||
const ResultList = styled.ul` | ||
margin-top: 20px; | ||
width: 75%; | ||
margin: 0 auto; | ||
display: flex; | ||
flex-direction: column; | ||
li { | ||
display: flex; | ||
height: 8vh; | ||
margin-top: 2vh; | ||
border: 2px solid #000; | ||
border-radius: 40px; | ||
text-align: center; | ||
line-height: 8vh; | ||
background-color: #ffff8d; | ||
p { | ||
flex: 1 1 auto; | ||
} | ||
p:nth-child(2) { | ||
flex: 3 1 auto; | ||
} | ||
} | ||
li:nth-child(1) { | ||
margin-top: 0px; | ||
} | ||
`; | ||
const EmptyResult = styled.div` | ||
text-align: center; | ||
> img { | ||
width: 20vh; | ||
height: 20vh; | ||
} | ||
`; | ||
const BtnWrap = styled.div` | ||
width: 30%; | ||
margin: 3% auto; | ||
`; | ||
const NewMoreBtn = styled.button` | ||
width: 15vh; | ||
height: 5vh; | ||
border-radius: 5vh; | ||
border: 2px solid black; | ||
background-color: black; | ||
color: white; | ||
margin-left: 10%; | ||
font-size: 0.8rem; | ||
transition: 0.2s; | ||
:hover { | ||
background-color: white; | ||
color: black; | ||
cursor: pointer; | ||
} | ||
`; | ||
|
||
return ( | ||
<> | ||
{result.length === 0 ? ( | ||
<div> | ||
<EmptyResult> | ||
<img src={empty} alt="empty" /> | ||
<p>검색 결과가 없습니다.</p> | ||
</EmptyResult> | ||
|
||
<BtnWrap> | ||
<NewMoreBtn>새로 만들기</NewMoreBtn> | ||
<NewMoreBtn>더보기</NewMoreBtn> | ||
</BtnWrap> | ||
</div> | ||
) : ( | ||
<div> | ||
<ResultList> | ||
{result.map((ele, idx) => { | ||
return ( | ||
<li key={idx}> | ||
<p>{ele.wordName}</p> | ||
<p>{ele.wordMean}</p> | ||
<p>{ele.thumbsup}</p> | ||
</li> | ||
); | ||
})} | ||
</ResultList> | ||
|
||
<BtnWrap> | ||
<NewMoreBtn>새로 만들기</NewMoreBtn> | ||
<NewMoreBtn>더보기</NewMoreBtn> | ||
</BtnWrap> | ||
</div> | ||
)} | ||
</> | ||
); | ||
} | ||
|
||
export default SearchResult; | ||
export default SearchResult; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,14 @@ | ||
import SearchInput from "../comp/SearchInput" | ||
import SearchResult from "../comp/SearchResult" | ||
import SearchInput from "../comp/SearchInput"; | ||
import SearchResult from "../comp/SearchResult"; | ||
import dummyData from "../dummy/dummyData"; | ||
|
||
function Search (){ | ||
return( | ||
<section> | ||
<SearchInput /> | ||
<SearchResult data={dummyData.word}/> | ||
</section> | ||
) | ||
function Search() { | ||
return ( | ||
<section> | ||
<SearchInput /> | ||
<SearchResult data={dummyData.word} /> | ||
</section> | ||
); | ||
} | ||
|
||
export default Search; | ||
export default Search; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
const { content } = require("../../models"); | ||
|
||
module.exports = { | ||
post: async (req, res) => { | ||
try { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,33 @@ | ||
const { user } = require("../../models"); | ||
const { generateAccessToken } = require("../tokenFunction/accessToken"); | ||
const { generateRefreshToken, sendRefreshToken } = require("../tokenFunction/refreshToken"); | ||
|
||
module.exports = { | ||
post: (req, res) => { | ||
res.send("This is user/login"); | ||
post: async (req, res) => { | ||
try { | ||
const { email, password } = req.body; | ||
if(!email || !password) { | ||
res.status(401).json({ message: "Invalid User" }); | ||
} | ||
const findData = await user.findOne({ | ||
where: {email: email, password: password} | ||
}); | ||
if(!findData) { | ||
res.status(401).json({ message: "Invalid User" }); | ||
} else { | ||
delete findData.dataValues.password; | ||
const accessToken = generateAccessToken(findData.dataValues); | ||
const refreshToken = generateRefreshToken(findData.dataValues); | ||
sendRefreshToken(res, refreshToken); | ||
res.status(200).json({ | ||
accessToken: accessToken, | ||
userInfo: findData.dataValues, | ||
message: "ok" | ||
}); | ||
} | ||
} catch(error) { | ||
console.log(error); | ||
res.status(500).json({ message: "Server Error" }); | ||
} | ||
} | ||
} |