1.16.2 • Published 4 months ago

@comparaonline/recommended-offers v1.16.2

Weekly downloads
-
License
-
Repository
github
Last release
4 months ago

Bricks | Car insurance recommended offers

npm

This library contains car insurance recommended offers.

Installation

You can install it using:

npm

npm install @comparaonline/recommended-offers

yarn

yarn add @comparaonline/recommended-offers

or the package manager of your choice

Usage

Simple example, providing a token and refreshToken to persist session and fully enable functionality:

import { useEffect, useRef } from 'react';
import RecommendedOffers from '@comparaonline/recommended-offers/react';
import '@comparaonline/recommended-offers/css';
import './App.css';

const ENVIRONMENT = 'set-your-environment';

export function App() {
  const containerRef = useRef(null);
  const environment = ENVIRONMENT === 'staging' ? 'staging' : 'production';
  const baseUrl =
    environment === 'staging'
      ? 'https://cotizador-staging.comparaonline.com'
      : 'https://cotizador.comparaonline.com';

  useEffect(() => {
    (async () => {
      const res = await fetch(baseUrl + '/octopus-prime/auth/login', {
        method: 'POST',
        headers: {
          Accept: 'application/json',
          'Content-Type': 'application/json',
        },
        body: JSON.stringify({
          username: 'not-a-valid-user',
          password: 'not-a-valid-password',
        }),
      });
      const data = await res.json();

      const brick = new RecommendedOffers({
        ...data,
        styles: { primaryColor: 'orange' },
        environment: environment,
      });
      if (containerRef.current) brick.init(containerRef.current);
    })();
  }, []);

  return <div className="App" id="App" ref={containerRef}></div>;
}

RecommendedOffers instance accepts a configuration object that has this structure:

export interface RecommendedOffersConfiguration {
  styles?: {
    theme?: 'dark' | 'light';
    primaryColor?: string;
  };
  texts?: {
    title?: string;
    description?: string;
    moreOffers?: string;
    success?: {
      title?: string;
      description?: string;
      seeOffers?: string;
      quoteAgain?: string;
    };
    error?: {
      title?: string;
      description?: string;
      understand?: string;
    };
  };
  lang?: 'es' | 'pt';
  token: string;
  environment?: 'staging' | 'production';
  refreshToken?: string;
}

styles let you define the theme, also its primaryColor, while lang let you pick between spanish(es) and portuguese(pt), and texts lets you define custom title, captions, button texts and others.

1.16.2

4 months ago

1.16.1

4 months ago

1.16.0

4 months ago

1.15.1

4 months ago

1.15.0

4 months ago

1.14.0

5 months ago

1.13.0

5 months ago

1.12.0

5 months ago

1.11.4

6 months ago

1.11.3

6 months ago

1.11.2

6 months ago

1.10.3

6 months ago

1.11.1

6 months ago

1.10.2

6 months ago

1.11.5

6 months ago

1.9.0

7 months ago

1.8.1

7 months ago

1.6.3

8 months ago

1.2.7

10 months ago

1.8.0

7 months ago

1.6.2

8 months ago

1.2.6

10 months ago

1.7.0

8 months ago

1.6.1

9 months ago

1.2.5

10 months ago

1.6.0

9 months ago

1.2.4

11 months ago

1.5.0

10 months ago

1.4.0

10 months ago

1.3.0

10 months ago

1.11.0

6 months ago

1.10.0

6 months ago

1.2.3

11 months ago

1.2.2

11 months ago

1.2.1

11 months ago

1.2.0

11 months ago

1.1.1

11 months ago

1.1.0

11 months ago

1.0.4

11 months ago

1.0.2

11 months ago

1.0.3

11 months ago

1.0.1

11 months ago

1.10.1

11 months ago