1.13.2 • Published 2 months ago

@comparaonline/cico-quote v1.13.2

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

Bricks | Car insurance Colombia quote form

npm

This library contains car insurance quote form split in three (3) steps.

Installation

You can install it using:

npm

npm install @comparaonline/cico-quote

yarn

yarn add @comparaonline/cico-quote

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 CICOQuote from '@comparaonline/cico-quote/react';
import '@comparaonline/cico-quote/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 CICOQuote({
        ...data,
        stepsDisplay: true,
        styles: { primaryColor: 'orange', mode: 'light' },
        environment: environment,
      });
      if (containerRef.current) brick.init(containerRef.current);
    })();
  }, []);

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

CICOQuote instance accepts a configuration object that has this structure:

export interface CICOQuoteConfiguration {
  stepsDisplay?: boolean;
  theme?: {
    container?: HTMLElement;
    darkContainer?: HTMLElement;
    mode?: 'dark' | 'light';
    primaryColor?: string;
  };
  lang?: 'es' | 'pt';
  token: string;
  environment?: 'staging' | 'production';
  refreshToken?: string;
}

Prop details

PropDescription
stepsDisplayAllows you to define the form display, it can be 3 steps form or single form.
themeSee theme config details
langLet you pick between spanish(es) and portuguese(pt).
environmentLet you pick between developing enviroments overwriting react env variable
can be staging for testing purposes and the default is production.

Theme details

PropDescription
containerBy default all css variables and the id this component needs are loaded to a div element within this component, that act like the parent element for the rest of elements. You can pass any html element to load this properties ex: document.documentElement.
darkContainerBy default the dark class and the color scheme this component needs to work with the dark mode are loaded to a div element within this component. Important this element must be a child of the container, preferably a direct child
modeLet you pick between dark or light mode. The default value is light
primaryColorLet you override the primary color value. Warning: This changes the css variable value, Since this package utilize TailwindCSS also change the value of the primary color. Possible affected class: primary-100, primary-200.
1.13.2

2 months ago

1.13.1

4 months ago

1.13.0

4 months ago

1.12.1

4 months ago

1.12.0

4 months ago

1.11.0

4 months ago

1.10.0

5 months ago

1.9.1

6 months ago

1.2.8

10 months ago

1.9.0

6 months ago

1.2.7

10 months ago

1.8.0

6 months ago

1.6.2

8 months ago

1.2.6

10 months ago

1.7.0

7 months ago

1.6.1

8 months ago

1.6.0

8 months ago

1.4.2

10 months ago

1.5.0

10 months ago

1.4.1

10 months ago

1.3.2

10 months ago

1.4.0

10 months ago

1.3.1

10 months ago

1.3.0

10 months ago

1.9.4

6 months ago

1.9.3

6 months ago

1.9.2

6 months ago

1.2.9

10 months ago

1.2.10

10 months ago

1.2.11

10 months ago

1.2.5

10 months ago

1.2.4

10 months ago

1.2.3

10 months ago

1.2.2

10 months ago

1.2.0

11 months ago

1.1.1

11 months ago

1.1.0

11 months ago

1.2.1

10 months ago

1.0.10

11 months ago

1.0.9

11 months ago

1.0.8

11 months ago

1.0.7

11 months ago

1.0.6

11 months ago

1.0.5

11 months ago

1.0.4

11 months ago

1.0.3

11 months ago

1.0.2

11 months ago