Ajoute une question pour les auto-entrepreneurs
parent
57a7b30f14
commit
09fd2a71a2
|
@ -26,3 +26,12 @@ export const setEntreprise = siren => async dispatch => {
|
|||
details: communeDetails
|
||||
})
|
||||
}
|
||||
|
||||
export const specifyIfAutoEntrepreneur = isAutoEntrepreneur => ({
|
||||
type: 'EXISTING_COMPANY::SPECIFY_AUTO_ENTREPRENEUR',
|
||||
isAutoEntrepreneur
|
||||
})
|
||||
|
||||
export const resetEntreprise = () => ({
|
||||
type: 'EXISTING_COMPANY::RESET'
|
||||
})
|
||||
|
|
|
@ -20,7 +20,7 @@ export default function CompanyDetails({ siren, denomination }) {
|
|||
const [company, setCompany] = useState()
|
||||
useEffect(() => {
|
||||
fetchCompanyDetails(siren).then(setCompany)
|
||||
}, [siren, company])
|
||||
}, [siren])
|
||||
|
||||
return (
|
||||
<>
|
||||
|
|
|
@ -77,7 +77,8 @@ export default function Search() {
|
|||
width: 100%;
|
||||
padding: 0.4rem;
|
||||
border-radius: 0.3rem;
|
||||
:hover {
|
||||
:hover,
|
||||
:focus {
|
||||
background-color: var(--lighterColour);
|
||||
}
|
||||
`}>
|
||||
|
|
|
@ -10,16 +10,18 @@ export default function Overlay({ onClose, children, ...otherProps }) {
|
|||
<FocusTrap
|
||||
focusTrapOptions={{
|
||||
onDeactivate: onClose,
|
||||
clickOutsideDeactivates: true
|
||||
clickOutsideDeactivates: !!onClose
|
||||
}}>
|
||||
<div aria-modal="true" id="overlayContent" {...otherProps}>
|
||||
{children}
|
||||
<LinkButton
|
||||
aria-label="close"
|
||||
onClick={onClose}
|
||||
id="overlayCloseButton">
|
||||
×
|
||||
</LinkButton>
|
||||
{onClose && (
|
||||
<LinkButton
|
||||
aria-label="close"
|
||||
onClick={onClose}
|
||||
id="overlayCloseButton">
|
||||
×
|
||||
</LinkButton>
|
||||
)}
|
||||
</div>
|
||||
</FocusTrap>
|
||||
</animate.fromBottom>
|
||||
|
|
|
@ -98,7 +98,8 @@ const infereLegalStatusFromCategorieJuridique = catégorieJuridique => {
|
|||
En revanche, impossible de différencier EI et auto-entreprise
|
||||
https://www.sirene.fr/sirene/public/question.action?idQuestion=2933
|
||||
*/
|
||||
if (!catégorieJuridique) {
|
||||
|
||||
if (catégorieJuridique === '1000') {
|
||||
return 'EI'
|
||||
}
|
||||
if (catégorieJuridique === '5498') {
|
||||
|
@ -129,6 +130,9 @@ function existingCompany(
|
|||
if (!action.type.startsWith('EXISTING_COMPANY::')) {
|
||||
return state
|
||||
}
|
||||
if (action.type.endsWith('RESET')) {
|
||||
return null
|
||||
}
|
||||
if (action.type.endsWith('SET_SIREN')) {
|
||||
return { siren: action.siren }
|
||||
}
|
||||
|
@ -144,6 +148,7 @@ function existingCompany(
|
|||
if (state && action.type.endsWith('SPECIFY_AUTO_ENTREPRENEUR')) {
|
||||
return { ...state, isAutoEntrepreneur: action.isAutoEntrepreneur }
|
||||
}
|
||||
|
||||
return state
|
||||
}
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ import { findRuleByDottedName } from 'Engine/rules'
|
|||
import {
|
||||
compose,
|
||||
defaultTo,
|
||||
dissoc,
|
||||
identity,
|
||||
lensPath,
|
||||
omit,
|
||||
|
@ -186,6 +187,12 @@ const addAnswerToSituation = (dottedName, value, state) => {
|
|||
)
|
||||
)(state)
|
||||
}
|
||||
const removeAnswerFromSituation = (dottedName, state) => {
|
||||
return compose(
|
||||
over(lensPath(['simulation', 'situation']), dissoc(dottedName)),
|
||||
over(lensPath(['conversationSteps', 'foldedSteps']), without([dottedName]))
|
||||
)(state)
|
||||
}
|
||||
|
||||
const existingCompanyReducer = (state, action) => {
|
||||
if (!action.type.startsWith('EXISTING_COMPANY::')) {
|
||||
|
@ -198,6 +205,9 @@ const existingCompanyReducer = (state, action) => {
|
|||
state
|
||||
)
|
||||
}
|
||||
if (action.type.endsWith('RESET')) {
|
||||
removeAnswerFromSituation('établissement . localisation', state)
|
||||
}
|
||||
return state
|
||||
}
|
||||
|
||||
|
|
|
@ -1,17 +1,20 @@
|
|||
/* @flow */
|
||||
|
||||
import {
|
||||
resetEntreprise,
|
||||
specifyIfAutoEntrepreneur
|
||||
} from 'Actions/existingCompanyActions'
|
||||
import { React, T } from 'Components'
|
||||
import CompanyDetails from 'Components/CompanyDetails'
|
||||
import FindCompany from 'Components/FindCompany'
|
||||
import Overlay from 'Components/Overlay'
|
||||
import { ScrollToTop } from 'Components/utils/Scroll'
|
||||
import withSitePaths from 'Components/utils/withSitePaths'
|
||||
import { compose } from 'ramda'
|
||||
import { useEffect, useRef, useState } from 'react'
|
||||
import emoji from 'react-easy-emoji'
|
||||
import { Helmet } from 'react-helmet'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { useSelector } from 'react-redux'
|
||||
import { useDispatch, useSelector } from 'react-redux'
|
||||
import { Link } from 'react-router-dom'
|
||||
import * as Animate from 'Ui/animate'
|
||||
import Video from './Video'
|
||||
|
@ -46,6 +49,7 @@ type Props = {
|
|||
régime: 'indépendant' | 'assimilé-salarié' | 'auto-entrepreneur' | null,
|
||||
sitePaths: Object
|
||||
}
|
||||
|
||||
function SocialSecurity({ sitePaths }: Props) {
|
||||
const { t } = useTranslation()
|
||||
const company = useSelector(state => state.inFranceApp.existingCompany)
|
||||
|
@ -138,17 +142,52 @@ function SocialSecurity({ sitePaths }: Props) {
|
|||
|
||||
const CompanySection = ({ company }) => {
|
||||
const [searchModal, showSearchModal] = useState(false)
|
||||
const companyRef = useRef(company)
|
||||
const [autoEntrepreneurModal, showAutoEntrepreneurModal] = useState(false)
|
||||
|
||||
const companyRef = useRef(null)
|
||||
useEffect(() => {
|
||||
if (companyRef.current !== company) {
|
||||
companyRef.current = company
|
||||
if (searchModal) {
|
||||
if (searchModal && company) {
|
||||
showSearchModal(false)
|
||||
}
|
||||
if (
|
||||
company?.statutJuridique === 'EI' &&
|
||||
company?.isAutoEntrepreneur == null
|
||||
) {
|
||||
showAutoEntrepreneurModal(true)
|
||||
}
|
||||
}
|
||||
}, [company, searchModal])
|
||||
|
||||
const dispatch = useDispatch(company)
|
||||
const handleAnswerAutoEntrepreneur = isAutoEntrepreneur => {
|
||||
dispatch(specifyIfAutoEntrepreneur(isAutoEntrepreneur))
|
||||
showAutoEntrepreneurModal(false)
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
{autoEntrepreneurModal && (
|
||||
<>
|
||||
<ScrollToTop />
|
||||
<Overlay>
|
||||
<h2> Êtes-vous auto-entrepreneur ? </h2>
|
||||
<div className="ui__ answer-group">
|
||||
<button
|
||||
className="ui__ button"
|
||||
onClick={() => handleAnswerAutoEntrepreneur(true)}>
|
||||
Oui
|
||||
</button>
|
||||
<button
|
||||
className="ui__ button"
|
||||
onClick={() => handleAnswerAutoEntrepreneur(false)}>
|
||||
Non
|
||||
</button>
|
||||
</div>
|
||||
</Overlay>
|
||||
</>
|
||||
)}
|
||||
{searchModal && (
|
||||
<>
|
||||
<ScrollToTop />
|
||||
|
@ -164,8 +203,11 @@ const CompanySection = ({ company }) => {
|
|||
<br />
|
||||
<button
|
||||
className="ui__ simple small button"
|
||||
onClick={() => showSearchModal(true)}>
|
||||
Modifier
|
||||
onClick={() => {
|
||||
dispatch(resetEntreprise())
|
||||
showSearchModal(true)
|
||||
}}>
|
||||
Changer
|
||||
</button>
|
||||
</>
|
||||
) : (
|
||||
|
@ -192,4 +234,5 @@ const CompanySection = ({ company }) => {
|
|||
</>
|
||||
)
|
||||
}
|
||||
export default compose(withSitePaths)(SocialSecurity)
|
||||
|
||||
export default withSitePaths(SocialSecurity)
|
||||
|
|
Loading…
Reference in New Issue