Skip to content

Commit

Permalink
remove advanced settings collapsible
Browse files Browse the repository at this point in the history
  • Loading branch information
pedronunes19 committed Mar 6, 2024
1 parent 33eb94b commit 653f698
Show file tree
Hide file tree
Showing 6 changed files with 1,937 additions and 3,699 deletions.
5,450 changes: 1,904 additions & 3,546 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"audit": "npm audit --production --audit-level=high"
},
"dependencies": {
"@babel/preset-env": "^7.13.15",
"@babel/preset-env": "^7.23.9",
"@date-io/date-fns": "^1.3.13",
"@hookform/resolvers": "^2.8.3",
"@material-ui/core": "^4.12.3",
Expand Down Expand Up @@ -202,4 +202,4 @@
"eslintConfig": {
"extends": "react-app"
}
}
}
42 changes: 0 additions & 42 deletions src/components/Offers/Edit/EditOfferForm.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -263,48 +263,6 @@ describe("Edit Offer Form", () => {
expect(screen.getByLabelText("Application URL").getAttribute("value")).toBe(offer.applyURL);
});

it("should not be visible advanced settings", () => {
useSession.mockImplementation(() => ({ isLoggedIn: true, data: { company: { _id: "company_id" } } }));
useOffer.mockImplementation(() => ({ offer, loading: false, error: null, mutate: () => {} }));

renderWithStoreAndTheme(
<BrowserRouter>
<MuiPickersUtilsProvider utils={DateFnsUtils}>
<EditOfferWrapper>
<EditOfferPage />
</EditOfferWrapper>
</MuiPickersUtilsProvider>
</BrowserRouter>,
{ initialState, theme }
);

expect(screen.queryByText("Publication Date *")).not.toBeVisible();
expect(screen.queryByText("Publication End Date *")).not.toBeVisible();
});

it("should be visible advanced settings after clicking the button", async () => {

useSession.mockImplementation(() => ({ isLoggedIn: true, data: { company: { _id: "company_id" } } }));
useOffer.mockImplementation(() => ({ offer, loading: false, error: null, mutate: () => {} }));

renderWithStoreAndTheme(
<BrowserRouter>
<MuiPickersUtilsProvider utils={DateFnsUtils}>
<EditOfferWrapper>
<EditOfferPage />
</EditOfferWrapper>
</MuiPickersUtilsProvider>
</BrowserRouter>,
{ initialState, theme }
);

await act(() => {
fireEvent.click(screen.getByText("Advanced Settings"));
});

expect(screen.getByText("Publication Date *")).toBeVisible();
expect(screen.getByText("Publication End Date *")).toBeVisible();
});

