@@ -29,7 +29,7 @@ function CreateJobModal(props) {
2929 const title = formData . get ( "title" ) ;
3030 const description = formData . get ( "description" ) ;
3131 const location = formData . get ( "location" ) ;
32- const company_name = formData . get ( "company_name" )
32+ const company_name = formData . get ( "company_name" ) ;
3333 const data = {
3434 title,
3535 description,
@@ -39,28 +39,28 @@ function CreateJobModal(props) {
3939 max_salary,
4040 } ;
4141
42- await fetch ( "https://chapi.techstartucalgary.com/jobs" , {
43- method : "POST" ,
44- headers : {
45- "Content-Type" : "application/json" ,
46- Authorization : `Bearer ${ localStorage . getItem ( "access_token" ) } ` ,
47- } ,
48- body : JSON . stringify ( data ) ,
49- } )
42+ await fetch ( "https://chapi.techstartucalgary.com/jobs" , {
43+ method : "POST" ,
44+ headers : {
45+ "Content-Type" : "application/json" ,
46+ Authorization : `Bearer ${ localStorage . getItem ( "access_token" ) } ` ,
47+ } ,
48+ body : JSON . stringify ( data ) ,
49+ } )
5050 . then ( ( response ) => {
51- if ( ! response . ok ) {
52- if ( response . status === 401 ) {
53- window . location . href = "#/signin" ;
54- } else {
55- setShowGenericError ( true ) ;
56- }
57- throw new Error ( "Job creation failed" ) ;
51+ if ( ! response . ok ) {
52+ if ( response . status === 401 ) {
53+ window . location . href = "#/signin" ;
54+ } else {
55+ setShowGenericError ( true ) ;
5856 }
59- props . closeModal ( ) ;
60- } )
61- . catch ( ( error ) => {
62- console . error ( error ) ;
63- } ) ;
57+ throw new Error ( "Job creation failed" ) ;
58+ }
59+ props . closeModal ( ) ;
60+ } )
61+ . catch ( ( error ) => {
62+ console . error ( error ) ;
63+ } ) ;
6464 } ;
6565
6666 const formatCurrency = ( num ) => {
@@ -76,7 +76,7 @@ function CreateJobModal(props) {
7676 < DialogTitle > Create New Job</ DialogTitle >
7777 < form className = "form" onSubmit = { submitNewJob } >
7878 < TextField name = "title" label = "Job Title" required />
79- < TextField name = "company_name" label = "Company Name" required />
79+ < TextField name = "company_name" label = "Company Name" required />
8080 < TextField
8181 name = "description"
8282 label = "Job Description"
@@ -116,9 +116,7 @@ function CreateJobModal(props) {
116116 ) }
117117 </ div >
118118 < div className = "row right-align button-container" >
119- < Button variant = "outlined" /*onClick={cancelModal}*/ >
120- Cancel
121- </ Button >
119+ < Button variant = "outlined" /*onClick={cancelModal}*/ > Cancel</ Button >
122120 < Button type = "submit" variant = "contained" >
123121 { /*isEditing ? `Update Job` : `Post Job`*/ }
124122 </ Button >
0 commit comments