-
Notifications
You must be signed in to change notification settings - Fork 74
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
email confirmation message banner #3576
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import React from "react" | ||
import { Banner, Sans } from "@artsy/palette" | ||
|
||
interface Props { | ||
messageCode: FlashMessageKey | ||
} | ||
|
||
export type FlashMessageKey = | ||
/* email confirmed */ | ||
| "confirmed" | ||
/* email already confirmed */ | ||
| "already_confirmed" | ||
/* email confirmation token was invalid */ | ||
| "invalid_token" | ||
/* email confirmation token was empty */ | ||
| "blank_token" | ||
/* email confirmation token was expired */ | ||
| "expired_token" | ||
|
||
type BannerMessage = string | React.FC | ||
|
||
const messages: Record<FlashMessageKey, BannerMessage> = { | ||
confirmed: "Your email has been confirmed.", | ||
already_confirmed: "You have already confirmed your email.", | ||
invalid_token: "Your token is invalid. Please try again.", | ||
blank_token: "No token found. Please try again.", | ||
expired_token: "An error has occurred. Please try again.", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't this be something about how their confirmation token expired, not the general message? Or are we planning to come back to this once we allow people to request the email? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I copied these from the eigen pr- happy to change but also wonder if these are meant to be final - in most cases for example 'try again' is not going to be actionable unless there is a 'resend email' button. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agreed – would much rather tell people to "Contact support@artsymail.com" |
||
} | ||
|
||
export const FlashBanner: React.FunctionComponent<Props> = ({ | ||
messageCode, | ||
}) => { | ||
const Message = messages[messageCode] | ||
if (!Message) return null | ||
return ( | ||
Message && ( | ||
<Banner dismissable backgroundColor="black100"> | ||
<Sans color="white100" size="3" lineHeight={1} weight="medium"> | ||
{typeof Message === "string" ? Message : <Message />} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. very well could be missing something, but these seem to always be strings... |
||
</Sans> | ||
</Banner> | ||
) | ||
) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -58,7 +58,12 @@ export class MinimalCtaBanner extends React.Component< | |
</Sans> | ||
</a> | ||
<IconContainer onClick={this.dismissCta.bind(this) as any}> | ||
<Icon name="close" color={this.props.textColor} fontSize="16px" /> | ||
<Icon | ||
name="close" | ||
color={this.props.textColor} | ||
fontSize="16px" | ||
style={{ cursor: "pointer" }} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This and the other change to the CtaBanner story were minor bugfixes left over from early explorations. It's possible we don't even use this and/or should remove the changes from the PR but for now I'm thinking we want to prioritize upcoming reaction migration work so am not addressing unless you think it is neccessary @damassi |
||
/> | ||
</IconContainer> | ||
</Banner> | ||
</BannerContainer> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import React from "react" | ||
import { storiesOf } from "storybook/storiesOf" | ||
import { FlashBanner } from "Components/FlashBanner" | ||
|
||
storiesOf("Components/FlashBanner", module).add( | ||
"Successful Confirmation Message", | ||
() => { | ||
return <FlashBanner messageCode="confirmed" /> | ||
} | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { mount } from "enzyme" | ||
import "jest-styled-components" | ||
import React from "react" | ||
import { FlashBanner } from "../FlashBanner" | ||
|
||
describe("FlashBanner", () => { | ||
it("renders a banner based on a message code", () => { | ||
const wrapper = mount(<FlashBanner messageCode="confirmed" />) | ||
expect(wrapper.text()).toContain("Your email has been confirmed.") | ||
}) | ||
|
||
it("returns nothing without complaint if the message code is not supported", () => { | ||
const wrapper = mount(<FlashBanner messageCode={"bad_message" as any} />) | ||
expect(wrapper.html()).toBeNull() | ||
}) | ||
}) |
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.
why the union type here? Seems like these are all strings?