Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F92093587
searchJournalFields.js
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sun, Nov 17, 07:20
Size
1 KB
Mime Type
text/x-java
Expires
Tue, Nov 19, 07:20 (2 d)
Engine
blob
Format
Raw Data
Handle
22375299
Attached To
rOACCT Open Access Compliance Check Tool (OACCT)
searchJournalFields.js
View Options
import
React
,
{
useState
}
from
'react'
;
import
{
makeStyles
}
from
'@material-ui/core/styles'
;
import
Button
from
'@material-ui/core/Button'
;
import
Input
from
'@material-ui/core/Input'
;
import
API
from
'../api'
;
import
JournalCard
from
"./journalCard"
const
useStyles
=
makeStyles
((
theme
)
=>
({
root
:
{
'& > *'
:
{
margin
:
theme
.
spacing
(
1
),
display
:
'grid'
,
},
}
}));
export
default
function
SearchJournalFields
()
{
const
classes
=
useStyles
();
//declare state hook for functional component
const
[
query
,
setQuery
]
=
useState
(
''
);
//query storage
const
[
journals
,
setJournals
]
=
useState
([]);
const
searchJournals
=
(
e
)
=>
{
e
.
preventDefault
();
// console.log("submitting");
// const query = "name"; test purpose
API
.
get
(
`
journal
/?
search
=
$
{
query
}
`
)
.
then
(
res
=>
{
const
data
=
res
.
data
;
setJournals
(
data
);
console
.
log
(
data
);
})
}
return
(
<>
<
form
style
=
{{
marginTop
:
"8rem"
}}
className
=
{
classes
.
root
}
noValidate
autoComplete
=
"on"
onSubmit
=
{
searchJournals
}
color
=
"inherit"
>
<
Input
type
=
'text '
name
=
"query"
placeholder
=
"Enter Journal Title or ISSN"
value
=
{
query
}
onChange
=
{(
e
)
=>
setQuery
(
e
.
target
.
value
)}
inputProps
=
{{
'object'
:
'description'
}}
/>
<
Button
style
=
{{
width
:
'99%'
}}
variant
=
"contained"
color
=
"secondary"
type
=
"submit"
>
Search
<
/Button>
<
/form>
<
div
className
=
"card-list"
style
=
{{
marginTop
:
"4rem"
}}
>
{
journals
.
map
(
journal
=>
(
<
JournalCard
journal
=
{
journal
}
key
=
{
journal
.
id
}
/>
))}
<
/div>
<
/>
);
}
Event Timeline
Log In to Comment