This repository was archived by the owner on Mar 13, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +14
-2
lines changed
src/routes/ResourceBookingForm Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ import withAuthentication from "../../hoc/withAuthentication";
2121import TCForm from "../../components/TCForm" ;
2222import { getEditResourceBookingConfig } from "./utils" ;
2323import "./styles.module.scss" ;
24+ import moment from "moment" ;
2425
2526const ResourceBookingDetails = ( { teamId, resourceBookingId } ) => {
2627 const [ submitting , setSubmitting ] = useState ( false ) ;
@@ -66,8 +67,8 @@ const ResourceBookingDetails = ({ teamId, resourceBookingId }) => {
6667
6768 // as we are using `PUT` method (not `PATCH`) we have send ALL the fields
6869 // fields which we don't send would become `null` otherwise
69- const getRequestData = ( values ) =>
70- _ . pick ( values , [
70+ const getRequestData = ( values ) => {
71+ const data = _ . pick ( values , [
7172 "projectId" ,
7273 "userId" ,
7374 "jobId" ,
@@ -79,6 +80,17 @@ const ResourceBookingDetails = ({ teamId, resourceBookingId }) => {
7980 "rateType" ,
8081 ] ) ;
8182
83+ // convert dates to the API format before sending
84+ if ( data . startDate ) {
85+ data . startDate = moment ( data . startDate ) . format ( 'YYYY-MM-DD' )
86+ }
87+ if ( data . endDate ) {
88+ data . endDate = moment ( data . endDate ) . format ( 'YYYY-MM-DD' )
89+ }
90+
91+ return data
92+ }
93+
8294 return (
8395 < Page title = "Edit Resource Booking" >
8496 { ! formData ? (
You can’t perform that action at this time.
0 commit comments