it("should not submit dates if not edited", async () => {
useSession.mockImplementation(() => ({ isLoggedIn: true, data: { company: { _id: "company_id" } } }));
Expand Down
96 changes: 30 additions & 66 deletions src/components/Offers/Form/form-components/OfferForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@ import {
Grid,
FormControl,
Typography,
Collapse,
Button,
} from "@material-ui/core";
import React, { useState, useCallback, useContext, useEffect } from "react";
import React, { useContext, useEffect } from "react";
import { Redirect } from "react-router-dom";
import PropTypes from "prop-types";
import MultiOptionTextField from "../../../utils/form/MultiOptionTextField";
Expand All @@ -27,10 +26,6 @@ import PublicationDateComponent from "./PublicationDateComponent";
import PublicationEndDateComponent from "./PublicationEndDateComponent";
import IsHiddenComponent from "./IsHiddenComponent";
import TextEditorComponent from "./TextEditorComponent";
import {
KeyboardArrowDown,
KeyboardArrowUp,
} from "@material-ui/icons";
import useOfferFormStyles from "./offerStyles";
import { Controller } from "react-hook-form";
import { useMobile } from "../../../../utils/media-queries";
Expand Down Expand Up @@ -85,22 +80,6 @@ const OfferForm = ({ context, title }) => {

const formDisabled = !isLoggedIn || companyUnfinishedRegistration;

const [isAdvancedOpen, setAdvancedOpen] = useState(false);

const shouldShowAdvancedOptions = useCallback(() => (
isAdvancedOpen ||
!!errors.publishDate || !!requestErrors.publishDate ||
!!errors.publishEndDate || !!requestErrors.publishEndDate ||
!!errors.isHidden
), [
errors.isHidden,
errors.publishDate,
errors.publishEndDate,
isAdvancedOpen,
requestErrors.publishDate,
requestErrors.publishEndDate,
]);

const Content = isMobile ? DialogContent : CardContent;
const classes = useOfferFormStyles(isMobile)();

Expand Down Expand Up @@ -271,57 +250,42 @@ const OfferForm = ({ context, title }) => {
/>
</Grid>
<Grid item xs={12} lg={12}>
<Button
onClick={() => setAdvancedOpen(!isAdvancedOpen)}
size="small"
margin="dense"
endIcon={
shouldShowAdvancedOptions()
? <KeyboardArrowUp />
: <KeyboardArrowDown />}
>
<Typography>Advanced Settings</Typography>
</Button>
</Grid>
<Grid item xs={12} lg={12}>
<Collapse in={shouldShowAdvancedOptions()}>
<Grid container spacing={4} className={classes.advancedSettingsCollapse}>
<Grid item xs={12} lg={6} className={classes.gridWithInfo}>
<PublicationDateComponent
disabled={formDisabled}
errors={errors}
requestErrors={requestErrors}
control={control}
datePickerProps={{
className: classes.advancedSettingsDatePicker,
}}
/>
</Grid>
<Grid container spacing={4}>
<Grid item xs={12} lg={6} className={classes.gridWithInfo}>
<PublicationDateComponent
disabled={formDisabled}
errors={errors}
requestErrors={requestErrors}
control={control}
datePickerProps={{
className: classes.publicationDatePicker,
}}
/>
</Grid>
<Grid item xs={12} lg={6} className={classes.gridWithInfo}>
<PublicationEndDateComponent
fields={fields}
disabled={formDisabled}
errors={errors}
requestErrors={requestErrors}
control={control}
datePickerProps={{
className: classes.publicationDatePicker,
}}
/>
</Grid>
{
showHiddenField &&
<Grid item xs={12} lg={6} className={classes.gridWithInfo}>
<PublicationEndDateComponent
fields={fields}
<IsHiddenComponent
disabled={formDisabled}
errors={errors}
requestErrors={requestErrors}
control={control}
datePickerProps={{
className: classes.advancedSettingsDatePicker,
}}
/>
</Grid>
{
showHiddenField &&
<Grid item xs={12} lg={6} className={classes.gridWithInfo}>
<IsHiddenComponent
disabled={formDisabled}
errors={errors}
requestErrors={requestErrors}
control={control}
/>
</Grid>
}
</Grid>
</Collapse>
}
</Grid>
</Grid>
<Grid item xs={12} className={classes.highlightOptionGrid}>
<ApplyURLComponent
Expand Down
5 changes: 1 addition & 4 deletions src/components/Offers/Form/form-components/offerStyles.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export default (isMobile) => makeStyles((theme) => ({
autocompleteChipWrapper: {
minHeight: "40px",
},
advancedSettingsDatePicker: {
publicationDatePicker: {
width: "100%",
marginRight: theme.spacing(2),
},
Expand All @@ -56,9 +56,6 @@ export default (isMobile) => makeStyles((theme) => ({
vacanciesGrid: {
marginBottom: theme.spacing(5),
},
advancedSettingsCollapse: {
marginBottom: theme.spacing(4),
},
jobTypeGrid: {
marginBottom: theme.spacing(4),
},
Expand Down
39 changes: 0 additions & 39 deletions src/components/Offers/New/CreateOfferForm.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,45 +151,6 @@ describe("Create Offer Form", () => {
expect(screen.getByText("Submit").parentNode).toBeEnabled();
});

it("should not be visible advanced settings", () => {
useSession.mockImplementation(() => ({ isLoggedIn: true, data: { company: { name: "Company Name" } } }));

renderWithStoreAndTheme(
<BrowserRouter>
<MuiPickersUtilsProvider utils={DateFnsUtils}>
<CreateOfferWrapper>
<CreateOfferPage />
</CreateOfferWrapper>
</MuiPickersUtilsProvider>
</BrowserRouter>,
{ initialState, theme }
);

expect(screen.queryByText("Publication Date *")).not.toBeVisible();
expect(screen.queryByText("Publication End Date *")).not.toBeVisible();
expect(screen.queryByText("Hide offer")).not.toBeVisible();
});

it("should be visible advanced settings after clicking the button", async () => {
useSession.mockImplementation(() => ({ isLoggedIn: true, data: { company: { name: "Company Name" } } }));

renderWithStoreAndTheme(
<BrowserRouter>
<MuiPickersUtilsProvider utils={DateFnsUtils}>
<CreateOfferWrapper>
<CreateOfferPage />
</CreateOfferWrapper>
</MuiPickersUtilsProvider>
</BrowserRouter>,
{ initialState, theme }
);

await fireEvent.click(screen.getByText("Advanced Settings"));

expect(screen.queryByText("Publication Date *")).toBeVisible();
expect(screen.queryByText("Publication End Date *")).toBeVisible();
expect(screen.queryByText("Hide offer")).toBeVisible();
});

it("should not have job type options with null value", async () => {
useSession.mockImplementation(() => ({ isLoggedIn: true, data: { company: { name: "Company Name" } } }));
Expand Down

0 comments on commit 653f698

Please sign in to comment.