Commit 1e75d62c authored by Yoon, Daeki's avatar Yoon, Daeki 😅
Browse files

api changed

parent 2e9e6170
......@@ -47,7 +47,7 @@ function Notice({ card_id, card_index, title, date, content, admin }) {
}
function remove (card_id) {
axios.delete(`/notices/${card_id}`)
axios.delete(`/api/notices/${card_id}`)
.then(res => {
if (res.status === 404) return alert(res.data.error)
alert("삭제되었습니다!");
......
......@@ -28,7 +28,7 @@ function Menu() {
}, [])
function acheck() {
axios.get(`/users/${localStorage.getItem('_id')}`, {
axios.get(`/api/users/${localStorage.getItem('_id')}`, {
headers: { authorization: localStorage.getItem('token') },
}).then(res => {
if (res.data.role == "admin") {
......
......@@ -20,7 +20,7 @@ function Cal(props) {
});
function getReserve(room) {
axios.get(`/reserves/room/${room}`, {
axios.get(`/api/reserves/room/${room}`, {
headers: { authorization: localStorage.getItem('token') },
})
.then(res => {
......
......@@ -31,7 +31,7 @@ function ACheck(props) {
}, [])
function getReserve() {
axios.get(`/users/admin/${props.match.params.id}`, {
axios.get(`/api/users/admin/${props.match.params.id}`, {
headers: { authorization: localStorage.getItem('token') },
})
.then(res => {
......@@ -48,7 +48,7 @@ function ACheck(props) {
if (state) return <Redirect to="/" />;
function remove(index) {
axios.put(`/reserves/${reserve[index]._id}`)
axios.put(`/api/reserves/${reserve[index]._id}`)
.then(res => {
if (res.status === 404) return alert(res.data.error)
alert("승인을 거절했습니다!");
......@@ -60,7 +60,7 @@ function ACheck(props) {
};
function admit(index) {
axios.put(`/reserves/${reserve[index]._id}`, {
axios.put(`/api/reserves/${reserve[index]._id}`, {
approve: true,
})
.then(res => {
......
......@@ -46,7 +46,7 @@ function Apply(props) {
}
function getUser() {
axios.get(`/users/${props.match.params.id}`, {
axios.get(`/api/users/${props.match.params.id}`, {
headers: { authorization: localStorage.getItem('token') },
})
.then(res => {
......@@ -100,7 +100,7 @@ function Apply(props) {
addRoomInfo(values);
axios({
method: 'post',
url: '/reserves',
url: '/api/reserves',
data: values
}).then(res => {
if (res.status === 404) {
......
......@@ -12,9 +12,9 @@ const Check = styled.div`
content: '새로운 비밀번호를 다시 입력하세요';
}
& #reCheck:not(.right) {
content: '비밀번호가 일치하지 않습니다.';
& #reCheck:not(.right)::after {
color: red;
content: "비밀번호가 일치하지 않습니다";
}
`
......@@ -50,7 +50,7 @@ function Change(props) {
.oneOf([Yup.ref("password"), null], '비밀번호가 일치하지 않습니다.'),
})}
onSubmit={(values, { setSubmitting }) => {
axios.put(`/users/change/${props.location.state.id}`, { ...values },
axios.put(`/api/users/change/${props.location.state.id}`, { ...values },
)
.then(res => {
console.log(res.data);
......@@ -87,7 +87,7 @@ function Change(props) {
</div>
<div className="form-group">
{touched.password2 && errors.password2 ? setCheckPw(false) : null}
{touched.password2 && errors.password2 ? setCheckPw(false) : setCheckPw(true)}
<div id="reCheck" className={checkPw ? "right" : "err"}></div>
<input
className={(touched.password2 && errors.password2 ? 'form-control is-invalid' : "form-control")}
......
......@@ -37,7 +37,7 @@ function Check(props) {
if (state) return <Redirect to="/" />;
function getReserve() {
axios.get(`/reserves/${props.match.params.id}`, {
axios.get(`/api/reserves/${props.match.params.id}`, {
headers: { authorization: localStorage.getItem('token') },
})
.then(res => {
......@@ -59,7 +59,7 @@ function Check(props) {
});
}
function remove(index) {
axios.delete(`/reserves/${reserve[index]._id}`)
axios.delete(`/api/reserves/${reserve[index]._id}`)
.then(res => {
if (res.status === 404) return alert(res.data.error)
alert("삭제되었습니다!");
......
......@@ -43,7 +43,7 @@ function Find() {
onSubmit={(values, { setSubmitting }) => {
axios({
method: 'post',
url: '/login/find',
url: '/api/login/find',
data: values,
}).then(res => {
if (res.status === 404) return alert(res.data.error)
......
......@@ -16,7 +16,7 @@ function Home() {
if (state) return <Redirect to="/" />;
function tcheck() {
axios.get(`/users/${localStorage.getItem('_id')}`, {
axios.get(`/api/users/${localStorage.getItem('_id')}`, {
headers: { authorization: localStorage.getItem('token') },
})
.then(res => {
......
......@@ -125,7 +125,7 @@ function Login() {
onSubmit={(values, { setSubmitting }) => {
axios({
method: 'post',
url: '/login',
url: '/api/login',
data: values,
}).then(res => {
if (res.status === 404) return alert(res.data.error)
......
......@@ -25,7 +25,7 @@ function Modify({ match }) {
function getOne(id) {
if (id) {
axios.get(`/notices/${match.params.id}`)
axios.get(`/api/notices/${match.params.id}`)
.then(res => {
if (res.status !== 201) {
alert(res.data.error);
......@@ -39,7 +39,7 @@ function Modify({ match }) {
};
function acheck() {
axios.get(`/users/admin/${localStorage.getItem('_id')}`, {
axios.get(`/api/users/admin/${localStorage.getItem('_id')}`, {
headers: { authorization: localStorage.getItem('token') },
})
.then(res => {
......@@ -73,7 +73,7 @@ function Modify({ match }) {
onSubmit={(values, { setSubmitting }) => {
axios({
method: 'put',
url: `/writes/${match.params.id}`,
url: `/api/writes/${match.params.id}`,
data: values,
})
.then(res => {
......
......@@ -18,7 +18,7 @@ function Notice() {
if (state) return <Redirect to="/" />;
function acheck() {
axios.get(`/users/${localStorage.getItem('_id')}`, {
axios.get(`/api/users/${localStorage.getItem('_id')}`, {
headers: { authorization: localStorage.getItem('token') },
})
.then(res => {
......@@ -36,7 +36,7 @@ function Notice() {
}
function getNotice() {
axios.get(`/notices`)
axios.get(`/api/notices`)
.then(res => {
console.log('res.data=', res.data)
if (res.status !== 201) {
......
......@@ -17,13 +17,13 @@ const Menu = styled(Navbar)`
const Wow = styled.div`
height: 90vh;
& #reCheck::after {
content: '비밀번호를 다시 입력하세요';
& #reCheck:after {
content: "비밀번호를 다시 입력하세요";
}
& #reCheck:not(.right) {
content: '비밀번호가 일치하지 않습니다.';
& #reCheck:not(.right)::after {
color: red;
content: "비밀번호가 일치하지 않습니다";
}
`
......@@ -62,7 +62,7 @@ function Signup() {
onSubmit={(values, { setSubmitting }) => {
axios({
method: 'post',
url: '/users',
url: '/api/users',
data: values,
}).then(res => {
if (res.status === 404) return alert(res.data.error)
......@@ -119,7 +119,7 @@ function Signup() {
</div>
<div className="form-group">
{touched.password2 && errors.password2 ? setCheckPw(false) : null}
{touched.password2 && errors.password2 ? setCheckPw(false) : setCheckPw(true)}
<div id="reCheck" className={checkPw ? "right" : "err"}></div>
<input
className={touched.password2 && errors.password2 ? "form-control is-invalid" : "form-control"}
......
......@@ -22,7 +22,7 @@ function Write() {
}
function acheck() {
axios.get(`/users/admin/${localStorage.getItem('_id')}`, {
axios.get(`/api/users/admin/${localStorage.getItem('_id')}`, {
headers: { authorization: localStorage.getItem('token') },
})
.then(res => {
......@@ -56,7 +56,7 @@ function Write() {
console.log(values)
axios({
method: 'post',
url: '/writes',
url: '/api/writes',
data: values,
}).then(res => {
if (res.status === 404) return alert(res.data.error)
......
......@@ -22,12 +22,12 @@ app.use(cors())
console.log('path=', path.join(CURRENT_WORKING_DIR, 'client', 'build'))
app.use('/', express.static(path.join(CURRENT_WORKING_DIR, 'client', 'build')))
app.use('/', indexRouter);
app.use('/users', usersRouter, reservesRouter);
app.use('/login', loginRouter);
app.use('/reserves', reservesRouter);
app.use('/notices', noticeRouter);
app.use('/writes', writesRouter);
app.use('/api/', indexRouter);
app.use('/api/users', usersRouter, reservesRouter);
app.use('/api/login', loginRouter);
app.use('/api/reserves', reservesRouter);
app.use('/api/notices', noticeRouter);
app.use('/api/writes', writesRouter);
app.use((err, req, res, next) => {
if (err.name === 'UnauthorizedError') {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment