Toggle navigation
Toggle navigation
This project
Loading...
Sign in
HyeonJun Jeon
/
Extended-Calendar
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
HyeonJun Jeon
2022-05-29 14:16:45 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
3420ec67ec2178488ea78bfd6f799c5dee84f966
3420ec67
1 parent
e3c94782
[Add] Login test
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
58 additions
and
8 deletions
src/libs/E_Campus.js
src/pages/Debug.js
src/styles/Debug.css
src/libs/E_Campus.js
View file @
3420ec6
function
login
(
id
,
pw
)
{
return
`I got data { id:"
${
id
}
" pw:"
${
pw
}
" }`
;
}
export
{
login
};
...
...
src/pages/Debug.js
View file @
3420ec6
import
{
useState
}
from
"react"
;
import
{
useNavigate
}
from
"react-router-dom"
;
import
{
login
}
from
"../libs/E_Campus"
;
import
"../styles/Debug.css"
;
import
{
initTempSubjects
}
from
"../utils/Test"
;
const
Debug
=
()
=>
{
const
[
state
,
setState
]
=
useState
({
input
:
""
,
output
:
""
});
const
[
state
,
setState
]
=
useState
({
type
:
"login"
,
input1
:
""
,
input2
:
""
,
output
:
""
,
});
const
handleChangeState
=
(
e
)
=>
{
setState
({
...
...
@@ -13,10 +21,18 @@ const Debug = () => {
};
const
handleSubmit
=
async
(
e
)
=>
{
if
(
state
.
input
===
"init"
)
await
initTempSubjects
();
const
result
=
state
.
input
;
let
result
;
switch
(
state
.
type
)
{
case
"initSubjects"
:
await
initTempSubjects
();
result
=
"inited"
;
break
;
case
"login"
:
result
=
login
(
state
.
input1
,
state
.
input2
);
break
;
default
:
}
console
.
log
(
result
);
setState
({
...
state
,
output
:
result
});
};
...
...
@@ -33,10 +49,28 @@ const Debug = () => {
Home
<
/button
>
<
/div
>
<
div
className
=
"dd"
>
<
div
>
<
span
>
type
:
<
/span
>
<
select
name
=
"type"
value
=
{
state
.
type
}
onChange
=
{
handleChangeState
}
>
<
option
value
=
{
"initSubjects"
}
>
initSubjects
<
/option
>
<
option
value
=
{
"login"
}
>
login
<
/option
>
<
/select
>
<
/div
>
<
input
value
=
{
state
.
input
}
onChange
=
{
handleChangeState
}
name
=
"input"
/>
<
button
onClick
=
{
handleSubmit
}
>
Enter
<
/button
>
<
div
>
{
"result : "
+
state
.
output
}
<
/div
>
<
input
value
=
{
state
.
input1
}
onChange
=
{
handleChangeState
}
name
=
"input1"
/>
<
input
value
=
{
state
.
input2
}
onChange
=
{
handleChangeState
}
name
=
"input2"
/>
<
button
onClick
=
{
handleSubmit
}
>
Enter
<
/button
>
<
div
>
{
"result : \n"
+
state
.
output
}
<
/div
>
<
/div
>
<
/div
>
);
};
...
...
src/styles/Debug.css
0 → 100644
View file @
3420ec6
.dd
{
display
:
flex
;
flex-direction
:
column
;
width
:
300px
;
margin
:
10px
0
10px
0
;
}
.dd
>
div
,
.dd
>
span
{
margin
:
5px
0
5px
0
;
}
Please
register
or
login
to post a comment