|
1 | 1 | import { useContext } from 'react'
|
2 | 2 | import { Trans, useTranslation } from 'react-i18next'
|
3 |
| -import { useSelector } from 'react-redux' |
4 | 3 | import { styled } from 'styled-components'
|
5 | 4 |
|
6 | 5 | import { PopoverWithTrigger } from '@/design-system'
|
7 | 6 | import { Button } from '@/design-system/buttons'
|
8 | 7 | import { Emoji } from '@/design-system/emoji'
|
9 | 8 | import { Grid, Spacing } from '@/design-system/layout'
|
10 |
| -import { useCurrentSimulatorData } from '@/hooks/useCurrentSimulatorData' |
11 |
| -import { |
12 |
| - companySituationSelector, |
13 |
| - situationSelector, |
14 |
| - targetUnitSelector, |
15 |
| -} from '@/store/selectors/simulationSelectors' |
| 9 | +import { useUrl } from '@/hooks/useUrl' |
16 | 10 |
|
17 | 11 | import { TrackingContext } from '../ATInternetTracking'
|
18 | 12 | import { ConseillersEntreprisesButton } from '../ConseillersEntreprisesButton'
|
19 |
| -import { useParamsFromSituation } from '../utils/useSearchParamsSimulationSharing' |
20 | 13 | import { ShareSimulationPopup } from './ShareSimulationPopup'
|
21 | 14 |
|
22 |
| -export function useUrl() { |
23 |
| - const language = useTranslation().i18n.language |
24 |
| - const situation = { |
25 |
| - ...useSelector(situationSelector), |
26 |
| - ...useSelector(companySituationSelector), |
27 |
| - } |
28 |
| - |
29 |
| - const targetUnit = useSelector(targetUnitSelector) |
30 |
| - |
31 |
| - const searchParams = useParamsFromSituation(situation, targetUnit) |
32 |
| - const { currentSimulatorData } = useCurrentSimulatorData() |
33 |
| - |
34 |
| - const { path = '' } = currentSimulatorData ?? {} |
35 |
| - const siteUrl = |
36 |
| - language === 'fr' |
37 |
| - ? import.meta.env.VITE_FR_BASE_URL |
38 |
| - : import.meta.env.VITE_EN_BASE_URL |
39 |
| - |
40 |
| - return siteUrl + path + '?' + searchParams.toString() |
41 |
| -} |
42 |
| - |
43 | 15 | const ButtonLabel = styled.span`
|
44 | 16 | margin-left: 1rem;
|
45 | 17 | `
|
46 | 18 |
|
| 19 | +export interface CustomSimulationButton { |
| 20 | + href: string |
| 21 | + title: string |
| 22 | +} |
| 23 | + |
47 | 24 | export default function ShareOrSaveSimulationBanner({
|
48 | 25 | share,
|
49 | 26 | print,
|
50 | 27 | conseillersEntreprises,
|
| 28 | + customSimulationbutton, |
51 | 29 | }: {
|
52 | 30 | share?: boolean
|
53 | 31 | print?: boolean
|
54 | 32 | conseillersEntreprises?: boolean
|
| 33 | + customSimulationbutton?: CustomSimulationButton |
55 | 34 | }) {
|
56 | 35 | const { t } = useTranslation()
|
57 | 36 | const tracker = useContext(TrackingContext)
|
@@ -92,6 +71,14 @@ export default function ShareOrSaveSimulationBanner({
|
92 | 71 | justifyContent: 'center',
|
93 | 72 | }}
|
94 | 73 | >
|
| 74 | + {customSimulationbutton && ( |
| 75 | + <Grid item xs={12} sm="auto"> |
| 76 | + <Button light size="XS" href={customSimulationbutton.href}> |
| 77 | + {customSimulationbutton.title} |
| 78 | + </Button> |
| 79 | + </Grid> |
| 80 | + )} |
| 81 | + |
95 | 82 | {share && (
|
96 | 83 | <Grid item xs={12} sm="auto">
|
97 | 84 | <PopoverWithTrigger
|
|
0 commit comments