Skip to content

Commit

Permalink
[EN-5921] feat(tech-debt): remove components from hooks (#111)
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulEntourage authored Jul 6, 2023
1 parent 988ddc8 commit 93c17c5
Show file tree
Hide file tree
Showing 14 changed files with 381 additions and 250 deletions.
20 changes: 11 additions & 9 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
"sourceType": "module"
},
"plugins": [
"react", "react-hooks", "prettier",
"react",
"react-hooks",
"prettier",
"@typescript-eslint/eslint-plugin",
"@typescript-eslint",
"typescript-sort-keys",
Expand Down Expand Up @@ -71,10 +73,13 @@
"react/static-property-placement": ["warn", "static getter"],
"react-hooks/rules-of-hooks": "error",
"react-hooks/exhaustive-deps": "error",
"jsx-a11y/aria-role": [ 2, {
"allowedInvalidRoles": ["Candidat"],
"ignoreNonDOM": true
}],
"jsx-a11y/aria-role": [
2,
{
"allowedInvalidRoles": ["Candidat"],
"ignoreNonDOM": true
}
],
"react/jsx-filename-extension": [
"warn",
{
Expand All @@ -90,10 +95,7 @@
],

// TypeScript Rules
"@typescript-eslint/no-unused-vars": [
1,
{ "ignoreRestSiblings": true }
],
"@typescript-eslint/no-unused-vars": [1, { "ignoreRestSiblings": true }],
"@typescript-eslint/member-delimiter-style": [
1,
{
Expand Down
2 changes: 1 addition & 1 deletion cypress.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module.exports = defineConfig({
projectId: process.env.CYPRESS_IO_PROJECT_ID,
defaultCommandTimeout: 10000,
pageLoadTimeout: 120000,
env :{
env: {
adresseLocauxParis: `${process.env.ADRESSE_LOCAUX_PARIS}`,
},
e2e: {
Expand Down
4 changes: 3 additions & 1 deletion cypress/e2e/parcours-travailler.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ describe('Parcours travailler', () => {
});

it('Remplir le formulaire, envoyer et fermer', () => {
cy.get('[data-testid="form-candidate-inscription-location"]').scrollIntoView().click();
cy.get('[data-testid="form-candidate-inscription-location"]')
.scrollIntoView()
.click();
cy.get('[data-testid="select-option-93"]').click();
cy.get('[data-testid="form-candidate-inscription-birthdate"]').type(
'1994-02-22'
Expand Down
132 changes: 66 additions & 66 deletions cypress/fixtures/auth-current-coach-externe-res.json
Original file line number Diff line number Diff line change
@@ -1,69 +1,69 @@
{
"id": "3a8ea26c-197c-4528-ab55-aa081e53343f",
"OrganizationId": "99aca0a7-3154-4fbe-b149-700a9de44871",
"firstName": "Sonia",
"lastName": "Lamani",
"email": "[email protected]",
"phone": "+33698754321",
"address": null,
"role": "Coach externe",
"adminRole": null,
"zone": "PARIS",
"gender": 1,
"lastConnection": "2023-05-26T09:32:48.902Z",
"candidat": null,
"coaches": [
{
"employed": false,
"hidden": false,
"note": null,
"url": "john-1cd4e535",
"contract": null,
"endOfContract": null,
"lastModifiedBy": null,
"candidat": {
"id": "1cd4e535-9c18-4b67-8896-e0652b5b3fc9",
"OrganizationId": "99aca0a7-3154-4fbe-b149-700a9de44871",
"firstName": "John",
"lastName": "Doeexterne",
"email": "[email protected]",
"phone": "+33698754321",
"address": null,
"role": "Candidat externe",
"adminRole": null,
"zone": "PARIS",
"gender": 0,
"lastConnection": null
}
},
{
"employed": false,
"hidden": false,
"note": "top top",
"url": "arnold-be521222",
"contract": null,
"endOfContract": null,
"lastModifiedBy": "3a8ea26c-197c-4528-ab55-aa081e53343f",
"candidat": {
"id": "be521222-7f46-42fb-805d-96676e65fe13",
"OrganizationId": "99aca0a7-3154-4fbe-b149-700a9de44871",
"firstName": "Arnold",
"lastName": "Schwarziexterne",
"email": "[email protected]",
"phone": "+33698754321",
"address": null,
"role": "Candidat externe",
"adminRole": null,
"zone": "PARIS",
"gender": 0,
"lastConnection": null
}
}
],
"organization": {
"name": "première en test",
"address": "panam",
"id": "3a8ea26c-197c-4528-ab55-aa081e53343f",
"OrganizationId": "99aca0a7-3154-4fbe-b149-700a9de44871",
"firstName": "Sonia",
"lastName": "Lamani",
"email": "[email protected]",
"phone": "+33698754321",
"address": null,
"role": "Coach externe",
"adminRole": null,
"zone": "PARIS",
"gender": 1,
"lastConnection": "2023-05-26T09:32:48.902Z",
"candidat": null,
"coaches": [
{
"employed": false,
"hidden": false,
"note": null,
"url": "john-1cd4e535",
"contract": null,
"endOfContract": null,
"lastModifiedBy": null,
"candidat": {
"id": "1cd4e535-9c18-4b67-8896-e0652b5b3fc9",
"OrganizationId": "99aca0a7-3154-4fbe-b149-700a9de44871",
"firstName": "John",
"lastName": "Doeexterne",
"email": "[email protected]",
"phone": "+33698754321",
"address": null,
"role": "Candidat externe",
"adminRole": null,
"zone": "PARIS",
"gender": 0,
"lastConnection": null
}
},
{
"employed": false,
"hidden": false,
"note": "top top",
"url": "arnold-be521222",
"contract": null,
"endOfContract": null,
"lastModifiedBy": "3a8ea26c-197c-4528-ab55-aa081e53343f",
"candidat": {
"id": "be521222-7f46-42fb-805d-96676e65fe13",
"OrganizationId": "99aca0a7-3154-4fbe-b149-700a9de44871",
"firstName": "Arnold",
"lastName": "Schwarziexterne",
"email": "[email protected]",
"phone": "+33698754321",
"address": null,
"role": "Candidat externe",
"adminRole": null,
"zone": "PARIS",
"id": "99aca0a7-3154-4fbe-b149-700a9de44871"
"gender": 0,
"lastConnection": null
}
}
}
],
"organization": {
"name": "première en test",
"address": "panam",
"zone": "PARIS",
"id": "99aca0a7-3154-4fbe-b149-700a9de44871"
}
}
16 changes: 8 additions & 8 deletions cypress/fixtures/post-external-message-res.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"UserId": "3da510cc-abae-4c4d-a801-30ca0d403951",
"firstName": "Addison",
"lastName": "Dare",
"email": "[email protected]",
"phone": "+33619509379",
"subject": "help",
"message": "Quos placeat placeat aliquid a aut quod eos quia impedit",
"type": "connector"
"UserId": "3da510cc-abae-4c4d-a801-30ca0d403951",
"firstName": "Addison",
"lastName": "Dare",
"email": "[email protected]",
"phone": "+33619509379",
"subject": "help",
"message": "Quos placeat placeat aliquid a aut quod eos quia impedit",
"type": "connector"
}
8 changes: 4 additions & 4 deletions src/components/backoffice/admin/AdminOpportunityList.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ import {
import { HeaderBackoffice } from 'src/components/headers/HeaderBackoffice';
import { openModal } from 'src/components/modals/Modal';
import { ModalEdit } from 'src/components/modals/Modal/ModalGeneric/ModalEdit';
import { PostOpportunityModal } from 'src/components/modals/Modal/ModalGeneric/PostOpportunityModal/PostOpportunityModal';
import { OpportunityList } from 'src/components/opportunities/OpportunityList';
import { ButtonMultiple } from 'src/components/utils';
import { Icon } from 'src/components/utils/Icon';
import { usePostOpportunity } from 'src/hooks';
import { useIsDesktop } from 'src/hooks/utils';
import { mutateFormSchema } from 'src/utils';

Expand Down Expand Up @@ -81,15 +81,15 @@ export const AdminOpportunityList = ({

const opportunityListRef = useRef();

const { PostOpportunityModal } = usePostOpportunity({
const opportunityModalProps = {
defaultValues: {
isPublic: true,
},
isAdmin: true,
callback: opportunityListRef?.current?.fetchData,
modalTitle: 'Ajouter une nouvelle offre',
schema: mutatedOfferSchema,
});
};

return (
<>
Expand All @@ -105,7 +105,7 @@ export const AdminOpportunityList = ({
buttons={[
{
onClick: () => {
openModal(<PostOpportunityModal />);
openModal(<PostOpportunityModal {...opportunityModalProps} />);
},
label: 'Nouvelle offre',
},
Expand Down
63 changes: 33 additions & 30 deletions src/components/cv/CVFiche.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useRouter } from 'next/router';
import PropTypes from 'prop-types';
import React from 'react';
import React, { useMemo } from 'react';
import {
FacebookShareButton,
LinkedinShareButton,
Expand All @@ -13,13 +13,14 @@ import { CVCareerPathSentence } from 'src/components/cv/CVCareerPathSentence';
import { formSendExternalMessage } from 'src/components/forms/schema/formSendExternalMessage';
import { openModal } from 'src/components/modals/Modal';
import { ModalEdit } from 'src/components/modals/Modal/ModalGeneric/ModalEdit';
import { PostOpportunityModal } from 'src/components/modals/Modal/ModalGeneric/PostOpportunityModal';
import { ModalShareCV } from 'src/components/modals/Modal/ModalGeneric/StepperModal/ModalShareCV';
import { Grid, Img, SimpleLink, Icon } from 'src/components/utils';
import { Button } from 'src/components/utils/Button';
import { CONTRACTS } from 'src/constants';
import { DEPARTMENTS_FILTERS } from 'src/constants/departements';
import { FB_TAGS, GA_TAGS } from 'src/constants/tags';
import { usePostOpportunity, useUpdateSharesCount } from 'src/hooks';
import { useUpdateSharesCount } from 'src/hooks';
import { fbEvent } from 'src/lib/fb';
import { gaEvent } from 'src/lib/gtag';
import {
Expand All @@ -36,34 +37,36 @@ import { CVShape } from './CV.shape';
export const CVFiche = ({ cv, actionDisabled }) => {
const updateSharesCount = useUpdateSharesCount();

const { PostOpportunityModal } = usePostOpportunity({
modalTitle: 'Proposer une opportunité à un candidat',
modalDesc: (
<div className="uk-text-normal">
Contactez ici le candidat et son coach LinkedOut afin de solliciter un
échange.
<br />
<br />
Si vous souhaitez échanger avec le coach bénévole qui accompagne le
candidat dans sa recherche d&apos;emploi, précisez-le dans votre
message.
<br />
<br />
<span className="uk-text-meta uk-text-italic">
LinkedOut est susceptible de transmettre cette opportunité à
d&apos;autres candidats dont le profil correspond à votre besoin.
</span>
</div>
),
candidateId: cv.UserId,
defaultValues: {
candidat: {
firstName: cv.user.candidat.firstName,
lastName: cv.user.candidat.lastName,
const opportunityModalProps = useMemo(() => {
return {
modalTitle: 'Proposer une opportunité à un candidat',
modalDesc: (
<div className="uk-text-normal">
Contactez ici le candidat et son coach LinkedOut afin de solliciter un
échange.
<br />
<br />
Si vous souhaitez échanger avec le coach bénévole qui accompagne le
candidat dans sa recherche d&apos;emploi, précisez-le dans votre
message.
<br />
<br />
<span className="uk-text-meta uk-text-italic">
LinkedOut est susceptible de transmettre cette opportunité à
d&apos;autres candidats dont le profil correspond à votre besoin.
</span>
</div>
),
candidateId: cv.UserId,
defaultValues: {
candidat: {
firstName: cv.user.candidat.firstName,
lastName: cv.user.candidat.lastName,
},
isPublic: false,
},
isPublic: false,
},
});
};
}, [cv]);

const { asPath } = useRouter();
const hostname = process.env.SERVER_URL;
Expand Down Expand Up @@ -209,7 +212,7 @@ export const CVFiche = ({ cv, actionDisabled }) => {
onClick={() => {
gaEvent(GA_TAGS.PAGE_CV_PROPOSER_OFFRE_CLIC);
fbEvent(FB_TAGS.COMPANY_CV_OFFER_OPEN);
openModal(<PostOpportunityModal />);
openModal(<PostOpportunityModal {...opportunityModalProps} />);
}}
>
Me proposer une offre <Icon name="chevron-right" />
Expand Down
16 changes: 3 additions & 13 deletions src/components/cv/CVList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { LoadingScreen } from 'src/components/backoffice/cv/LoadingScreen';
import { CandidatCard } from 'src/components/cards';
import { SearchBar } from 'src/components/filters/SearchBar';
import { openModal } from 'src/components/modals/Modal';
import { usePostPublicOfferModal } from 'src/components/modals/usePostPublicOfferModal';
import { PostPublicOfferModal } from 'src/components/modals/Modal/ModalGeneric/PostOpportunityModal';
import { Button, Grid, SimpleLink, Icon } from 'src/components/utils';
import { CV_FILTERS_DATA, INITIAL_NB_OF_CV_TO_DISPLAY } from 'src/constants';
import { FB_TAGS } from 'src/constants/tags';
Expand Down Expand Up @@ -52,8 +52,6 @@ export const CVList = ({
setSearch,
resetFilters,
}: CVListProps) => {
const PublicOfferModal = usePostPublicOfferModal();

const [cvs, setCVs] = useState(undefined);
const [loading, setLoading] = useState(false);
const [loadingMore, setLoadingMore] = useState(false);
Expand Down Expand Up @@ -210,7 +208,7 @@ export const CVList = ({
className="uk-link-text"
onClick={() => {
fbEvent(FB_TAGS.COMPANY_GENERAL_OFFER_OPEN);
openModal(<PublicOfferModal />);
openModal(<PostPublicOfferModal />);
}}
>
Publier une offre d’emploi
Expand All @@ -235,15 +233,7 @@ export const CVList = ({
}
return renderCvList(cvs);
}
}, [
cvs,
error,
filters,
hasSuggestions,
loading,
renderCvList,
PublicOfferModal,
]);
}, [cvs, error, filters, hasSuggestions, loading, renderCvList]);

return (
<div data-uk-scrollspy="cls:uk-animation-slide-bottom-small; target: .uk-card; delay: 200">
Expand Down
Loading

0 comments on commit 93c17c5

Please sign in to comment.