Skip to content

Commit f4dfcf7

Browse files
author
Morgan Merzouk
committed
Préselectionner "j'ai eu un refus" si éligible au RC et cherche un contact sur un autre mode de chauffage
1 parent 0c44aee commit f4dfcf7

3 files changed

Lines changed: 29 additions & 5 deletions

File tree

src/modules/chaleur-renouvelable/client/ChoixChauffageResults.tsx

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1+
import { useState } from 'react';
2+
13
import { EligibilityFormContact } from '@/components/EligibilityForm';
24
import CallOut from '@/components/ui/CallOut';
35
import Dialog from '@/components/ui/Dialog';
46
import Link from '@/components/ui/Link';
57
import useIsMobile from '@/hooks/useIsMobile';
68
import { trackPostHogEvent } from '@/modules/analytics/client';
79
import { BatEnrBatimentSelection } from '@/modules/chaleur-renouvelable/client/BatEnrBatimentSelection';
8-
import DemandeFCRForm from '@/modules/chaleur-renouvelable/client/DemandFCRForm';
10+
import DemandeFCRForm, { type ContactRecipientId } from '@/modules/chaleur-renouvelable/client/DemandFCRForm';
911
import { useChoixChauffageResults } from '@/modules/chaleur-renouvelable/client/hooks/useChoixChauffageResults';
1012
import { IncompatibleSolutionsSection } from '@/modules/chaleur-renouvelable/client/results/ui/IncompatibleSolutionsSection';
1113
import { NoResultSection } from '@/modules/chaleur-renouvelable/client/results/ui/NoResultSection';
@@ -17,6 +19,7 @@ import { ParamsForm } from './ParamsForm';
1719

1820
export default function ChoixChauffageResults() {
1921
const isMobile = useIsMobile();
22+
const [selectedContactRecipientId, setSelectedContactRecipientId] = useState<ContactRecipientId>('network-manager');
2023
const {
2124
batEnrBatiments,
2225
contactForm,
@@ -42,6 +45,7 @@ export default function ChoixChauffageResults() {
4245
urlParams,
4346
} = useChoixChauffageResults();
4447
const params = urlParams.params;
48+
const shouldPreselectPublicAdvisor = Boolean(situation.eligibiliteReseauChaleur);
4549

4650
if (isMobile === null) {
4751
return null;
@@ -96,9 +100,18 @@ export default function ChoixChauffageResults() {
96100
typeLogement={effectiveTypeLogement}
97101
onEditParamsClick={handleEditHotWaterParamsClick}
98102
onOpenChange={handleAccordionOpenChange}
103+
onCtaClick={() => {
104+
if (shouldPreselectPublicAdvisor) {
105+
setSelectedContactRecipientId('public-advisor');
106+
}
107+
}}
99108
/>
100109
<IncompatibleSolutionsSection rows={incompatibleSolutionRows} />
101-
<DemandeFCRForm topSolution={recommended.label} />
110+
<DemandeFCRForm
111+
selectedRecipientId={selectedContactRecipientId}
112+
setSelectedRecipientId={setSelectedContactRecipientId}
113+
topSolution={recommended.label}
114+
/>
102115
<CallOut
103116
title={
104117
<>

src/modules/chaleur-renouvelable/client/DemandFCRForm.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ const contactRecipients = [
3434
},
3535
] as const;
3636

37-
type ContactRecipientId = (typeof contactRecipients)[number]['id'];
37+
export type ContactRecipientId = (typeof contactRecipients)[number]['id'];
3838

3939
function ContactRecipientSelector({
4040
selectedRecipientId,
@@ -134,10 +134,15 @@ function ProjectStatusSelect({ label, onChange, options, isPublicAdvisorSelected
134134
);
135135
}
136136

137-
export default function DemandFCRForm({ topSolution }: { topSolution?: string }) {
137+
type DemandFCRFormProps = {
138+
selectedRecipientId: ContactRecipientId;
139+
setSelectedRecipientId: (recipientId: ContactRecipientId) => void;
140+
topSolution?: string;
141+
};
142+
143+
export default function DemandFCRForm({ selectedRecipientId, setSelectedRecipientId, topSolution }: DemandFCRFormProps) {
138144
const [isLoading, setIsLoading] = useState(false);
139145
const [isSent, setIsSent] = useState(false);
140-
const [selectedRecipientId, setSelectedRecipientId] = useState<ContactRecipientId>('network-manager');
141146
const [isProjectStatusSelectOpen, setIsProjectStatusSelectOpen] = useState(false);
142147
const [refusalPeriod, setRefusalPeriod] = useState('');
143148
const [refusalReason, setRefusalReason] = useState('');

src/modules/chaleur-renouvelable/client/results/ui/ResultsSection.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ type ResultsSectionProps = {
3333
typeLogement: TypeLogement;
3434
onEditParamsClick: () => void;
3535
onOpenChange: (id: string, expanded: boolean) => void;
36+
onCtaClick?: () => void;
3637
};
3738

3839
export function ResultsSection({
@@ -45,6 +46,7 @@ export function ResultsSection({
4546
typeLogement,
4647
onEditParamsClick,
4748
onOpenChange,
49+
onCtaClick,
4850
}: ResultsSectionProps) {
4951
const [activeTab, setActiveTab] = useState<ModeDeChauffageUsage>('heatingAndHotWater');
5052
const itemsByUsage = useMemo(
@@ -161,6 +163,7 @@ export function ResultsSection({
161163
isOpen={openAccordionId === id}
162164
position={index + 1}
163165
onOpenChange={(expanded) => onOpenChange(id, expanded)}
166+
onCtaClick={onCtaClick}
164167
/>
165168
);
166169
})}
@@ -182,6 +185,7 @@ type OtherSolutionRowProps = {
182185
position: number;
183186
situation: Situation;
184187
onOpenChange: (expanded: boolean) => void;
188+
onCtaClick?: () => void;
185189
};
186190

187191
function OtherSolutionRow({
@@ -193,6 +197,7 @@ function OtherSolutionRow({
193197
position,
194198
situation,
195199
onOpenChange,
200+
onCtaClick,
196201
}: OtherSolutionRowProps) {
197202
const dpeTo = improveDpe(dpeFrom, item.gainClasse);
198203
const { lowerBoundString, upperBoundString } = getCostPrecisionRange(item.coutParAn);
@@ -265,6 +270,7 @@ function OtherSolutionRow({
265270
className="my-3"
266271
postHogEventKey="fcr_results:alternative_solution_cta_clicked"
267272
postHogEventProps={{ solution_type: item.label }}
273+
onClick={onCtaClick}
268274
>
269275
Passer à l’étape suivante
270276
</Button>

0 commit comments

Comments
 (0)