Skip to content

Commit

Permalink
fix: publishStartDate on quickEditOfferForm is now correct one
Browse files Browse the repository at this point in the history
  • Loading branch information
tomaspalma committed Feb 7, 2024
1 parent c97421a commit aa89a72
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 72 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,27 +31,29 @@ import CollapsedQuickOfferEdit from "./CollapsedQuickOfferEdit";
const generateRow = ({
title, location, publishDate, publishEndDate, isHidden, isArchived, hiddenReason,
ownerName, getOfferVisibility, setOfferVisibility, offerId, _id, ...args }) => ({
fields: {
title: { value: (
<OfferTitle
title={title}
getOfferVisibility={getOfferVisibility}
offerId={offerId}
/>), align: "left", linkDestination: `/offer/${_id}` },
publishStartDate: { value: format(parseISO(publishDate), "yyyy-MM-dd") },
publishEndDate: { value: format(parseISO(publishEndDate), "yyyy-MM-dd") },
location: { value: location },
},
payload: {
offer: new Offer({
title, location, publishDate, publishEndDate, isHidden,
isArchived, hiddenReason, ownerName, _id, ...args,
}),
getOfferVisibility: getOfferVisibility,
setOfferVisibility: setOfferVisibility,
offerId: offerId,
},
});
fields: {

Check failure on line 34 in src/components/Company/Offers/Manage/CompanyOffersManagementWidget.js

View workflow job for this annotation

GitHub Actions / build

Expected indentation of 4 spaces but found 8
title: {

Check failure on line 35 in src/components/Company/Offers/Manage/CompanyOffersManagementWidget.js

View workflow job for this annotation

GitHub Actions / build

Expected indentation of 8 spaces but found 12
value: (

Check failure on line 36 in src/components/Company/Offers/Manage/CompanyOffersManagementWidget.js

View workflow job for this annotation

GitHub Actions / build

Expected indentation of 12 spaces but found 16
<OfferTitle

Check failure on line 37 in src/components/Company/Offers/Manage/CompanyOffersManagementWidget.js

View workflow job for this annotation

GitHub Actions / build

Expected indentation of 16 spaces but found 20
title={title}

Check failure on line 38 in src/components/Company/Offers/Manage/CompanyOffersManagementWidget.js

View workflow job for this annotation

GitHub Actions / build

Expected indentation of 20 spaces but found 24
getOfferVisibility={getOfferVisibility}

Check failure on line 39 in src/components/Company/Offers/Manage/CompanyOffersManagementWidget.js

View workflow job for this annotation

GitHub Actions / build

Expected indentation of 20 spaces but found 24
offerId={offerId}

Check failure on line 40 in src/components/Company/Offers/Manage/CompanyOffersManagementWidget.js

View workflow job for this annotation

GitHub Actions / build

Expected indentation of 20 spaces but found 24
/>), align: "left", linkDestination: `/offer/${_id}`

Check failure on line 41 in src/components/Company/Offers/Manage/CompanyOffersManagementWidget.js

View workflow job for this annotation

GitHub Actions / build

Expected indentation of 16 spaces but found 20

Check failure on line 41 in src/components/Company/Offers/Manage/CompanyOffersManagementWidget.js

View workflow job for this annotation

GitHub Actions / build

Missing trailing comma
},

Check failure on line 42 in src/components/Company/Offers/Manage/CompanyOffersManagementWidget.js

View workflow job for this annotation

GitHub Actions / build

Expected indentation of 8 spaces but found 12
publishStartDate: { value: format(parseISO(publishDate), "yyyy-MM-dd") },
publishEndDate: { value: format(parseISO(publishEndDate), "yyyy-MM-dd") },
location: { value: location },
},
payload: {
offer: new Offer({
title, location, publishDate, publishEndDate, isHidden,
isArchived, hiddenReason, ownerName, _id, ...args,
}),
getOfferVisibility: getOfferVisibility,
setOfferVisibility: setOfferVisibility,
offerId: offerId,
},
});

