Skip to content

Commit b318fe4

Browse files
committed
Remove block of demonstration code in HouseholdAIModal
1 parent ac91840 commit b318fe4

1 file changed

Lines changed: 10 additions & 87 deletions

File tree

src/modals/HouseholdAIModal.jsx

Lines changed: 10 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,19 @@
1-
import React, { useCallback, useEffect, useRef, useState } from "react";
21
import { Button, Modal } from "antd";
3-
import { countryApiCall } from "../api/call";
4-
import useCountryId from "../hooks/useCountryId";
5-
import { MarkdownFormatter } from "../layout/MarkdownFormatter";
2+
import React, { useCallback, useEffect, useRef, useState } from "react";
63
import { useSearchParams } from "react-router-dom";
4+
import { countryApiCall } from "../api/call";
75
import { COUNTRY_BASELINE_POLICIES } from "../data/countries";
8-
import LoadingCentered from "../layout/LoadingCentered";
6+
import useCountryId from "../hooks/useCountryId";
97
import ErrorComponent from "../layout/ErrorComponent";
8+
import LoadingCentered from "../layout/LoadingCentered";
9+
import { MarkdownFormatter } from "../layout/MarkdownFormatter";
1010

1111
/**
1212
* Modal for displaying AI output
1313
* @param {Object} props
1414
* @param {Object} props.variableName The name of the variable
15-
* @param {String} props.value The value of the variable
1615
* @param {Boolean} props.isModalVisible Whether the modal is visible
1716
* @param {Function} props.setIsModalVisible Function to set the visibility of the modal
18-
* @param {Boolean} props.isDemo Whether this is a demo of the feature (used on AI landing page)
1917
* @returns {React.Component} The modal component
2018
*/
2119

@@ -24,14 +22,8 @@ export default function HouseholdAIModal(props) {
2422
isModalVisible = false,
2523
setIsModalVisible,
2624
variableName,
27-
isDemo = false,
2825
} = props || {};
2926

30-
// For demo version on the AI page
31-
const [internalModalVisible, setInternalModalVisible] = useState(false);
32-
const showModal = isDemo ? internalModalVisible : isModalVisible;
33-
const setShowModal = isDemo ? setInternalModalVisible : setIsModalVisible;
34-
3527
const [analysis, setAnalysis] = useState("");
3628
const [isLoading, setIsLoading] = useState(true);
3729
const [isError, setIsError] = useState(false);
@@ -49,45 +41,11 @@ export default function HouseholdAIModal(props) {
4941

5042
// Function to hide modal
5143
const handleCancel = () => {
52-
setShowModal(false);
44+
setIsModalVisible(false);
5345
};
5446

55-
// Example explanation for demo mode
56-
const demoExplanation = `# WIC Benefits Explanation
57-
58-
You qualify for $475 in WIC (Women, Infants, and Children) benefits based on your household's income and composition.
59-
60-
## Eligibility Criteria
61-
62-
Your household qualifies for WIC because:
63-
- You have a 3-year-old child (WIC serves children up to age 5)
64-
- Your household income of $47,000 is below 185% of the Federal Poverty Level for a family of 4
65-
- Your household meets categorical eligibility requirements
66-
67-
## Benefit Calculation
68-
69-
Your WIC benefit is calculated as follows:
70-
- Food package value for a child 1-4 years old: approximately $39.60 per month
71-
- Annual calculation: $39.60 × 12 months = $475.20 (rounded to $475)
72-
73-
## Factors That Could Change Your Benefit
74-
75-
Your WIC benefit amount could change if:
76-
- Your child turns 5 (you would lose eligibility)
77-
- Your income increases above the 185% FPL threshold ($54,385 for a family of 4)
78-
- Your household composition changes (adding an infant or pregnant woman would increase benefits)
79-
- You move to a different state (WIC food package values vary by state)
80-
`;
81-
8247
// Convert this and fetchTracer to async/await
8348
const fetchAnalysis = useCallback(async () => {
84-
// If demo mode, use the sample explanation
85-
if (isDemo) {
86-
setIsLoading(false);
87-
setAnalysis(demoExplanation);
88-
return;
89-
}
90-
9149
setIsError(false);
9250
const jsonObject = {
9351
household_id: householdId,
@@ -147,62 +105,27 @@ Your WIC benefit amount could change if:
147105
}
148106
}
149107
}
150-
}, [countryId, householdId, policyId, variableName, isDemo, demoExplanation]);
108+
}, [countryId, householdId, policyId, variableName]);
151109

152110
useEffect(() => {
153111
function resetModalData() {
154112
prevVariableName.current = variableName;
155113
}
156114

157115
// If modal isn't shown, don't do anything
158-
if (!showModal) {
116+
if (!isModalVisible) {
159117
return;
160118
}
161119

162120
// If variable hasn't changed and we generated analysis,
163121
// don't do anything (e.g., user clicked on same variable)
164-
if (!isDemo && variableName === prevVariableName.current) {
122+
if (variableName === prevVariableName.current) {
165123
return;
166124
}
167125

168126
fetchAnalysis();
169127
resetModalData();
170-
}, [showModal, variableName, fetchAnalysis, isDemo]);
171-
172-
// For demo purposes on the AI page
173-
if (isDemo) {
174-
return (
175-
<>
176-
<Button
177-
type="primary"
178-
onClick={() => setInternalModalVisible(true)}
179-
style={{ marginTop: "1rem" }}
180-
>
181-
Try AI Explanation Demo
182-
</Button>
183-
184-
<Modal
185-
title="AI Household Explanation Demo"
186-
open={internalModalVisible}
187-
onCancel={handleCancel}
188-
footer={[
189-
<Button key="back" onClick={handleCancel}>
190-
Close
191-
</Button>,
192-
]}
193-
width="60%"
194-
>
195-
{isLoading ? (
196-
<LoadingCentered />
197-
) : isError ? (
198-
<ErrorComponent message="Error loading demo. Please try again later." />
199-
) : (
200-
<MarkdownFormatter markdown={analysis} pSize={14} />
201-
)}
202-
</Modal>
203-
</>
204-
);
205-
}
128+
}, [isModalVisible, variableName, fetchAnalysis]);
206129

207130
return (
208131
<Modal

0 commit comments

Comments
 (0)