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

Factor out some common stuff from calculator.ts #12

Merged
merged 2 commits into from
Aug 4, 2023

Conversation

oyamauchi
Copy link
Member

I want to copy this file for the RI calculator. To avoid too much duplication, this factors out some common logic: the "fetch from API and interpret errors" code, and the static footer.

It also changes the api-path attribute of the calculator element to api-host, which should contain only the protocol and hostname, not the path. Since the RI calculator will be fetching multiple paths, I want to separate path from host. api-path is not publicly documented, so I think it's fine to remove it.

@vercel
Copy link

vercel bot commented Aug 4, 2023

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

Name Status Preview Comments Updated (UTC)
embed-rewiringamerica-org ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 4, 2023 11:09pm

@@ -62,8 +63,8 @@ export class RewiringAmericaCalculator extends LitElement {
@property({ type: String, attribute: 'api-key' })
apiKey: string = '';

@property({ type: String, attribute: 'api-path' })
Copy link
Member

Choose a reason for hiding this comment

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

I think I was using this in working-copy.html for local dev? Fine to evolve away from that, but probably worth resolving now so we don't leave a vestigial usage around.

The aim I had with this api-path property was to allow people embedding the calculator to hide their API key by using a proxy endpoint on their own server instead. Nobody has actually asked for that, and nobody is using it, so I agree we can change it.

Copy link
Member Author

Choose a reason for hiding this comment

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

This setup can still support that use case. They'd just have to have their proxy preserve paths instead of hardcoding a destination path. That's easy to do with e.g. nginx.

Will fix working-copy.html.

@RandomEtc
Copy link
Member

Also, verified the preview works. Looks good!

@RandomEtc
Copy link
Member

Re fetching multiple paths, the website (non-embed) calculator does this too - it calls /incentives for the preview list before personalization, and /calculator once we have inputs and want to present personalized results.

Base automatically changed from owen/lint to main August 4, 2023 23:07
I want to copy this file for the RI calculator. To avoid too much
duplication, this factors out some common logic: the "fetch from API
and interpret errors" code, and the static footer.

It also changes the `api-path` attribute of the calculator element to
`api-host`, which should contain only the protocol and hostname, not
the path. Since the RI calculator will be fetching multiple paths, I
want to separate path from host. `api-path` is not publicly
documented, so I think it's fine to remove it.
@oyamauchi oyamauchi merged commit be7397d into main Aug 4, 2023
2 checks passed
@oyamauchi oyamauchi deleted the owen/calc-refactor branch August 4, 2023 23:14
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