@@ -104,6 +104,50 @@ function Form(props: FormProps) {
104104 return urlParts [ urlParts . length - 1 ] ;
105105 } , [ ] ) ;
106106
107+ useEffect ( ( ) => {
108+ const urlParams = new URLSearchParams ( window . location . search ) ;
109+ const prefillParam = urlParams . get ( 'prefill' ) ;
110+ const action = urlParams . get ( 'action' ) ;
111+
112+ if ( action === 'create' && prefillParam ) {
113+ try {
114+ const decoded = JSON . parse ( atob ( prefillParam ) ) ;
115+
116+ const mapHoursToSession = ( hours : number ) : string => {
117+ if ( hours <= 1 ) return '1 hour' ;
118+ if ( hours <= 3 ) return '3 hours' ;
119+ if ( hours <= 8 ) return '8 hours' ;
120+ if ( hours <= 24 ) return '24 hours' ;
121+ if ( hours <= 48 ) return '48 hours' ;
122+ return '72 hours' ;
123+ } ;
124+
125+ const mappedData : any = {
126+ one_sentence_summary : decoded . title || '' ,
127+ description : decoded . description || '' ,
128+ wanted_type : 'Web development'
129+ } ;
130+
131+ if ( decoded . estimatedHours ) {
132+ mappedData . estimated_session_length = mapHoursToSession ( decoded . estimatedHours ) ;
133+ }
134+
135+ if ( decoded . repositoryUrl ) {
136+ mappedData . ticket_url = decoded . repositoryUrl ;
137+ }
138+
139+ setDynamicSchemaName ( 'freelance_job_request' ) ;
140+ setDynamicSchema ( dynamicSchemasByType [ 'freelance_job_request' ] ) ;
141+ setDynamicInitialValues ( mappedData ) ;
142+ setStepTracker ( 2 ) ;
143+
144+ window . history . replaceState ( { } , '' , '/bounties?action=create' ) ;
145+ } catch ( error ) {
146+ console . error ( 'Failed to parse prefill data:' , error ) ;
147+ }
148+ }
149+ } , [ ] ) ;
150+
107151 useEffect ( ( ) => {
108152 async function fetchWorkspaces ( ) {
109153 if ( ui . meInfo ?. id ) {
@@ -346,6 +390,7 @@ function Form(props: FormProps) {
346390 onSubmit = { props . onSubmit }
347391 innerRef = { props . formRef }
348392 validationSchema = { validator ( schema ) }
393+ enableReinitialize = { true }
349394 >
350395 { ( { setFieldTouched, handleSubmit, values, setFieldValue, errors, initialValues } : any ) => {
351396 const isDescriptionValid = values . ticket_url
0 commit comments