Skip to content
This repository was archived by the owner on Jul 6, 2026. It is now read-only.

Fixed user profile page error#2618

Closed
v-lerie wants to merge 1 commit into
PolicyEngine:mainfrom
v-lerie:valerie/fix-profile-page
Closed

Fixed user profile page error#2618
v-lerie wants to merge 1 commit into
PolicyEngine:mainfrom
v-lerie:valerie/fix-profile-page

Conversation

@v-lerie

@v-lerie v-lerie commented Jun 23, 2025

Copy link
Copy Markdown
Collaborator

Description

Fixes #2589

Changes

  • Updated the logic for loading the user profile page to prevent errors when a user profile does not exist yet.
  • This fix is paired with the backend fix in policyengine-api PR #2598, which adds logic to automatically create a user profile during a GET /user-profile call if none exists.

@vercel

vercel Bot commented Jun 23, 2025

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
policyengine-app ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 23, 2025 5:22am

@anth-volk anth-volk left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple questions for you @v-lerie. Thanks for this!

} else {
dispUserSince = dateFormatter.format(accessedUserProfile.user_since);
dispUserSince = dateFormatter.format(
new Date(parseInt(accessedUserProfile.user_since) * 1000),

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question, blocking: Why multiply by 1000?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without multiplying by 1000, the date kept showing up as January 1st, 1970. This happened because accessedUserProfile.user_since is a Unix timestamp in seconds, but JavaScript’s Date expects timestamps in milliseconds. So we multiply by 1000 to format the date correctly.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question, blocking: But when using this code with working profiles, I'm able to properly display the date without multiplying by 1000

When we actually write the record to the table, I believe we use JS Date, not something native to the database, for this exact purpose.

Comment thread src/api/call.js

const POLICYENGINE_API = "https://api.policyengine.org";
const POLICYENGINE_API =
process.env.REACT_APP_API_URL || "https://api.policyengine.org";

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: Why add this environment variable?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added REACT_APP_API_URL for local development and testing. I wasn’t able to get the frontend and backend to connect properly without it. It defaults to the live API if not set, so production behavior isn’t affected. I left it in since it might be helpful for others running things locally, but I can remove it if it’s not needed.

@MaxGhenis

Copy link
Copy Markdown
Contributor

Thank you for this contribution. Closing as part of the policyengine-app (v1) wind-down: policyengine.org is now served by policyengine-app-v2, and this repository is being archived, so changes merged here would not reach the live site.

If this is still relevant, please consider re-opening it against policyengine-app-v2 — we'd welcome it there. Apologies that this sat open through the migration.

@MaxGhenis MaxGhenis closed this Jul 6, 2026
@github-project-automation github-project-automation Bot moved this from Todo to Closed in policyengine-app Jul 6, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

Status: Closed

Development

Successfully merging this pull request may close these issues.

The profile page seems to break periodically

3 participants