Skip to content
Open
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
3 changes: 2 additions & 1 deletion src/api/call.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import { buildVariableTree, getTreeLeavesInOrder } from "./variables";
import { wrappedJsonStringify, wrappedResponseJson } from "../data/wrappedJson";
import { useAuthenticatedFetch } from "../hooks/useAuthenticatedFetch";

const POLICYENGINE_API = "https://api.policyengine.org";
const POLICYENGINE_API =
process.env.REACT_APP_API_URL || "https://api.policyengine.org";
Copy link
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
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.


/**
* returns an api call function that can be used to make requests
Expand Down
4 changes: 3 additions & 1 deletion src/pages/UserProfilePage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,9 @@ function UserProfileSection(props) {
} else if (dispState === STATES.EMPTY) {
dispUserSince = "Loading";
} else {
dispUserSince = dateFormatter.format(accessedUserProfile.user_since);
dispUserSince = dateFormatter.format(
new Date(parseInt(accessedUserProfile.user_since) * 1000),
Copy link
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
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
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.

);
}

let dispCountry = "";
Expand Down
Loading