@@ -32,63 +32,82 @@ import { useGlobalContext } from '../../context/DataContext';
3232const AddJournal = ( ) => {
3333 const {
3434 title,
35- setTitle,
3635 authors,
37- setAuthors,
3836 journaltype,
39- setJournaltype,
4037 topic,
41- setTopic,
4238 issn,
43- setIssn,
4439 link,
45- setLink,
4640 policy,
47- setPolicy,
4841 dataavail,
49- setDataavail,
5042 handleChangeData,
5143 datashared,
52- setDatashared,
5344 handleChangeData2,
5445 peerreview,
55- setPeerreview,
5646 handleChangePeer,
5747 enforced,
58- setEnforced,
5948 evidence,
60- setEvidence,
6149 isPending,
6250 handleSubmit,
51+ dispatch,
6352 } = useGlobalContext ( ) ;
6453 return (
6554 < Container >
6655 < PolicyContainer >
6756 < Head > Create Journal Policies</ Head >
6857 < Form onSubmit = { handleSubmit } >
6958 < Label > Journal titile</ Label >
70- < Input type = 'text' required value = { title } onChange = { ( e ) => setTitle ( e . target . value ) } />
59+ < Input
60+ type = 'text'
61+ required
62+ value = { title }
63+ onChange = { ( e ) =>
64+ dispatch ( {
65+ type : 'SET_TITLE' ,
66+ payload : e . target . value ,
67+ } )
68+ }
69+ />
7170 < FirstDiv >
7271 < div >
7372 < Label > Journal Type</ Label >
7473 < Input
7574 type = 'text'
7675 required
7776 value = { journaltype }
78- onChange = { ( e ) => setJournaltype ( e . target . value ) }
77+ onChange = { ( e ) =>
78+ dispatch ( {
79+ type : 'SET_JOURNALTYPE' ,
80+ payload : e . target . value ,
81+ } )
82+ }
7983 />
8084 </ div >
8185 < div >
8286 < Label > ISSN Number</ Label >
83- < Input type = 'text' required value = { issn } onChange = { ( e ) => setIssn ( e . target . value ) } />
87+ < Input
88+ type = 'text'
89+ required
90+ value = { issn }
91+ onChange = { ( e ) =>
92+ dispatch ( {
93+ type : 'SET_ISSN' ,
94+ payload : e . target . value ,
95+ } )
96+ }
97+ />
8498 </ div >
8599 < div >
86100 < Label > Enforced Evidence</ Label >
87101 < Input
88102 type = 'text'
89103 required
90104 value = { evidence }
91- onChange = { ( e ) => setEvidence ( e . target . value ) }
105+ onChange = { ( e ) =>
106+ dispatch ( {
107+ type : 'SET_EVIDENCE' ,
108+ payload : e . target . value ,
109+ } )
110+ }
92111 />
93112 </ div >
94113 </ FirstDiv >
@@ -99,20 +118,40 @@ const AddJournal = () => {
99118 type = 'text'
100119 required
101120 value = { topic }
102- onChange = { ( e ) => setTopic ( e . target . value ) }
121+ onChange = { ( e ) =>
122+ dispatch ( {
123+ type : 'SET_TOPIC' ,
124+ payload : e . target . value ,
125+ } )
126+ }
103127 />
104128 </ div >
105129 < div >
106130 < Label > Source</ Label >
107- < Input type = 'text' required value = { link } onChange = { ( e ) => setLink ( e . target . value ) } />
131+ < Input
132+ type = 'text'
133+ required
134+ value = { link }
135+ onChange = { ( e ) =>
136+ dispatch ( {
137+ type : 'SET_LINK' ,
138+ payload : e . target . value ,
139+ } )
140+ }
141+ />
108142 </ div >
109143 < div >
110144 < Label > Authors</ Label >
111145 < Input
112146 type = 'text'
113147 required
114148 value = { authors }
115- onChange = { ( e ) => setAuthors ( e . target . value ) }
149+ onChange = { ( e ) =>
150+ dispatch ( {
151+ type : 'SET_AUTHORS' ,
152+ payload : e . target . value ,
153+ } )
154+ }
116155 />
117156 </ div >
118157 </ FirstDiv >
@@ -126,15 +165,31 @@ const AddJournal = () => {
126165 < SecondDiv >
127166 < div >
128167 < Label > Policy Type:</ Label >
129- < Select value = { policy } onChange = { ( e ) => setPolicy ( e . target . value ) } >
168+ < Select
169+ value = { policy }
170+ onChange = { ( e ) =>
171+ dispatch ( {
172+ type : 'SET_POLICY' ,
173+ payload : e . target . value ,
174+ } )
175+ }
176+ >
130177 < option value = 'policy 1' > Policy 1</ option >
131178 < option value = 'policy 2' > Policy 2</ option >
132179 < option value = 'policy 3' > Policy 3</ option >
133180 </ Select >
134181 </ div >
135182 < div >
136183 < Label > Enforced:</ Label >
137- < Select value = { enforced } onChange = { ( e ) => setEnforced ( e . target . value ) } >
184+ < Select
185+ value = { enforced }
186+ onChange = { ( e ) =>
187+ dispatch ( {
188+ type : 'ENFORCED' ,
189+ payload : e . target . value ,
190+ } )
191+ }
192+ >
138193 < option value = 'Yes - before publication' > Yes - before publication</ option >
139194 < option value = 'option 2' > Option 2</ option >
140195 </ Select >
0 commit comments