-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #192 from hhbb0081/test
Feat: 영업중 & 영업종료 api 연동
- Loading branch information
Showing
11 changed files
with
205 additions
and
31 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
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
26 changes: 17 additions & 9 deletions
26
src/components/views/Header/OperationButton/OperationButton.jsx
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
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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { useEffect, useState } from "react"; | ||
import commonApis from "../../util/commonApis"; | ||
|
||
const apiUrl = `/user/name`; | ||
|
||
const useFetchStoreName = () => { | ||
const [info, setInfo] = useState(""); | ||
const token = localStorage.getItem("accessToken"); | ||
const config = { | ||
headers: { | ||
Authorization: `Bearer ${token}`, | ||
}, | ||
}; | ||
useEffect(() => { | ||
const fetchData = async () => { | ||
commonApis | ||
.get(`${apiUrl}`, config) | ||
.then((res) => { | ||
if (res.status === 200) { | ||
setInfo(res.data.name); | ||
} | ||
}) | ||
.catch((err) => console.log(err)); | ||
}; | ||
fetchData(); | ||
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
}, []); | ||
return info; | ||
}; | ||
|
||
export default useFetchStoreName; |
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 |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { useEffect } from "react"; | ||
import { useSetRecoilState } from "recoil"; | ||
import { storeContextState } from "../../Atom/status"; | ||
import commonApis from "../../util/commonApis"; | ||
|
||
const apiUrl = `/store/sales`; | ||
|
||
const useFetchStoreStatus = () => { | ||
const setStoreStatus = useSetRecoilState(storeContextState); | ||
const token = localStorage.getItem("accessToken"); | ||
const config = { | ||
headers: { | ||
Authorization: `Bearer ${token}`, | ||
}, | ||
}; | ||
const fetchData = async () => { | ||
commonApis | ||
.get(apiUrl, config) | ||
.then((res) => { | ||
if (res.status === 200) { | ||
setStoreStatus(res.data.status); | ||
return res.data.status; | ||
} | ||
}) | ||
.catch((err) => console.log(err)); | ||
}; | ||
useEffect(() => { | ||
fetchData(); | ||
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
}, []); | ||
return; | ||
}; | ||
|
||
export default useFetchStoreStatus; |
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 |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { message } from "antd"; | ||
import { useSetRecoilState } from "recoil"; | ||
import { storeContextState } from "../../Atom/status"; | ||
import commonApis from "../../util/commonApis"; | ||
|
||
const apiUrl = `/store/sales`; | ||
|
||
const useStoreStatusChange = () => { | ||
const token = localStorage.getItem("accessToken"); | ||
const setStoreStatus = useSetRecoilState(storeContextState); | ||
|
||
const storeStatusChange = async (status) => { | ||
console.log('status: ', status); | ||
const body ={ | ||
status: status | ||
}; | ||
const config = { | ||
headers: { | ||
Authorization: `Bearer ${token}`, | ||
}, | ||
}; | ||
try { | ||
const response = await commonApis.post( | ||
apiUrl, body, config | ||
); | ||
if(response.status === 200){ | ||
message.success("영업 상태 변경 완료되었습니다."); | ||
setStoreStatus(response.data.status); | ||
} else { | ||
message.error("영업 상태 변경 실패하였습니다."); | ||
} | ||
} catch (error) { | ||
console.log(error); | ||
message.error("영업 상태 변경 중 오류가 발생하였습니다."); | ||
} | ||
} | ||
return storeStatusChange; | ||
}; | ||
|
||
export default useStoreStatusChange; |
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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { message } from "antd"; | ||
import commonApis from "../util/commonApis"; | ||
|
||
const apiUrl = `/ceo/entry/reject`; | ||
|
||
const useRejectEntry = () => { | ||
const token = localStorage.getItem("accessToken"); | ||
const config = { | ||
headers: { | ||
Authorization: `Bearer ${token}`, | ||
}, | ||
}; | ||
const rejectEntry = () => { | ||
commonApis | ||
.get(`${apiUrl}`, config) | ||
.then((res) => { | ||
if (res.status === 200 && res.data.success) { | ||
message.success(res.data.message); | ||
} | ||
}) | ||
.catch((err) => console.log(err)); | ||
}; | ||
return rejectEntry; | ||
}; | ||
|
||
export default useRejectEntry; |
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
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
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
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