@@ -13,6 +13,8 @@ import {
13
13
Select ,
14
14
Checkbox ,
15
15
VStack ,
16
+ Flex ,
17
+ Text ,
16
18
} from '@chakra-ui/react'
17
19
import dynamic from 'next/dynamic'
18
20
import { uniqBy , prop } from 'ramda'
@@ -44,12 +46,14 @@ export default function EditTeamForm({
44
46
initialValues,
45
47
onSubmit,
46
48
staff,
49
+ team,
47
50
isCreateForm,
48
51
orgTeamTags = [ ] ,
49
52
teamTags = [ ] ,
50
53
profileValues,
51
54
} ) {
52
55
const [ orgTeam , setOrgTeam ] = useState ( false )
56
+ const [ hasLocation , setHasLocation ] = useState ( initialValues . location )
53
57
if ( profileValues ) {
54
58
initialValues . tags = { }
55
59
profileValues . forEach ( ( { id, value } ) => {
@@ -83,13 +87,13 @@ export default function EditTeamForm({
83
87
}
84
88
if ( orgTeamTags . length > 0 ) {
85
89
extraOrgTeamFields = orgTeamTags . map (
86
- ( { id, name, required, description } ) => {
90
+ ( { id, name, key_type , required, description } ) => {
87
91
return (
88
92
< FormControl isRequired = { required } key = { `extra-tag-${ id } ` } >
89
93
< FormLabel htmlFor = { `extra-tag-${ id } ` } > { name } </ FormLabel >
90
94
< Field
91
95
as = { Input }
92
- type = 'text'
96
+ type = { key_type }
93
97
name = { `tags.key-${ id } ` }
94
98
id = { `extra-tag-${ id } ` }
95
99
required = { required }
@@ -106,13 +110,13 @@ export default function EditTeamForm({
106
110
107
111
if ( teamTags . length > 0 ) {
108
112
extraTeamFields = teamTags . map (
109
- ( { id, name, required, description } ) => {
113
+ ( { id, name, key_type , required, description } ) => {
110
114
return (
111
115
< FormControl isRequired = { required } key = { `extra-tag-${ id } ` } >
112
116
< FormLabel htmlFor = { `extra-tag-${ id } ` } > { name } </ FormLabel >
113
117
< Field
114
118
as = { Input }
115
- type = 'text'
119
+ type = { key_type }
116
120
name = { `tags.key-${ id } ` }
117
121
id = { `extra-tag-${ id } ` }
118
122
required = { required }
@@ -129,8 +133,8 @@ export default function EditTeamForm({
129
133
130
134
return (
131
135
< Form >
132
- < VStack alignItems = { 'flex-start' } >
133
- < Heading variant = 'sectionHead' > Details</ Heading >
136
+ < VStack alignItems = { 'flex-start' } spacing = { 4 } >
137
+ < Heading variant = 'sectionHead' > Team Details</ Heading >
134
138
< FormControl isRequired isInvalid = { errors . name } >
135
139
< FormLabel htmlFor = 'name' > Name</ FormLabel >
136
140
< Field
@@ -192,18 +196,20 @@ export default function EditTeamForm({
192
196
</ FormHelperText >
193
197
</ FormControl >
194
198
{ staff && isCreateForm && (
195
- < FormControl >
196
- < FormLabel htmlFor = 'orgTeam-checkbox' >
199
+ < FormControl pt = { 4 } >
200
+ < Flex alignItems = 'center' gap = { 2 } >
197
201
< Checkbox
198
202
id = 'orgTeam-checkbox'
199
203
name = 'orgTeam-checkbox'
200
204
type = 'checkbox'
201
- checked = { orgTeam }
205
+ isChecked = { orgTeam }
202
206
style = { { minWidth : '1rem' } }
203
207
onChange = { ( e ) => setOrgTeam ( e . target . checked ) }
204
208
/>
205
- This team belongs to an organization
206
- </ FormLabel >
209
+ < FormLabel htmlFor = 'orgTeam-checkbox' m = { 0 } >
210
+ This team belongs to an organization
211
+ </ FormLabel >
212
+ </ Flex >
207
213
{ orgTeam && (
208
214
< Field
209
215
as = { Select }
@@ -222,18 +228,29 @@ export default function EditTeamForm({
222
228
</ FormControl >
223
229
) }
224
230
{ extraOrgTeamFields . length > 0 ? (
225
- < >
226
- < Heading as = 'h3' size = 'sm' >
227
- Organization Attributes
231
+ < Flex
232
+ flexDir = 'column'
233
+ alignItems = 'flex-start'
234
+ border = { '1px' }
235
+ borderRadius = 'base'
236
+ p = { 8 }
237
+ borderColor = 'brand.50'
238
+ >
239
+ < Heading as = 'h3' size = 'sm' variant = 'sectionHead' >
240
+ { team . org ?. name } Details
228
241
</ Heading >
242
+ < Text fontSize = 'sm' pb = { 4 } >
243
+ Organization { team . org ?. name } requests the following
244
+ additional details
245
+ </ Text >
229
246
{ extraOrgTeamFields }
230
- </ >
247
+ </ Flex >
231
248
) : (
232
249
''
233
250
) }
234
251
{ extraTeamFields . length > 0 ? (
235
252
< >
236
- < Heading as = 'h3' size = 'sm' >
253
+ < Heading as = 'h3' size = 'sm' variant = 'sectionHead' >
237
254
Other Team Attributes
238
255
</ Heading >
239
256
{ extraTeamFields }
@@ -242,12 +259,32 @@ export default function EditTeamForm({
242
259
''
243
260
) }
244
261
< Heading variant = 'sectionHead' > Location</ Heading >
245
- < FormMap
246
- style = { { height : '300px' , width : '100%' } }
247
- name = 'location'
248
- value = { values . location }
249
- onChange = { setFieldValue }
250
- />
262
+ < FormControl >
263
+ < Flex alignItems = 'center' gap = { 2 } >
264
+ < Checkbox
265
+ id = 'hasLocation-checkbox'
266
+ name = 'hasLocation-checkbox'
267
+ type = 'checkbox'
268
+ isChecked = { hasLocation }
269
+ style = { { minWidth : '1rem' } }
270
+ onChange = { ( e ) => {
271
+ setHasLocation ( e . target . checked )
272
+ setFieldValue ( 'location' , null )
273
+ } }
274
+ />
275
+ < FormLabel htmlFor = 'hasLocation-checkbox' m = { 0 } >
276
+ This team has a location
277
+ </ FormLabel >
278
+ </ Flex >
279
+ </ FormControl >
280
+ { hasLocation && (
281
+ < FormMap
282
+ style = { { height : '300px' , width : '100%' } }
283
+ name = 'location'
284
+ value = { values . location }
285
+ onChange = { setFieldValue }
286
+ />
287
+ ) }
251
288
< FormControl >
252
289
< Button
253
290
isDisabled = { isSubmitting }
0 commit comments