From 9e433e6c798dad8234a10b0848ec567ca80eb803 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Palma?= Date: Tue, 4 Apr 2023 15:37:14 +0100 Subject: [PATCH] feature: companies can now quick edit their offers --- .../Offers/Manage/CollapsedQuickOfferEdit.js | 40 +++ .../Offers/Manage/CompanyOffersActions.js | 11 + .../Manage/CompanyOffersManagementWidget.js | 170 +++++---- .../CompanyOffersManagementWidget.spec.js | 335 +++++++++++++----- .../Offers/Manage/QuickOfferEditForm.js | 100 ++++++ .../PublicationEndDateComponent.js | 29 +- src/hooks/useOfferForm.js | 4 +- 7 files changed, 525 insertions(+), 164 deletions(-) create mode 100644 src/components/Company/Offers/Manage/CollapsedQuickOfferEdit.js create mode 100644 src/components/Company/Offers/Manage/QuickOfferEditForm.js diff --git a/src/components/Company/Offers/Manage/CollapsedQuickOfferEdit.js b/src/components/Company/Offers/Manage/CollapsedQuickOfferEdit.js new file mode 100644 index 00000000..a0aa4bb4 --- /dev/null +++ b/src/components/Company/Offers/Manage/CollapsedQuickOfferEdit.js @@ -0,0 +1,40 @@ +import React, { useState } from "react"; +import PropTypes from "prop-types"; +import { Box, Button, Collapse, Typography } from "@material-ui/core"; +import { KeyboardArrowDown, KeyboardArrowUp } from "@material-ui/icons"; +import { QuickOfferEditForm } from "./QuickOfferEditForm"; + +const CollapsedQuickOfferEdit = ({ offerId, isMobile }) => { + const [collapse, setCollapse] = useState(false); + + return isMobile ? ( + <> + + Quick Edit Offer + + + + ); +}; + +QuickOfferEditForm.propTypes = { + offerId: PropTypes.string.isRequired, + showTitle: PropTypes.bool.isRequired, +}; diff --git a/src/components/Offers/Form/form-components/PublicationEndDateComponent.js b/src/components/Offers/Form/form-components/PublicationEndDateComponent.js index 6056845a..20187e33 100644 --- a/src/components/Offers/Form/form-components/PublicationEndDateComponent.js +++ b/src/components/Offers/Form/form-components/PublicationEndDateComponent.js @@ -5,7 +5,9 @@ import { KeyboardDatePicker } from "@material-ui/pickers"; import { Tooltip } from "@material-ui/core"; import { Info } from "@material-ui/icons"; -const PublicationEndDateComponent = ({ fields, disabled, errors, requestErrors, control, datePickerProps }) => ( +const PublicationEndDateComponent = ({ + fields, disabled, errors, requestErrors, control, datePickerProps, showInfoTooltip = true, +}) => ( <> )} control={control} /> - - - + {showInfoTooltip ? + + + + + : "" + } ); @@ -55,6 +61,7 @@ PublicationEndDateComponent.propTypes = { requestErrors: PropTypes.object, control: PropTypes.object.isRequired, datePickerProps: PropTypes.object, + showInfoTooltip: PropTypes.bool, }; export default PublicationEndDateComponent; diff --git a/src/hooks/useOfferForm.js b/src/hooks/useOfferForm.js index 03d1cb06..e2d4f173 100644 --- a/src/hooks/useOfferForm.js +++ b/src/hooks/useOfferForm.js @@ -7,7 +7,7 @@ import useTechSelector from "../components/utils/offers/useTechSelector"; import { INITIAL_JOB_DURATION } from "../reducers/searchOffersReducer"; import useSession from "./useSession"; -export default (schema) => { +export default (schema, overrideDefaultValues) => { const { handleSubmit, formState, control, setValue, getValues, clearErrors, reset } = useForm({ mode: "all", resolver: yupResolver(schema), @@ -15,7 +15,7 @@ export default (schema) => { defaultValues: { title: "", publishDate: defaultDates.getPublishDate(), - publishEndDate: defaultDates.getPublishEndDate(), + publishEndDate: overrideDefaultValues?.publishEndDate ?? defaultDates.getPublishEndDate(), jobDuration: [INITIAL_JOB_DURATION, INITIAL_JOB_DURATION + 1], jobStartDate: null, description: "",