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
@alloy => Working collector profile mutation! #80
Conversation
console.log("Loyalty Applicant Not Saved"); | ||
} | ||
else { | ||
console.log("Success"); |
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.
This should navigate us to the thank you page.
|
||
const onSuccess = (response) => { | ||
if(!response.updateCollectorProfile.loyalty_applicant_at) { | ||
console.log("Loyalty Applicant Not Saved"); |
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 may want to just render any errors under/above the button.
@@ -84,7 +155,7 @@ interface RelayProps { | |||
artwork_inquiries_connection: { | |||
edges: Array<{ | |||
node: { | |||
id: string, | |||
id: string | null, |
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'm not sure why this showed up...
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.
Because MP’s schema doesn’t specify this field as non-nullable https://github.com/artsy/metaphysics/blob/656eb8d1bdaad64ed2fdb0ed2517f8dd0de2ca4a/schema/me/artwork_inquiries.js#L23
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.
Which is the case for most of these types… it’s null
galore! 🎊
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 work! Looking good
this.setState({ self_reported_purchases: e.target.value }) | ||
} | ||
|
||
handleClick(e) { |
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.
maybe name onClickSubmitButton
, submitButtonClicked
, a more descriptive name
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.
Similarly this event can probably be typed as React.MouseEvent<Button>
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.
yup and yup
|
||
type RelayMutationProps = State | ||
|
||
class UpdateCollectorProfileMutation extends Relay.Mutation<RelayMutationProps, any> { |
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.
can we move the mutation to a separate file? maybe inquiries/relay.ts
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.
Yea, I was just starting out all in one file. At the very least I think co-locating it with this component makes the most sense, I can move to a separate file.
Lots of examples I saw online seem to have all the different mutations defined in a completely separate place, but that seems weird. I'm definitely down to keep them close to the app/components for now.
@@ -40,6 +84,33 @@ class Inquiries extends React.Component<RelayProps, any> { | |||
}) | |||
} | |||
|
|||
handleTextboxChange(e) { |
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.
#It looks like you can type the event as React.FormEvent<TextArea>
.
FormEvent
is just a SyntheticEvent
, which for the target
property has this tidbit which explains that we should use currentTarget
instead and that will get cast as HTMLTextAreaElement
through T
.
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 have to read about these things more
@@ -82,7 +82,7 @@ app.get("/inquiries", (req, res) => { | |||
styles, | |||
html, | |||
entrypoint: "/bundles/inquiries.js", | |||
bootstrapData: `var DATA = ${JSON.stringify(data)};`, | |||
bootstrapData: `var DATA = ${JSON.stringify(data)}; var USER_DATA = ${JSON.stringify(req.user.toJSON())};`, |
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.
Ah, I remember now, we need to harden this against XSS attacks. In the past I came across this lib of yahoo that should be able to escape HTML.
Yup, great stuff, glad you made it out alive! 👏 |
Ok, looks good. Mergin'! I'll have a PR up with the sharify integration for serializing objects on the client-side |
Cool! I'll leave myself an issue to do more research into those typed event handlers. |
Thanks for the pairing @alloy and @l2succes
This hooks up the mutation that lets you mark yourself as a loyalty applicant, as well as saving the textbox of self-reported purchases.