# react-metrc-link

> A modal that a backend url can be passed into to verify Metrc credentials

Latest version **1.0.9** (published 2021-08-13) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-metrc-link
pnpm add react-metrc-link
yarn add react-metrc-link
bun add react-metrc-link
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.9 |
| Published | 2021-08-13 |
| First published | 2021-07-01 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 2.1 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Melanie MacDonald |
| Maintainers | mmacdonald1 |
| Keywords | react, typescript, npm |

## Links

- npm: https://www.npmjs.com/package/react-metrc-link
- Repository: https://github.com/Terrayn-eng/react-metrc-link
- Homepage: https://github.com/Terrayn-eng/react-metrc-link#readme
- Issues: https://github.com/Terrayn-eng/react-metrc-link/issues
- npm.io page: https://npm.io/package/react-metrc-link

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 1.0.9 (latest) — 2021-08-13
- 1.0.8 — 2021-07-19
- 1.0.7 — 2021-07-06
- 1.0.6 — 2021-07-06
- 1.0.5 — 2021-07-06
- 1.0.4 — 2021-07-01
- 1.0.3 — 2021-07-01
- 1.0.2 — 2021-07-01
- 1.0.1 — 2021-07-01
- 1.0.0 — 2021-07-01

## README

# React Metrc Link

A React button and modal designed to take in Metrc User Key and State and output those credentials if they are accurate.

Pairs with a python package [metrc-client-python](https://pypi.org/project/metrc-client-python/) for the backend.


![](https://media.giphy.com/media/1Z12CZEvvxqFAa5dli/giphy.gif)

## Getting Started

Install package in React app using
```npm i react-metrc-link```

In desired component, import the Metrc component
```
import {MetrcLink} from 'react-metrc-link'
```
Then add the component to the render method with the required props
```
<MetrcLink 
  callback={handleCallback}  
  states={states} 
  backendUrl='http://127.0.0.1:5000/user_key'
  companyName= 'Terrayn'
/>
```

## Required Props
  * Callback - function with 1 arguement - pass in a function that can recieve back a response object
  example:
  ```
  const handleCallback = (resp) =>{
    console.log(resp.state, resp.user_key)
  }
  ```
  where resp will be 
  ```
  {
    user_key:'...',
    state:'CO'
  }
  ```
  * States - array of strings - The states that you have Metrc Vendor Keys for in the backend server. Use state initials in uppercase format.

  * Backend Url - string - The url to send the user_key and state object to in order to verify credentials

  * Company Name - string - The app name or company name you want the modal copy to refer to

  ## Non Required Props

  * Privacy Policy Link - string - a link to an end user privacy policy. Will add text to first screen that by continuing user agrees to linked privacy policy.

  * Label - string - Button text

  * Background Color - string - Button background color

  * Color - string - Button text color

  * Font Family - string - Button Font (only takes websafe fonts)

  * Font Weight - number - Button font weight

  * Border - string - Button border

  * Border Radius - string - Button border radius

  * Line Height - number - Button text line height

  * Letter Spacing - string - Button text letter spacing

  * Font Size - string - Button font size
  
  * Padding - string - Button padding

  * Margin - string - Button margin

## Example Component with all available props

```
import React from 'react';
import './App.css';
import {MetrcLink} from 'react-metrc-link'

function App() {

  const handleCallback = (resp) =>{
    console.log(resp.state, resp.user_key)
  }

  const states =['CO','OR','CA','AK']

  return (
    <div>
      <MetrcLink 
        callback={handleCallback} 
        states={states} 
        backendUrl='http://127.0.0.1:5000/user_key'
        companyName='Terrayn'
        privacyPolicyLink='https://www.google.com'
        label='Link with Metrc'
        backgroundColor='#68c86b'
        color='#fff'
        fontFamily='Helvetica, sans-serif'
        fontWeight='40'
        border='none'
        borderRadius='3em'
        lineHeight='1'
        letterSpacing='0.5px'
        fontSize='16px'
        padding='12px 74px'
        margin='0px'
      />
    </div>
  );
}

export default App;
```

## Response

If request is successful response will be a 200 with a body of 

```
 {
    user_key:'...',
    state:'CO'
  }
```
where user_key and state are the values the user entered.

Otherwise the response will be a 500 and the modal will send the user to re-enter their credentials.

## Attributions

Package created by partnership between [Terrayn](https://terrayn.com) and [Lendica](https://golendica.com)

Designs by [Anna Stapor](https://www.linkedin.com/in/anna-stapor-65b462172/)

Illustrations by [Undraw](https://undraw.co/)

---
_Source: https://npm.io/package/react-metrc-link · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
