-
-
Notifications
You must be signed in to change notification settings - Fork 110
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
Mail to legislators and show stored testimony into EditTestimony modal #281
Conversation
…eeding mailing tool
…howAddComment becomes showTestimony
Visit the preview URL for this PR (updated for commit jkoren/advocacy-maps@c21ad30): https://digital-testimony-dev--pr281-mail-to-legislators-qoxqzt34.web.app (expires Wed, 16 Mar 2022 16:49:58 GMT) 🔥 via Firebase Hosting GitHub Action 🌎 Sign: bc0858669d4997df2a9165c2144bd1e2dbba0242 |
…displayName in BillTestimonies.js
…ny and BillTestimonies
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome work, Jeff! I'm excited to see this coming together.
Could you also update ExpandTestimony.js to show the whitespace in the testimony?
<p style={{whiteSpace: "pre-wrap"}}>{testimony ? testimony.content : ""}</p>
const senatorEmail = senatorId ? GetMemberEmail(senatorId) : "" | ||
const representativeEmail = representativeId ? GetMemberEmail(representativeId) : "" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I have legislators selected, these lines cause an error. One of the rules of hooks is not to call hooks conditionally. Since GetMemberEmail calls useMembers, we're violating that rule. things seem to work with these lines:
const senator = useMember(profile?.senator?.id)
const senatorEmail = senator.member?.EmailAddress ?? ""
const representative = useMember(profile?.representative?.id)
const representativeEmail = representative.member?.EmailAddress ?? ""
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice! I updated the code.
const edit = useEditTestimony(user.uid, bill.BillNumber) | ||
const positionMessage = "Select my support..(required)" | ||
|
||
const url = `mailto:${senatorEmail},${representativeEmail}?subject=My testimony on Bill ${bill ? bill.BillNumber : ""}&body=${testimony ? testimony.content : ""}` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should wrap this url in encodeURI
. Some characters like newlines and spaces aren't allowed in URL's. This converts them to escape strings like %20
so they show up correctly in the email draft
const url = encodeURI(`mailto:${senatorEmail},${representativeEmail}?subject=My testimony on Bill ${bill ? bill.BillNumber : ""}&body=${testimony ? testimony.content : ""}`)
|
||
const publishTestimony = async () => { | ||
if (testimony.position == undefined || testimony.position == positionMessage) { return } | ||
handleCloseTestimony() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's move this down two lines, so the modal closes after the testimony is published.
Also, what do you think about adding a loading state to the publish button? we can have an isPublishing
useState value that we set to true before saving the draft and false after publishing testimony. Then if isPublishing
is true, we disable the publish button and change the text to "Loading..."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like it!
<div> | ||
<links.External href={url}> | ||
Send copy to your legislators | ||
</links.External> | ||
</div> | ||
<div> | ||
<links.External href={url}> | ||
Send copy to relevant committee | ||
</links.External> | ||
</div> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we show these if the user has not chosen legislators? Maybe a note to say "add your legislators in your profile to email them your testimony"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like it
const defaultContent = testimony && testimony.content ? testimony.content : defaultTestimony | ||
|
||
const publishTestimony = async () => { | ||
if (testimony.position == undefined || testimony.position == positionMessage) { return } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider adding a validation error message to the form in this case so the user can more easily tell why the form didn't submit
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One of the integration tests is changing due to the changes in useEditTestimony. We can disable this test for now by adding
|
} | ||
|
||
const positionChosen = testimony.position != undefined && testimony.position != positionMessage |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the second condition should be testimony.content !== positionMessage
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
actually the original is correct. it is testing to make sure that the user has not re-chosen the default position, which is "Select my support..(required)" This would only happen if the user chooses a position such as "Endorse" and then re-selects the "Select my support..(required)" option.
I tried to disable the "Select my support..(required)" option, but then the menu defaults to this first enabled option "Endorse"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🥳
No description provided.