@@ -50,7 +50,7 @@ export default function EditProjectPage() {
5050 description : '' ,
5151 longDescription : '' ,
5252 organization : '' ,
53- repositoryUrl : '' ,
53+ repositoryUrls : [ '' ] ,
5454 websiteUrl : '' ,
5555 timelineUrl : '' ,
5656 difficulty : 'intermediate' ,
@@ -110,7 +110,9 @@ export default function EditProjectPage() {
110110 description : project . description || '' ,
111111 longDescription : project . longDescription || '' ,
112112 organization : project . organization || '' ,
113- repositoryUrl : project . repositoryUrl || '' ,
113+ repositoryUrls : Array . isArray ( project . repositoryUrls ) && project . repositoryUrls . length > 0
114+ ? project . repositoryUrls
115+ : ( project . repositoryUrl ? [ project . repositoryUrl ] : [ '' ] ) ,
114116 websiteUrl : project . websiteUrl || '' ,
115117 timelineUrl : project . timelineUrl || '' ,
116118 difficulty : project . difficulty || 'intermediate' ,
@@ -146,7 +148,7 @@ export default function EditProjectPage() {
146148 setFormData ( { ...formData , [ e . target . name ] : e . target . value } ) ;
147149 } ;
148150
149- const handleArrayChange = ( field : 'requirements' | 'learningOutcomes' , index : number , value : string ) => {
151+ const handleArrayChange = ( field : 'requirements' | 'learningOutcomes' | 'repositoryUrls' , index : number , value : string ) => {
150152 const updated = [ ...formData [ field ] ] ;
151153 updated [ index ] = value ;
152154 setFormData ( { ...formData , [ field ] : updated } ) ;
@@ -165,11 +167,11 @@ export default function EditProjectPage() {
165167 } ) ;
166168 } ;
167169
168- const addArrayItem = ( field : 'requirements' | 'learningOutcomes' ) => {
170+ const addArrayItem = ( field : 'requirements' | 'learningOutcomes' | 'repositoryUrls' ) => {
169171 setFormData ( { ...formData , [ field ] : [ ...formData [ field ] , '' ] } ) ;
170172 } ;
171173
172- const removeArrayItem = ( field : 'requirements' | 'learningOutcomes' , index : number ) => {
174+ const removeArrayItem = ( field : 'requirements' | 'learningOutcomes' | 'repositoryUrls' , index : number ) => {
173175 const updated = formData [ field ] . filter ( ( _ , i ) => i !== index ) ;
174176 setFormData ( { ...formData , [ field ] : updated } ) ;
175177 } ;
@@ -272,7 +274,7 @@ export default function EditProjectPage() {
272274 description : formData . description ,
273275 longDescription : formData . longDescription ,
274276 organization : formData . organization ,
275- repositoryUrl : formData . repositoryUrl ,
277+ repositoryUrls : formData . repositoryUrls . filter ( Boolean ) ,
276278 websiteUrl : formData . websiteUrl ,
277279 timelineUrl : formData . timelineUrl ,
278280 difficulty : formData . difficulty ,
@@ -477,32 +479,52 @@ export default function EditProjectPage() {
477479
478480 { /* Links */ }
479481 < div className = "space-y-4" >
480- < h2 className = "font-bold text-lg border-b-2 border-[var(--dsoc-dark)] pb-2" > Links</ h2 >
481-
482- < div className = "grid md:grid-cols-2 gap-4" >
483- < div >
484- < label className = "block font-bold text-sm mb-2" > Repository URL *</ label >
485- < input
486- type = "url"
487- name = "repositoryUrl"
488- value = { formData . repositoryUrl }
489- onChange = { handleChange }
490- required
491- className = "neo-brutal-input"
492- placeholder = "https://github.com/org/repo"
493- />
494- </ div >
495- < div >
496- < label className = "block font-bold text-sm mb-2" > Website URL</ label >
497- < input
498- type = "url"
499- name = "websiteUrl"
500- value = { formData . websiteUrl }
501- onChange = { handleChange }
502- className = "neo-brutal-input"
503- placeholder = "https://example.com"
504- />
505- </ div >
482+ < h2 className = "font-bold text-lg border-b-2 border-[var(--dsoc-dark)] pb-2" > Links & Repositories </ h2 >
483+
484+ < div className = "space-y-3" >
485+ < label className = "block font-bold text-sm" > Repository URLs * (At least one is required)</ label >
486+ { formData . repositoryUrls . map ( ( repoUrl , index ) => (
487+ < div key = { index } className = "flex gap-2" >
488+ < input
489+ type = "url"
490+ value = { repoUrl }
491+ onChange = { ( e ) => handleArrayChange ( 'repositoryUrls' , index , e . target . value ) }
492+ required = { index === 0 }
493+ className = "neo-brutal-input flex-1"
494+ placeholder = "https://github.com/org/repo"
495+ />
496+ { formData . repositoryUrls . length > 1 && (
497+ < button
498+ type = "button"
499+ onClick = { ( ) => removeArrayItem ( 'repositoryUrls' , index ) }
500+ className = "p-3 bg-[var(--dsoc-pink)] text-white border-4 border-[var(--dsoc-dark)]"
501+ >
502+ < Trash2 className = "w-5 h-5" />
503+ </ button >
504+ ) }
505+ </ div >
506+ ) ) }
507+
508+ < button
509+ type = "button"
510+ onClick = { ( ) => addArrayItem ( 'repositoryUrls' ) }
511+ className = "inline-flex items-center gap-2 px-4 py-2 bg-[var(--dsoc-success)] text-white font-bold border-4 border-[var(--dsoc-dark)] hover:translate-x-1 transition-transform text-sm"
512+ >
513+ < Plus className = "w-4 h-4" />
514+ Add Repository URL
515+ </ button >
516+ </ div >
517+
518+ < div >
519+ < label className = "block font-bold text-sm mb-2" > Website URL</ label >
520+ < input
521+ type = "url"
522+ name = "websiteUrl"
523+ value = { formData . websiteUrl }
524+ onChange = { handleChange }
525+ className = "neo-brutal-input"
526+ placeholder = "https://example.com"
527+ />
506528 </ div >
507529 </ div >
508530
0 commit comments