Skip to content
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
10 changes: 4 additions & 6 deletions app/src/adapters/PolicyAdapter.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
import {
V2PolicyCreatePayload,
V2PolicyParameterValue,
V2PolicyResponse,
} from '@/api/policy';
import { V2PolicyCreatePayload, V2PolicyParameterValue, V2PolicyResponse } from '@/api/policy';
import { FOREVER } from '@/constants';
import { Policy } from '@/types/ingredients/Policy';
import { ParameterMetadata } from '@/types/metadata';
Expand All @@ -20,7 +16,9 @@ export class PolicyAdapter {
const paramMap = new Map<string, ValueInterval[]>();
for (const pv of response.parameter_values ?? []) {
const name = pv.parameter_name;
if (!paramMap.has(name)) paramMap.set(name, []);
if (!paramMap.has(name)) {
paramMap.set(name, []);
}
paramMap.get(name)!.push({
startDate: pv.start_date.split('T')[0],
endDate: pv.end_date?.split('T')[0] ?? FOREVER,
Expand Down
4 changes: 1 addition & 3 deletions app/src/hooks/useUserReports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -469,9 +469,7 @@ export const useUserReportById = (userReportId: string, options?: { enabled?: bo
staleTime: 5 * 60 * 1000,
});

const legacyPolicies = policyResults.queries
.map((q) => q.data)
.filter((p): p is Policy => !!p);
const legacyPolicies = policyResults.queries.map((q) => q.data).filter((p): p is Policy => !!p);

// Step 5: Get user associations (always called — hooks must be unconditional)
const { data: simulationAssociations } = useSimulationAssociationsByUser(userId || '');
Expand Down
16 changes: 8 additions & 8 deletions app/src/tests/fixtures/utils/parameterLabelsMocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,31 +24,31 @@ export const TEST_PARAM_NAMES = {
export const MOCK_PARAMETER_METADATA: ParameterMetadataCollection = {
'gov.irs': {
label: 'Internal Revenue Service (IRS)',
type: 'parameterNode',
type: 'node',
parameter: 'gov.irs',
unit: '',
},
'gov.irs.credits': {
label: 'credits',
type: 'parameterNode',
type: 'node',
parameter: 'gov.irs.credits',
unit: '',
},
'gov.irs.credits.eitc': {
label: 'Earned Income Tax Credit',
type: 'parameterNode',
type: 'node',
parameter: 'gov.irs.credits.eitc',
unit: '',
},
'gov.irs.credits.eitc.max': {
label: 'EITC maximum amount by number of children',
type: 'parameterNode',
type: 'node',
parameter: 'gov.irs.credits.eitc.max',
unit: '',
},
'gov.irs.credits.eitc.max[0]': {
label: 'bracket 1',
type: 'parameterNode',
type: 'node',
parameter: 'gov.irs.credits.eitc.max[0]',
unit: '',
},
Expand All @@ -60,19 +60,19 @@ export const MOCK_PARAMETER_METADATA: ParameterMetadataCollection = {
},
'gov.irs.income': {
label: 'income',
type: 'parameterNode',
type: 'node',
parameter: 'gov.irs.income',
unit: '',
},
'gov.irs.income.bracket': {
label: 'bracket',
type: 'parameterNode',
type: 'node',
parameter: 'gov.irs.income.bracket',
unit: '',
},
'gov.irs.income.bracket.rates': {
label: 'Individual income tax rates',
type: 'parameterNode',
type: 'node',
parameter: 'gov.irs.income.bracket.rates',
unit: '',
},
Expand Down
14 changes: 7 additions & 7 deletions app/src/tests/unit/utils/parameterLabels.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ describe('getHierarchicalLabels', () => {
const partialMetadata = {
'gov.irs': {
label: 'IRS',
type: 'parameterNode' as const,
type: 'node' as const,
parameter: 'gov.irs',
unit: '',
},
Expand Down Expand Up @@ -279,7 +279,7 @@ describe('capitalize first formatting', () => {

// When
const result = getHierarchicalLabels('gov.irs', {
'gov.irs': { label: input, type: 'parameterNode', parameter: 'gov.irs', unit: '' },
'gov.irs': { label: input, type: 'node', parameter: 'gov.irs', unit: '' },
});

// Then
Expand All @@ -292,7 +292,7 @@ describe('capitalize first formatting', () => {

// When
const result = getHierarchicalLabels('gov.irs', {
'gov.irs': { label: input, type: 'parameterNode', parameter: 'gov.irs', unit: '' },
'gov.irs': { label: input, type: 'node', parameter: 'gov.irs', unit: '' },
});

// Then
Expand All @@ -305,7 +305,7 @@ describe('capitalize first formatting', () => {

// When
const result = getHierarchicalLabels('gov.irs', {
'gov.irs': { label: input, type: 'parameterNode', parameter: 'gov.irs', unit: '' },
'gov.irs': { label: input, type: 'node', parameter: 'gov.irs', unit: '' },
});

// Then
Expand All @@ -318,7 +318,7 @@ describe('capitalize first formatting', () => {

// When
const result = getHierarchicalLabels('gov.irs', {
'gov.irs': { label: input, type: 'parameterNode', parameter: 'gov.irs', unit: '' },
'gov.irs': { label: input, type: 'node', parameter: 'gov.irs', unit: '' },
});

// Then
Expand All @@ -331,7 +331,7 @@ describe('capitalize first formatting', () => {

// When
const result = getHierarchicalLabels('gov.irs', {
'gov.irs': { label: input, type: 'parameterNode', parameter: 'gov.irs', unit: '' },
'gov.irs': { label: input, type: 'node', parameter: 'gov.irs', unit: '' },
});

// Then
Expand All @@ -344,7 +344,7 @@ describe('capitalize first formatting', () => {

// When
const result = getHierarchicalLabels('gov.irs', {
'gov.irs': { label: input, type: 'parameterNode', parameter: 'gov.irs', unit: '' },
'gov.irs': { label: input, type: 'node', parameter: 'gov.irs', unit: '' },
});

// Then
Expand Down
6 changes: 3 additions & 3 deletions app/src/types/metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ export interface VariableMetadata {
* filtering logic should be removed/changed.
* - `period`: V1 included time period info. V2 doesn't provide this.
* - `type`: V1 distinguished "parameter" vs "parameterNode" for tree hierarchy.
* V2 only returns actual parameters; nodes are created dynamically in buildParameterTreeV2.
* V2 uses "parameter" vs "node" (cleaner naming, avoids redundant "parameter" prefix).
* - `values`: V1 included values inline. V2 fetches via separate /parameter-values endpoint.
* Currently set to {} and populated on-demand.
*/
Expand All @@ -135,8 +135,8 @@ export interface ParameterMetadata {
tax_benefit_model_version_id?: string;
created_at?: string;

// Parameter tree fields
type?: 'parameter' | 'parameterNode';
// Parameter tree fields (V2 uses 'node', V1 used 'parameterNode')
type?: 'parameter' | 'node';
parameter: string; // Dot-separated path to parameter

// Values indexed by date
Expand Down
Loading