import * as classNames from "classnames"; import * as _ from "lodash"; import * as React from "react"; import { Avatar, IAvatarProps } from "../Avatar"; import { Button, ButtonSize } from "../Button"; import { Form } from "../Form"; import { Loading, LoadingType } from "../Loading"; import { Pill, IPillProps } from "../Pill"; import { Pin, PinType } from "../Pin"; import { Reveal, RevealType } from "../Reveal"; import { Sheet, ISheetProps } from "../Sheet"; import { Link, LinkType, ILinkProps } from "../Link"; interface IPhotographerProps { avatar: IAvatarProps; sheet: ISheetProps; name: string; pill?: IPillProps; link?: Partial; promo?: string; request?: (data: any, complete: (success: boolean) => void) => void; onProfileBook?: () => void; onClose?: (navigation: string) => void; onFinish?: (success: boolean) => void; /** * Reset to the initial photographer "profile" screen when the sheet is closed */ resetOnClose?: boolean; /** * Instead of a 'Book' button, only an email link will be shown */ bookAsLink?: ILinkProps; } interface IPhotographerState { navigation: "profile" | "book" | "loader" | "success" | "failed"; } const defaultPhotographerState: IPhotographerState = { navigation: "profile", }; export class Photographer extends React.Component { public state: IPhotographerState = defaultPhotographerState; public render() { const { onCloseEnd, ...sheetProps } = this.props.sheet; return ( { if (_.isFunction(this.props.onClose)) { this.props.onClose(this.state.navigation); } if (_.isFunction(onCloseEnd)) { onCloseEnd(); } if (this.props.resetOnClose) { this.setState({ navigation: "profile", }); } }}>
{this.renderProfile(this.state.navigation === "profile")} {this.renderBook(this.state.navigation === "book")} {this.renderLoader(this.state.navigation === "loader")} {this.renderSuccess(this.state.navigation === "success")} {this.renderFailed(this.state.navigation === "failed")}
); } private renderProfile = (active: boolean) => { return (

{this.props.name}

{this.props.link && (
)} {this.props.promo && (
{this.props.promo}
)}
{this.props.bookAsLink ? ( ) : (
); } private renderBook = (active: boolean) => { return (
Book Photographer
Let us know how to contact you so we can book it.
{ if (_.isFunction(this.props.request)) { this.setState({ navigation: "loader" }) this.props.request(data, (success: boolean) => { this.setState({ navigation: success ? "success" : "failed" }) }); } }} selects={[ { isSearchable: false, id: "photographer-select", supertext: "Contact via", defaultValue: { value: "email", label: "Email", input: { id: "photographer-email", supertext: "Email", type: "email", placeholder: "Enter your email", required: true, }, }, defaultOptions: [ { value: "email", label: "Email", input: { id: "photographer-email", supertext: "Email", type: "email", placeholder: "Enter your email", required: true, }, }, { value: "sms", label: "SMS", input: { id: "photographer-sms", supertext: "Phone Number", type: "tel", placeholder: "Enter your number", required: true, } }, { value: "call", label: "Call", input: { id: "photographer-call", supertext: "Phone Number", type: "tel", placeholder: "Enter your number", required: true, } }, ], } ]} submit={{ text: "Book" }} /> ); } private renderLoader = (active: boolean) => { return ( ); } private renderSuccess = (active: boolean) => { return (
Request Sent
We will follow up with you shortly.
); } private renderFailed = (active: boolean) => { return (
Something went wrong!
Please try again shortly.
); } }