Skip to content

Commit

Permalink
feat: #12 가게등록, 로그인, 등록마감, 설명수정
Browse files Browse the repository at this point in the history
  • Loading branch information
mineii committed Jan 19, 2023
1 parent f2b4722 commit 873bb03
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 21 deletions.
10 changes: 5 additions & 5 deletions src/components/StoreRegister/StoreRegisterInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ export default function RegisterInput() {

const storeRegister =()=>{
//axios.post(url : post가 연결되어야 할 api주소, data : 백엔드에서 정의한 request body).then(앞 코드가 정상작동하면 실행되는 다음 행위)
axios.post('http://localhost:8000/api/v1/stores/signup/',{
axios.post('http://localhost:8000/api/v1/stores/signin/',{
store_name: store_name,
phone_num: phone_num,
latitude: 0,
longitude: 0,
email : email,
password: password})
.then((res) =>localStorage.setItem("store_id", res.data.store_id) ) //(setItem) 로컬스토리지에 res.data.store_id를 "id"로 저장하는 코드,
// res는 사용자 마음대로 정의, res.data.store_id는 백엔드에서 받아온 response body
.then((res) =>localStorage.setItem("token", res.data.token) ) //(setItem) 로컬스토리지에 res.data.store_id를 "id"로 저장하는 코드,
// res는 사용자 마음대로 정의, res.data.store_id는 백엔드에서 받아온 response body
}
//console.log(localStorage.getItem("id")) 로컬스토리지에서 저장되어있는 값을 꺼내와서 console.log에 출력해서 확인하는 코드(getItem)

Expand All @@ -47,9 +47,9 @@ export default function RegisterInput() {
<TextField onChange={(e)=>{setEmail(e.target.value)}}id="standard-basic" label="이메일 주소" variant="standard" />
<TextField onChange={(e)=>{setPassword(e.target.value)}}id="standard-basic" label="비밀번호" variant="standard" />
</Box>
<Link to="/waitingList">
{/* <Link to="/waitingList"> */}
<button onClick={storeRegister} className="ButtonStyle" >가게 등록</button>
</Link>
{/* </Link> */}
</div>

);
Expand Down
4 changes: 1 addition & 3 deletions src/components/WaitingList/StoreInformation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ function StoreInformation(information: any) {
store_id: localStorage.getItem("store_id"), //- 우선 임의의 값으로 지정, 로그인 api완료 후 추후 진행
information: info //information: info = 처음에 가져온 가게설명 초기값 : 변경되는 가게설명수정
})
.then((response) => {
console.log(information);
})
.then(res => setInfo(info))
.catch((error) => {
console.log('Error!');
});
Expand Down
2 changes: 1 addition & 1 deletion src/components/WaitingList/SubButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ function SubButton() {
store_id: 2 //localStorage.getItem("store_id") //회원가입(가게등록)을 해서 store_id가 생성이 돼야 localStorage에 저장이 되고,
//이후 getItem을 통해 store_id를 가져올 수 있는데, 아직 그 과정이 선행되지 않아 임의로 2로 지정해주어 확인 작업함
})
.then(res => setIs_waiting(!is_waiting)
.then(res => setIs_waiting(is_waiting)
)
}

Expand Down
16 changes: 8 additions & 8 deletions src/pages/Login/Login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,25 @@ import {
} from "react-router-dom";
import axios from "axios";

// 로그인
// 로그인, response body - access, refresh

function Login() {
document.body.style.backgroundColor = "#FFFBD9";

const [store_name, setStore_name] = useState('')
const [email, setEmail] = useState('')
const [password, setPassword] = useState('')

function Con() {
console.log(store_name, password)
console.log(email, password)
}

// URL확인 필요!
const storeLogin =()=>{
//axios.post(url : post가 연결되어야 할 api주소, data : 백엔드에서 정의한 request body).then(앞 코드가 정상작동하면 실행되는 다음 행위)
axios.post('http://localhost:8000/api/v1/stores/login/',{
store_id: localStorage.getItem('store_id'),
token: '민아'})
.then((res) => console.log(res)) //(setItem) 로컬스토리지에 res.data.store_id를 "id"로 저장하는 코드,
email: email,
password: password})
.then((res) =>localStorage.setItem("token", res.data.token)) //(setItem) 로컬스토리지에 res.data.store_id를 "id"로 저장하는 코드,
// res는 사용자 마음대로 정의, res.data.store_id는 백엔드에서 받아온 response body
}

Expand All @@ -38,8 +38,8 @@ function Login() {
noValidate
autoComplete="off">
<Logo/>
<TextField onChange={(e)=>{setStore_name(e.target.value)}} id="standard-basic" label="가게명 / 업소명" variant="standard" />
<TextField onChange={(e)=>{setPassword(e.target.value)}}id="standard-basic" label="비밀번호(4자리)" variant="standard" />
<TextField onChange={(e)=>{setEmail(e.target.value)}} id="standard-basic" label="이메일 주소" variant="standard" />
<TextField onChange={(e)=>{setPassword(e.target.value)}}id="standard-basic" label="비밀번호" variant="standard" />
</Box>
<div className="InputStyle">
<Link to="/WaitingList">
Expand Down
13 changes: 9 additions & 4 deletions src/pages/WaitingList/WaitingList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,21 @@ const test: waitings[] = [
}
]



function WaitingList() {
document.body.style.backgroundColor = "#FFFBD9";

//const [information, setInformation] = useState('');
const [is_waiting, setIs_waiting] = useState(true);
const [waiting, setWaiting] = useState([]); //props 이용해서 자식 페이지로 ?
const [temp, setTemp] = useState<res>({information:'',
is_waiting : true, waiting : {waiting_id : 0, name: '', people:0, phone_num: ''}});
const [temp, setTemp] = useState<res>({
information:'',
is_waiting : true,
waiting : {
waiting_id : 0,
name: '',
people:0,
phone_num: ''
}});

const customerRegister =()=>{
//axios.post(url : post가 연결되어야 할 api주소, data : 백엔드에서 정의한 request body).then(앞 코드가 정상작동하면 실행되는 다음 행위)
Expand Down

0 comments on commit 873bb03

Please sign in to comment.