Skip to content

Comments

Update frontend for user-policy API v2 compatibility#574

Merged
anth-volk merged 11 commits intomove-to-api-v2from
alpha/user-policy-api-integration
Feb 17, 2026
Merged

Update frontend for user-policy API v2 compatibility#574
anth-volk merged 11 commits intomove-to-api-v2from
alpha/user-policy-api-integration

Conversation

@SakshiKekre
Copy link
Collaborator

Summary

Aligns frontend with backend PR #71 which adds user-policy association CRUD endpoints.

Changes

API endpoints:

  • Updated from /api/user-policy-associations to /user-policies
  • findByUser now uses query params: /user-policies/?user_id=xxx&country_id=xxx
  • findById changed from (userId, policyId) to (userPolicyId)

Types:

  • Added id field to UserPolicyMetadata (association ID from backend)
  • Made created_at and updated_at required in response
  • Added UserPolicyUpdateMetadata for PATCH requests
  • Removed updated_at from creation payload

Implementation:

  • Fixed UserPolicyAdapter.fromApiResponse to use apiData.id instead of apiData.policy_id
  • Implemented update method with PATCH /user-policies/{id}
  • Implemented delete method with DELETE /user-policies/{id}
  • Updated LocalStoragePolicyStore to match new interface

Test plan

  • TypeScript compiles without errors
  • All adapter tests pass (9/9)
  • All policyAssociation tests pass (26/26)

@vercel
Copy link

vercel bot commented Jan 14, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
policyengine-app-v2 Ready Ready Preview, Comment Feb 17, 2026 9:15pm
policyengine-calculator Ready Ready Preview, Comment Feb 17, 2026 9:15pm
policyengine-website Ready Ready Preview, Comment Feb 17, 2026 9:15pm

Request Review

Remove isMigrationComplete, markMigrationComplete, clearMigrationFlag,
and MIGRATION_COMPLETE storage key. Migration functionality will be
built separately once all ingredient APIs are properly set up.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Create api/v2/userPolicyAssociations.ts with types, conversion
functions, and CRUD operations mirroring the household v2 module.
Refactor ApiPolicyStore to delegate to v2 functions instead of
inline fetch calls. Add userId param to update/delete for backend
ownership verification.

Remove deprecated v1 code: PolicyAdapter.fromMetadata/toCreationPayload,
UserPolicyAdapter, PolicyCreationPayload, UserPolicyCreationPayload,
userPolicyMetadata types, and dead countParameterChanges function.
Replace toCreationPayload usage in report pages with direct
convertParametersToPolicyJson calls.

Fix queryKeys bug (model -> country label), add useDeletePolicyAssociation
hook, and update test fixtures with countryId.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@anth-volk anth-volk merged commit a0a901c into move-to-api-v2 Feb 17, 2026
3 checks passed
@anth-volk anth-volk deleted the alpha/user-policy-api-integration branch February 17, 2026 21:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants