Toggle navigation
Toggle navigation
This project
Loading...
Sign in
2021-1-capstone-design1
/
RIT_Project1
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
1
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
박권수
2021-08-17 02:42:44 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
57810b68e8c56cda71b66f43885da6838471f315
57810b68
1 parent
b4a9151c
feat. api fix, login container complet
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
14 additions
and
17 deletions
web/src/api/api-auth.ts
web/src/api/api-doctor.ts
web/src/api/api-manager.ts
web/src/api/api-user.ts
web/src/views/login/LoginContainer.tsx
web/src/views/main/MainContainer.tsx
web/src/api/api-auth.ts
View file @
57810b6
import
{
client
}
from
"./client"
;
export
default
{
register
:
(
Data
:
FormData
)
=>
{
register
:
(
Data
:
any
)
=>
{
return
client
.
post
(
'/auth/register'
,
Data
);
},
registerDoctor
:
(
Data
:
FormData
)
=>
{
registerDoctor
:
(
Data
:
any
)
=>
{
return
client
.
post
(
'/auth/register/doctor'
,
Data
);
},
login
:
(
Data
:
FormData
)
=>
{
login
:
(
Data
:
any
)
=>
{
return
client
.
post
(
'/auth/login'
,
Data
);
},
...
...
web/src/api/api-doctor.ts
View file @
57810b6
...
...
@@ -23,21 +23,21 @@ export default {
},
});
},
writePatientInfo
:
(
token
:
RecoilState
<
any
>
,
Data
:
FormData
)
=>
{
writePatientInfo
:
(
token
:
RecoilState
<
any
>
,
Data
:
any
)
=>
{
return
client
.
patch
(
'/doctor/patient'
,
Data
,
{
headers
:
{
Authorization
:
token
,
},
});
},
writeBottleFeedback
:
(
token
:
RecoilState
<
any
>
,
Data
:
FormData
)
=>
{
writeBottleFeedback
:
(
token
:
RecoilState
<
any
>
,
Data
:
any
)
=>
{
return
client
.
post
(
'/doctor/bottle'
,
Data
,
{
headers
:
{
Authorization
:
token
,
},
});
},
registerPatient
:
(
token
:
RecoilState
<
any
>
,
Data
:
FormData
)
=>
{
registerPatient
:
(
token
:
RecoilState
<
any
>
,
Data
:
any
)
=>
{
return
client
.
post
(
'/doctor/patient'
,
Data
,
{
headers
:
{
Authorization
:
token
,
...
...
web/src/api/api-manager.ts
View file @
57810b6
...
...
@@ -16,14 +16,14 @@ export default {
},
});
},
acceotDoctorRegReq
:
(
token
:
RecoilState
<
any
>
,
Data
:
FormData
)
=>
{
acceotDoctorRegReq
:
(
token
:
RecoilState
<
any
>
,
Data
:
any
)
=>
{
return
client
.
post
(
'/manage/doctor/accept'
,
Data
,
{
headers
:
{
Authorization
:
token
,
},
});
},
rejectDoctorRegReq
:
(
token
:
RecoilState
<
any
>
,
Data
:
FormData
)
=>
{
rejectDoctorRegReq
:
(
token
:
RecoilState
<
any
>
,
Data
:
any
)
=>
{
return
client
.
post
(
'/manage/doctor/reject'
,
Data
,
{
headers
:
{
Authorization
:
token
,
...
...
web/src/api/api-user.ts
View file @
57810b6
...
...
@@ -16,7 +16,7 @@ export default {
},
});
},
acceptDoctorRegister
:
(
token
:
RecoilState
<
any
>
,
Data
:
FormData
)
=>
{
acceptDoctorRegister
:
(
token
:
RecoilState
<
any
>
,
Data
:
any
)
=>
{
return
client
.
post
(
'/user/doctorrequest/'
,
Data
,
{
headers
:
{
Authorization
:
token
,
...
...
web/src/views/login/LoginContainer.tsx
View file @
57810b6
...
...
@@ -18,6 +18,7 @@ const LoginContainer = (props : LoginProps) => {
password : '',
});
const [token, setToken] = useRecoilState(recoilUtil.token);
const [userType, setUserType] = useRecoilState(recoilUtil.userType);
const onSetUserId = (e : React.ChangeEvent<HTMLInputElement>) => {
setLoginForm({
...
...
@@ -34,14 +35,10 @@ const LoginContainer = (props : LoginProps) => {
};
const onLogin = async () => {
const data : FormData = new FormData();
data.append('userId', loginForm.userId);
data.append('password', loginForm.password);
try {
const result : any = await authApi.login(
data
);
if(result.
token
) {
setToken(result.token);
const result : any = await authApi.login(
loginForm
);
if(result.
statusText === 'OK'
) {
setToken(result.
data.
token);
props.history.push('/');
}
} catch(e) {
...
...
web/src/views/main/MainContainer.tsx
View file @
57810b6
...
...
@@ -17,7 +17,7 @@ const MainContainer = (props : MainProps) => {
const userType = useRecoilValue(recoilUtil.userType);
useEffect(() => {
if(!token || token.length) {
if(!token ||
!
token.length) {
props.history.push('/login');
}
}, []);
...
...
Please
register
or
login
to post a comment