@@ -47,6 +47,7 @@ export const UserProfileTab = () => {
47
47
< div className = "flex flex-col gap-10" >
48
48
< BioSection model = { model } updating = { updating } onChange = { setModel } />
49
49
< ContactSection model = { model } updating = { updating } onChange = { setModel } />
50
+ < WorkSection model = { model } updating = { updating } onChange = { setModel } />
50
51
< PrivacySection model = { model } updating = { updating } onChange = { setModel } />
51
52
< MapSection model = { model } onChange = { setModel } />
52
53
< SkillSection model = { model } updating = { updating } onChange = { setModel } />
@@ -56,12 +57,17 @@ export const UserProfileTab = () => {
56
57
57
58
const BioSection = ( { model, updating, onChange } : SectionProps ) => {
58
59
const [ bio , setBio ] = useState ( "" ) ;
59
- const [ pendingChanges , setPendingChanges ] = useState ( false ) ;
60
- const canSubmit = pendingChanges && ! updating ;
60
+ const [ name , setName ] = useState ( "" ) ;
61
+ const [ pendingChangesBio , setPendingChangesBio ] = useState ( false ) ;
62
+ const [ pendingChangesName , setPendingChangesName ] = useState ( false ) ;
63
+ const canSubmitBio = pendingChangesBio && ! updating ;
64
+ const canSubmitName = pendingChangesName && ! updating ;
61
65
62
66
useEffect ( ( ) => {
63
67
setBio ( model ?. bio ?? "" ) ;
64
- setPendingChanges ( false ) ;
68
+ setName ( model ?. name ?? "" ) ;
69
+ setPendingChangesBio ( false ) ;
70
+ setPendingChangesName ( false ) ;
65
71
} , [ model ] ) ;
66
72
67
73
return (
@@ -75,6 +81,7 @@ const BioSection = ({ model, updating, onChange }: SectionProps) => {
75
81
Zobrazit profil
76
82
</ a >
77
83
</ div >
84
+
78
85
< div className = "flex flex-col gap-2" >
79
86
< label htmlFor = "registrationEmail" className = "block" >
80
87
Registrační e-mail:
@@ -98,6 +105,31 @@ const BioSection = ({ model, updating, onChange }: SectionProps) => {
98
105
</ p >
99
106
</ div >
100
107
108
+ < div className = "flex flex-col gap-2" >
109
+ < label htmlFor = "name" className = "block" >
110
+ Jméno a příjmení:
111
+ </ label >
112
+ < input
113
+ id = "name"
114
+ className = "block w-full rounded-md border-2 border-gray p-2"
115
+ disabled = { ! model || updating }
116
+ defaultValue = { name }
117
+ onChange = { ( e ) => {
118
+ setName ( e . target . value ) ;
119
+ setPendingChangesName ( true ) ;
120
+ } }
121
+ />
122
+ < div >
123
+ < button
124
+ onClick = { ( ) => onChange ( { ...model ! , name } ) }
125
+ className = { clsx ( canSubmitName ? "btn-primary" : "btn-disabled" ) }
126
+ disabled = { ! canSubmitName }
127
+ >
128
+ Uložit jméno
129
+ </ button >
130
+ </ div >
131
+ </ div >
132
+
101
133
< div className = "flex flex-col gap-2" >
102
134
< label htmlFor = "bio-textarea" className = "block" >
103
135
Řekni něco málo o sobě, ať tě lidé lépe poznají:
@@ -111,16 +143,16 @@ const BioSection = ({ model, updating, onChange }: SectionProps) => {
111
143
defaultValue = { bio }
112
144
onChange = { ( e ) => {
113
145
setBio ( e . target . value ) ;
114
- setPendingChanges ( true ) ;
146
+ setPendingChangesBio ( true ) ;
115
147
} }
116
148
/>
117
149
< div >
118
150
< button
119
151
onClick = { ( ) => onChange ( { ...model ! , bio } ) }
120
- className = { clsx ( canSubmit ? "btn-primary" : "btn-disabled" ) }
121
- disabled = { ! canSubmit }
152
+ className = { clsx ( canSubmitBio ? "btn-primary" : "btn-disabled" ) }
153
+ disabled = { ! canSubmitBio }
122
154
>
123
- Uložit změny
155
+ Uložit text
124
156
</ button >
125
157
</ div >
126
158
</ div >
@@ -175,13 +207,133 @@ const ContactSection = ({ model, updating, onChange }: SectionProps) => {
175
207
className = { clsx ( canSubmit ? "btn-primary" : "btn-disabled" ) }
176
208
disabled = { ! canSubmit }
177
209
>
178
- Uložit změny
210
+ Uložit kontaktní email
179
211
</ button >
180
212
</ div >
181
213
</ section >
182
214
) ;
183
215
} ;
184
216
217
+ const WorkSection = ( { model, updating, onChange } : SectionProps ) => {
218
+ const occupationsOptions = {
219
+ "private-sector" : "Pracuji v soukromém sektoru" ,
220
+ "non-profit" : "Pracuji v neziskové organizaci" ,
221
+ state : "Pracuji ve státním sektoru" ,
222
+ freelancing : "Jsem na volné noze/freelancer" ,
223
+ studying : "Studuji" ,
224
+ "parental-leave" : "Jsem na rodičovské" ,
225
+ "looking-for-job" : "Hledám práci" ,
226
+ other : "Jiné" ,
227
+ } ;
228
+
229
+ const [ occupation , setOccupation ] = useState ( "" ) ;
230
+ const [ organization , setOrganization ] = useState ( "" ) ;
231
+ const [ url , setUrl ] = useState ( "" ) ;
232
+ const [ pendingChangesOrganization , setPendingChangesOrganization ] =
233
+ useState ( false ) ;
234
+ const [ pendingChangesUrl , setPendingChangesUrl ] = useState ( false ) ;
235
+ const canSubmitOrganization = pendingChangesOrganization && ! updating ;
236
+ const canSubmitUrl = pendingChangesUrl && ! updating ;
237
+
238
+ useEffect ( ( ) => {
239
+ setOccupation ( model ?. occupation ?? "" ) ;
240
+ setOrganization ( model ?. organizationName ?? "" ) ;
241
+ setUrl ( model ?. profileUrl ?? "" ) ;
242
+ setPendingChangesOrganization ( false ) ;
243
+ setPendingChangesUrl ( false ) ;
244
+ } , [ model ] ) ;
245
+
246
+ return (
247
+ < section className = "flex max-w-prose flex-col gap-4" >
248
+ < h2 className = "typo-title2" > Práce</ h2 >
249
+
250
+ < div className = "flex flex-col gap-2" >
251
+ < label htmlFor = "occupation" className = "block" >
252
+ Čemu se aktuálně věnuješ:
253
+ </ label >
254
+ < div >
255
+ { Object . entries ( occupationsOptions ) . map ( ( [ id , label ] ) => (
256
+ < label key = { id } className = "mb-1 flex items-center" >
257
+ < input
258
+ type = "radio"
259
+ className = "mr-3"
260
+ name = "occupation"
261
+ checked = { occupation == id }
262
+ disabled = { updating }
263
+ onChange = { ( ) =>
264
+ onChange ( {
265
+ ...model ! ,
266
+ occupation : id ,
267
+ } )
268
+ }
269
+ />
270
+ < span className = { occupation === id ? "font-bold" : "" } >
271
+ { label }
272
+ </ span >
273
+ </ label >
274
+ ) ) }
275
+ </ div >
276
+ </ div >
277
+
278
+ < div className = "flex flex-col gap-2" >
279
+ < label htmlFor = "organization" className = "block" >
280
+ Název organizace, kde působíš:
281
+ </ label >
282
+ < input
283
+ id = "organization"
284
+ className = "block w-full rounded-md border-2 border-gray p-2"
285
+ disabled = { ! model || updating }
286
+ defaultValue = { organization }
287
+ placeholder = "název firmy, neziskové organizace, státní instituce, …"
288
+ onChange = { ( e ) => {
289
+ setOrganization ( e . target . value ) ;
290
+ setPendingChangesOrganization ( true ) ;
291
+ } }
292
+ />
293
+ < div >
294
+ < button
295
+ onClick = { ( ) =>
296
+ onChange ( { ...model ! , organizationName : organization } )
297
+ }
298
+ className = { clsx (
299
+ canSubmitOrganization ? "btn-primary" : "btn-disabled" ,
300
+ ) }
301
+ disabled = { ! canSubmitOrganization }
302
+ >
303
+ Uložit organizaci
304
+ </ button >
305
+ </ div >
306
+ </ div >
307
+
308
+ < div className = "flex flex-col gap-2" >
309
+ < label htmlFor = "profileUrl" className = "block" >
310
+ Odkaz na tvůj web nebo profesní profil:
311
+ </ label >
312
+ < input
313
+ id = "profileUrl"
314
+ className = "block w-full rounded-md border-2 border-gray p-2"
315
+ disabled = { ! model || updating }
316
+ defaultValue = { url }
317
+ placeholder = "například LinkedIn, GitHub, Behance, About.me, …"
318
+ onChange = { ( e ) => {
319
+ setUrl ( e . target . value ) ;
320
+ setPendingChangesUrl ( true ) ;
321
+ } }
322
+ />
323
+ < div >
324
+ < button
325
+ onClick = { ( ) => onChange ( { ...model ! , profileUrl : url } ) }
326
+ className = { clsx ( canSubmitUrl ? "btn-primary" : "btn-disabled" ) }
327
+ disabled = { ! canSubmitUrl }
328
+ >
329
+ Uložit odkaz
330
+ </ button >
331
+ </ div >
332
+ </ div >
333
+ </ section >
334
+ ) ;
335
+ } ;
336
+
185
337
const PrivacySection = ( { model, updating, onChange } : SectionProps ) => {
186
338
const hasPublicProfile = model ?. privacyFlags . includes ( "enablePublicProfile" ) ;
187
339
0 commit comments