Skip to content
This repository was archived by the owner on Mar 13, 2025. It is now read-only.

feat: don't use time for Resource Bookings #152

Merged
merged 1 commit into from
Apr 22, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions src/routes/ResourceBookingForm/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import withAuthentication from "../../hoc/withAuthentication";
import TCForm from "../../components/TCForm";
import { getEditResourceBookingConfig } from "./utils";
import "./styles.module.scss";
import moment from "moment";

const ResourceBookingDetails = ({ teamId, resourceBookingId }) => {
const [submitting, setSubmitting] = useState(false);
Expand Down Expand Up @@ -66,8 +67,8 @@ const ResourceBookingDetails = ({ teamId, resourceBookingId }) => {

// as we are using `PUT` method (not `PATCH`) we have send ALL the fields
// fields which we don't send would become `null` otherwise
const getRequestData = (values) =>
_.pick(values, [
const getRequestData = (values) => {
const data = _.pick(values, [
"projectId",
"userId",
"jobId",
Expand All @@ -79,6 +80,17 @@ const ResourceBookingDetails = ({ teamId, resourceBookingId }) => {
"rateType",
]);

// convert dates to the API format before sending
if (data.startDate) {
data.startDate = moment(data.startDate).format('YYYY-MM-DD')
}
if (data.endDate) {
data.endDate = moment(data.endDate).format('YYYY-MM-DD')
}

return data
}

return (
<Page title="Edit Resource Booking">
{!formData ? (
Expand Down