Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-enable cliff impacts #2211

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/pages/policy/output/CliffImpact.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ function description(metadata) {
return (
<p style={{ marginTop: "10px" }}>
The cliff rate is the share of households whose net income falls if each
adult earned an additional {metadata.currency}2,000. The cliff gap is the
adult earned an additional {metadata.currency}1,000. The cliff gap is the
sum of the losses incurred by all households on a cliff if their income
rose in this way.{" "}
<a href="https://policyengine.org/us/research/how-would-reforms-affect-cliffs">
Expand Down
39 changes: 4 additions & 35 deletions src/pages/policy/output/FetchAndDisplayImpact.jsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,13 @@
import { useEffect, useRef, useState } from "react";
import {
DisplayError,
DisplayImpact,
DisplayWait,
LowLevelDisplay,
} from "./Display";
import { DisplayError, DisplayImpact, DisplayWait } from "./Display";
import { useSearchParams } from "react-router-dom";
import { asyncApiCall, copySearchParams, apiCall } from "../../../api/call";
import ErrorPage from "layout/ErrorPage";
import { defaultYear } from "data/constants";
import { areObjectsSame } from "../../../data/areObjectsSame";
import { updateUserPolicy } from "../../../api/userPolicies";
import useCountryId from "../../../hooks/useCountryId";
import { wrappedResponseJson } from "../../../data/wrappedJson";
// import LoadingCentered from "layout/LoadingCentered";
import LoadingCentered from "layout/LoadingCentered";

/**
*
Expand Down Expand Up @@ -58,11 +52,6 @@ export function FetchAndDisplayImpact(props) {
function computingCallback(data) {
// Position in queue message only occurs with average_time
// in the response object; if this is present, enable message
/*
if (data.average_time && data.message) {
setQueueMsg(data.message);
}
*/
if (data.queue_position) {
setQueuePos(data.queue_position);
}
Expand Down Expand Up @@ -223,14 +212,9 @@ export function FetchAndDisplayCliffImpact(props) {
const reformPolicyId = searchParams.get("reform");
const baselinePolicyId = searchParams.get("baseline");

// Remove the following eslint ignore when cliff impacts are restored
// eslint-disable-next-line no-unused-vars
const [impact, setImpact] = useState(null);
const [error, setError] = useState(null);
const {
metadata,
// policy,
} = props;
const { metadata, policy } = props;
useEffect(() => {
if (!!region && !!timePeriod && !!reformPolicyId && !!baselinePolicyId) {
const url = `/${metadata.countryId}/economy/${reformPolicyId}/over/${baselinePolicyId}?region=${region}&time_period=${timePeriod}&target=cliff`;
Expand Down Expand Up @@ -283,24 +267,9 @@ export function FetchAndDisplayCliffImpact(props) {
return <DisplayError error={error} />;
}

// Remove the below block when cliff impacts are reinstated
return (
<LowLevelDisplay {...props}>
<ErrorPage message="This service is temporarily unavailable. Please try again later." />
</LowLevelDisplay>
);

/*
if (!impact) {
return <LoadingCentered message="Computing the cliff impact..." />;
}

return (
<DisplayImpact
impact={impact}
policy={policy}
metadata={metadata}
/>
);
*/
return <DisplayImpact impact={impact} policy={policy} metadata={metadata} />;
}
4 changes: 2 additions & 2 deletions src/pages/policy/output/ImpactTypes.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import averageImpactByDecile from "./decile/AverageImpactByDecile";
import averageImpactByWealthDecile from "./decile/AverageImpactByWealthDecile";
import budgetaryImpact from "./budget/BudgetaryImpact";
// import cliffImpact from "./CliffImpact";
import cliffImpact from "./CliffImpact";
import deepPovertyImpact from "./poverty/DeepPovertyImpact";
import deepPovertyImpactByGender from "./poverty/DeepPovertyImpactByGender";
import detailedBudgetaryImpact from "./budget/DetailedBudgetaryImpact";
Expand Down Expand Up @@ -43,7 +43,7 @@ const map = {
"povertyImpact.deep.byGender": deepPovertyImpactByGender,
"povertyImpact.regular.byRace": povertyImpactByRace,
inequalityImpact: inequalityImpact,
// cliffImpact: cliffImpact,
cliffImpact: cliffImpact,
"laborSupplyImpact.earnings.overall.absolute": LaborSupplyResponseAbsolute,
"laborSupplyImpact.earnings.overall.relative": LaborSupplyResponseRelative,
"laborSupplyImpact.earnings.byDecile.relative.total":
Expand Down
1 change: 0 additions & 1 deletion src/pages/policy/output/PolicyOutput.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ export default function PolicyOutput(props) {
{...props}
showPolicyImpactPopup={showPolicyImpactPopup}
/>
;
</>
);
}
Expand Down
6 changes: 5 additions & 1 deletion src/pages/policy/output/tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const policyOutputs = {
genderDeepPovertyImpact: "Deep poverty impact by sex",
racialPovertyImpact: "Poverty impact by race and ethnicity",
inequalityImpact: "Income inequality impact",
// cliffImpact: "Cliff impact",
cliffImpact: "Cliff impact",
"laborSupplyImpact.byDecile.relative.total":
"Labor supply impact by decile (relative)",
"laborSupplyImpact.byDecile.relative.income":
Expand Down Expand Up @@ -158,6 +158,10 @@ export function getPolicyOutputTree(countryId) {
name: "policyOutput.inequalityImpact",
label: "Inequality impact",
},
{
name: "policyOutput.cliffImpact",
label: "Cliff impact",
},
{
name: "policyOutput.laborSupplyImpact",
label:
Expand Down
Loading