@@ -17,6 +17,7 @@ export default function Signup() {
1717 species : preferences ?. species || 'Human' ,
1818 planet : preferences ?. planet || '' ,
1919 bio : preferences ?. bio || '' ,
20+ interests : preferences ?. interests || [ ] ,
2021 profilePic : preferences ?. profilePic || '' ,
2122 // Default preferences for now, will be updated on the next page
2223 limbs : preferences ?. limbs || 4 ,
@@ -25,6 +26,8 @@ export default function Signup() {
2526 maxDistanceAU : preferences ?. maxDistanceAU || 10 ,
2627 goals : preferences ?. goals || 'Long term fusion' ,
2728 } ) ;
29+ const [ interestInput , setInterestInput ] = useState ( '' ) ;
30+ const interestSuggestions = [ 'Stargazing' , 'Volcano Diving' , 'Heavy Metal (Literally)' , 'Asteroid Mining' ] ;
2831
2932 const handleSubmit = ( e : React . FormEvent ) => {
3033 e . preventDefault ( ) ;
@@ -40,6 +43,30 @@ export default function Signup() {
4043 } ) ) ;
4144 } ;
4245
46+ const addInterest = ( value : string ) => {
47+ const trimmed = value . trim ( ) ;
48+ if ( ! trimmed || formData . interests . includes ( trimmed ) || formData . interests . length >= 3 ) return ;
49+ setFormData ( prev => ( {
50+ ...prev ,
51+ interests : [ ...prev . interests , trimmed ]
52+ } ) ) ;
53+ setInterestInput ( '' ) ;
54+ } ;
55+
56+ const removeInterest = ( value : string ) => {
57+ setFormData ( prev => ( {
58+ ...prev ,
59+ interests : prev . interests . filter ( item => item !== value )
60+ } ) ) ;
61+ } ;
62+
63+ const handleInterestKeyDown = ( e : React . KeyboardEvent < HTMLInputElement > ) => {
64+ if ( e . key === 'Enter' ) {
65+ e . preventDefault ( ) ;
66+ addInterest ( interestInput ) ;
67+ }
68+ } ;
69+
4370 const handlePhotoClick = ( ) => {
4471 // Only open the file dialog if we don't already have a photo,
4572 // or if they click the overlay. (Actually, clicking the overlay could mean changing photo)
@@ -170,12 +197,7 @@ export default function Signup() {
170197 </ div >
171198 < div >
172199 < label style = { { display : 'block' , marginBottom : '8px' , fontSize : '0.9rem' } } > Species:</ label >
173- < select name = "species" value = { formData . species } onChange = { handleChange } >
174- < option value = "Human" > Human</ option >
175- < option value = "Alien" > Alien</ option >
176- < option value = "Hybrid" > Hybrid</ option >
177- < option value = "Open to all" > Open to all</ option >
178- </ select >
200+ < input type = "text" name = "species" value = { formData . species } onChange = { handleChange } placeholder = "Type your species" />
179201 </ div >
180202 </ div >
181203
@@ -203,6 +225,60 @@ export default function Signup() {
203225 } }
204226 />
205227 </ div >
228+
229+ < div >
230+ < div style = { { display : 'flex' , justifyContent : 'space-between' , alignItems : 'center' , marginBottom : '8px' } } >
231+ < label style = { { fontSize : '0.9rem' } } > Interests:</ label >
232+ < span style = { { fontSize : '0.8rem' , color : 'rgba(234, 222, 218, 0.7)' } } > Up to 3</ span >
233+ </ div >
234+ < input
235+ type = "text"
236+ value = { interestInput }
237+ onChange = { e => setInterestInput ( e . target . value ) }
238+ onKeyDown = { handleInterestKeyDown }
239+ placeholder = "Type an interest and press Enter"
240+ />
241+ < div style = { { display : 'flex' , flexWrap : 'wrap' , gap : '8px' , margin : '12px 0' } } >
242+ { formData . interests . map ( interest => (
243+ < button
244+ type = "button"
245+ key = { interest }
246+ onClick = { ( ) => removeInterest ( interest ) }
247+ style = { {
248+ padding : '8px 12px' ,
249+ borderRadius : '999px' ,
250+ border : '1px solid rgba(255,255,255,0.2)' ,
251+ background : 'rgba(255,255,255,0.08)' ,
252+ color : 'white' ,
253+ cursor : 'pointer'
254+ } }
255+ >
256+ { interest } ×
257+ </ button >
258+ ) ) }
259+ </ div >
260+ < div style = { { display : 'flex' , flexWrap : 'wrap' , gap : '8px' } } >
261+ { interestSuggestions
262+ . filter ( suggestion => ! formData . interests . includes ( suggestion ) )
263+ . map ( suggestion => (
264+ < button
265+ type = "button"
266+ key = { suggestion }
267+ onClick = { ( ) => addInterest ( suggestion ) }
268+ style = { {
269+ padding : '8px 12px' ,
270+ borderRadius : '999px' ,
271+ border : '1px solid rgba(255,255,255,0.2)' ,
272+ background : 'rgba(255,255,255,0.05)' ,
273+ color : 'rgba(234, 222, 218, 0.9)' ,
274+ cursor : 'pointer'
275+ } }
276+ >
277+ { suggestion }
278+ </ button >
279+ ) ) }
280+ </ div >
281+ </ div >
206282
207283 < div style = { { marginTop : '16px' } } >
208284 < button type = "submit" className = "btn-primary" style = { { width : '100%' } } > Next</ button >
0 commit comments