const sorters = {
title: alphabeticalSorter,
Expand Down Expand Up @@ -198,16 +200,15 @@ const CompanyOffersManagementWidget = ({ addSnackbar, isMobile }) => {
return !isMobile ? (
<CollapsedQuickOfferEdit
offerId={rowKey}
offers={offers}
setOffers={setOffers}
isMobile={isMobile}
/>
) : (
<>
<div className={classes.payloadSection}>
<Grid container alignItems="center">
<Grid item xs={6}>
<Typography className={classes.collapsableTitles} variant="body1">
Actions
Actions
</Typography>
</Grid>
<Grid item xs={6} justifyContent="center">
Expand Down Expand Up @@ -269,8 +270,8 @@ const CompanyOffersManagementWidget = ({ addSnackbar, isMobile }) => {
emptyMessage="No offers here."
RowContent={RowContent}
RowCollapseComponent={RowCollapseComponent}
handleSelect={() => {}}
handleSelectAll={() => {}}
handleSelect={() => { }}
handleSelectAll={() => { }}
isSelectableTable={false}
isLoading={isLoading}
error={error}
Expand Down
7 changes: 6 additions & 1 deletion src/components/Company/Offers/Manage/QuickOfferEditForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,13 @@ export const QuickOfferEditForm = ({ offerId, showTitle = false }) => {
dispatch(addSnackbar(notification));
};

const { publishEndDate } = offers[offerId]["fields"];
const { publishStartDate, publishEndDate } = offers[offerId]["fields"];

console.log("Publish start date is: ", publishStartDate);

Check warning on line 23 in src/components/Company/Offers/Manage/QuickOfferEditForm.js

View workflow job for this annotation

GitHub Actions / build

Unexpected console statement

const { control, fields, errors } = useOfferForm(EditOfferSchema, {
publishEndDate: publishEndDate.value,
publishDate: publishStartDate.value
});

const isObjectEmpty =
Expand Down Expand Up @@ -62,6 +65,8 @@ export const QuickOfferEditForm = ({ offerId, showTitle = false }) => {
}
};

console.log("Errors are: ", errors);

Check warning on line 68 in src/components/Company/Offers/Manage/QuickOfferEditForm.js

View workflow job for this annotation

GitHub Actions / build

Unexpected console statement

return (
<form onSubmit={(e) => onSubmit(e)} aria-label="Quick Offer Edit Form">
{showTitle && <Typography align="center">Quick Edit Offer</Typography>}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,52 +7,54 @@ import { Info } from "@material-ui/icons";

const PublicationEndDateComponent = ({
fields, disabled, errors, requestErrors, control, datePickerProps, showInfoTooltip = true,
}) => (
<>
<Controller
name="publishEndDate"
render={(
{ field: { onChange, onBlur, name, value } },
) => (
<KeyboardDatePicker
margin="dense"
value={value}
label="Publication End Date *"
id={name}
name={name}
disabled={disabled}
onChange={(_, value) => {
const date = new Date(value);
// KeybaordDatePicker defaults its date to midnight. It makes more sense to consider the last hour of the day
// The offer is available between day x (00:00) and day y (23:59)
date.setHours(23, 59, 59, 0);
onChange(date);
}}
onBlur={onBlur}
variant="inline"
autoOk
format="yyyy-MM-dd"
minDate={fields?.publishDate}
error={!!errors?.publishEndDate ||
}) => {
return (
<>
<Controller
name="publishEndDate"
render={(
{ field: { onChange, onBlur, name, value } },
) => (
<KeyboardDatePicker
margin="dense"
value={value}
label="Publication End Date *"
id={name}
name={name}
disabled={disabled}
onChange={(_, value) => {
const date = new Date(value);
// KeybaordDatePicker defaults its date to midnight. It makes more sense to consider the last hour of the day
// The offer is available between day x (00:00) and day y (23:59)
date.setHours(23, 59, 59, 0);
onChange(date);
}}
onBlur={onBlur}
variant="inline"
autoOk
format="yyyy-MM-dd"
minDate={fields?.publishDate}
error={!!errors?.publishEndDate ||
!!requestErrors?.publishEndDate}
helperText={errors?.publishEndDate?.message ||
helperText={errors?.publishEndDate?.message ||
requestErrors?.publishEndDate?.message || " "}
{...datePickerProps}
/>)}
control={control}
/>
{showInfoTooltip ?
<Tooltip
title="The offer will only be visible until this date"
placement="top"
>
<Info fontSize="small" />
</Tooltip>
{...datePickerProps}
/>)}
control={control}
/>
{showInfoTooltip ?
<Tooltip
title="The offer will only be visible until this date"
placement="top"
>
<Info fontSize="small" />
</Tooltip>

: ""
}
</>
);
: ""
}
</>
)
};

PublicationEndDateComponent.propTypes = {
fields: PropTypes.object.isRequired,
Expand Down
5 changes: 3 additions & 2 deletions src/hooks/useOfferForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@ import { INITIAL_JOB_DURATION } from "../reducers/searchOffersReducer";
import useSession from "./useSession";

export default (schema, overrideDefaultValues) => {
console.log("Default: ", defaultDates.getPublishDate());

Check warning on line 11 in src/hooks/useOfferForm.js

View workflow job for this annotation

GitHub Actions / build

Unexpected console statement
const { handleSubmit, formState, control, setValue, getValues, clearErrors, reset } = useForm({
mode: "all",
resolver: yupResolver(schema),
reValidateMode: "onChange",
defaultValues: {
title: "",
publishDate: defaultDates.getPublishDate(),
publishDate: overrideDefaultValues?.publishDate ?? defaultDates.getPublishDate(),
publishEndDate: overrideDefaultValues?.publishEndDate ?? defaultDates.getPublishEndDate(),
jobDuration: [INITIAL_JOB_DURATION, INITIAL_JOB_DURATION + 1],
jobStartDate: null,
Expand Down Expand Up @@ -72,7 +73,7 @@ export default (schema, overrideDefaultValues) => {
clearErrors();
}
},
[clearErrors, isLoggedIn]);
[clearErrors, isLoggedIn]);

return {
success,
Expand Down

0 comments on commit aa89a72

Please sign in to comment.