1.11.7-beta.10 • Published 11 months ago

rex-coreui v1.11.7-beta.10

Weekly downloads
-
License
MIT
Repository
github
Last release
11 months ago

coreui

REX Core UI library

NPM JavaScript Style Guide

Install

npm install --save @referralexchange/coreui

yarn add @referralexchange/coreui

API

Currently in the funnel, we're using the API to get matches at /lead/funnel/get_matches/. We also need to include in the call the lead_uuid to get matches for:

def get_matches
  # Hit the API server to get the lead
  uuid = params[:uuid] ? params[:uuid] : @lead.uuid
  resp = CoreUtils::API.get(
    service: '/lead/funnel/get_matches/',
    data: {
      lead_uuid: uuid,
    }
  )

  data = resp.data

  render json: data
end

Usage

import React, { Component } from "react";

import {
  EnhancedAgentProfile,
  NormalAgentProfile,
} from "@referralexchange/coreui";

class Example extends Component {
  render() {
    const agent = {
      broker_name: "Mark McLaughlin",
      company_city: "Berkeley",
      company_name: "Pacific Union International",
      created_at: "2017-05-06T08:14:51.000-07:00",
      designations: "Realtor®#Realtor®",
      direct_line: "5105176202",
      email: "test@test.com",
      experience_in_community:
        "Berkeley, Oakland, Albany, El Cerrito, Kensington, Piedmont, Emeryville",
      hobbies: "DIY home updates, flea markets, gardening, crocheting",
      id: 1215685,
      bio: `Born and raised in the north of England (Mancheters area) - moved to California in 1990. Prior to real estate I held a variety of positions in technology related companies. My skill-sets includes software design and develpment, sales, marketing and relocation.

  A licensed Realtor since 2001, I now work with my daughter, Michelle, who has more than 20 years experience as a Realtor. We specialize in helping home buyers and sellers throughout the San Francisco East Bay to get the reults they are hoping for, with the minimum amount of stress.`,
      languages: "",
      license_state: "CA",
      match_id: 6127284,
      agent_datapoints: [],
      personal_family:
        "Bay Area native family, with husband at UC Berkeley and proud mom",
      phone_mobile: "4152254265",
      phone_office: "4152254265",
      photo_file_name:
        "https://s3.amazonaws.com/agentmachine_development_pclip/users/photos/005/189/416/original/760087-custom.jpg",
      specialties:
        "Buyer Representative#Condominiums#First Time Buyers#Relocation#Seller Representative",
      stats: { closed: 0, accept: 8, avg_match_price: 662500 },
      url: "",
      user: {
        email: "test@test.com",
        first_name: "Test",
        last_name: "User",
        phone_mobile: "4152254265",
        phone_office: "4152254265",
      },
      verified_company: {
        name: "Pacific Union International",
        address: "1625 Shattuck Ave #101",
        city: "Berkeley",
        zip: "94709",
      },
      years_in_real_estate: 10,
    };

    let name = agent.first_name || agent.user.first_name;

    if (agent.last_name) {
      name += " " + agent.last_name;
    } else if (agent.user.last_name) {
      name += " " + agent.user.last_name;
    }

    let leadName = this.state.user.first_name;

    if (this.state.user.last_name) {
      leadName += " " + this.state.user.last_name;
    }

    let firstName = agent.first_name || agent.user.first_name;
    return (
      <div>
        <EnhancedAgentProfile
          {...agent}
          trackFunnelUserAction={this.trackFunnelUserAction}
          first_name={firstName && firstName.toLocaleLowerCase().trim()}
          yearsOfExp={agent.years_in_real_estate}
          areas={[agent.company_city, agent.license_state].join(", ")}
          agentImg={agentImg}
          rank={index + 1}
          phone={
            agent.phone_mobile ||
            agent.phone_office ||
            (agent.user && agent.user.phone_mobile) ||
            (agent.user && agent.user.phone_office)
          }
          agentId={agent.id}
          createdAt={agent.created_at}
          buying={!this.state.leadInfo.created_seller}
          priceLow={this.state.lead.home_price_min}
          priceHigh={this.state.lead.home_price_max}
          leadName={leadName}
          location={location}
          broker={agent.company_name}
          email={agent.email || (agent.user && agent.user.email)}
          lightning={this.state.lightning}
          matchId={agent.match_id}
          trackEvent={this.trackEvent}
          trackFunnelUserAction={this.trackFunnelUserAction}
        />
        <div className={css(styles.spacer)} />
        <NormalAgentProfile
          {...agent}
          trackFunnelUserAction={this.trackFunnelUserAction}
          first_name={firstName && firstName.toLocaleLowerCase().trim()}
          yearsOfExp={agent.years_in_real_estate}
          areas={[agent.company_city, agent.license_state].join(", ")}
          agentImg={agent.photo_file_name}
          rank={index + 1}
          phone={
            agent.phone_mobile ||
            agent.phone_office ||
            (agent.user && agent.user.phone_mobile) ||
            (agent.user && agent.user.phone_office)
          }
          agentId={agent.id}
          createdAt={agent.created_at}
          buying={!this.state.leadInfo.created_seller}
          priceLow={this.state.lead.home_price_min}
          priceHigh={this.state.lead.home_price_max}
          leadName={leadName}
          location={location}
          broker={agent.company_name}
          email={agent.email || (agent.user && agent.user.email)}
          lightning={this.state.lightning}
          matchId={agent.match_id}
          trackEvent={this.trackEvent}
          trackFunnelUserAction={this.trackFunnelUserAction}
        />
      </div>
    );
  }
}