npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

reufy-memed-react

v1.0.3

Published

React library to integrate with memed

Downloads

16

Readme

reufy-memed-react

reufy-memed-react é uma biblioteca desenvolvida para o ecossistema React com o objetivo de ajudar na integração com o serviço de prescrição médica online da Memed. Algumas etapas da homologação já são feitas pela lib, como a desativação de algumas funções, adesão dos dados do paciente antes do módulo estar liberado para uso, e a criação do script em execução que carregam as instancias MdHub e MdSinapsePrescricao, responsáveis por alguns bindings de eventos e commandos.

Instalação

Para instalar a biblioteca via yarn ou npm basta rodar no seu terminal:


npm  install  reufy-memed-react

ou


yarn  add  reufy-memed-react

Uso

A biblioteca garante que o script será criado, e o módulo liberado somente quando as funções setDoctorToken e setPatient forem chamadas com os respectivos valores. As funções podem ser obtidas do hook useMemed após seu componente estar sendo encapsulado pelo MemedProvider. Você pode acionar o módulo de prescrição passando uma ref do seu botão ou usando as funções showPrescription e hidePrescription para abrir e fechar o módulo de forma imperativa. Você consegue controlar o estado de inicialização do módulo usando a variável loadingModule.

Hook useMemed

Um exemplo utilizando a Refs:


import  React  from  'react'

import  Button  from  '@material-ui/core/Button'

import { useMemed } from  'reufy-memed-react'

  

import { Patient } from  '@patient/domain/Patient'

  

interface  PrescriptionButtonProps {

patient: Patient;

}

  

export  default  function  PrescriptionButton(props: PrescriptionButtonProps): React.ReactElement {

const { patient } = props

const  buttonRef = React.useRef(null)

const { setActionRef, setDoctorToken, setPatient, loadingModule } = useMemed()

  

React.useEffect(() => {

async  function  fetchDoctorToken() {

const  response = await  fetch('<SUA_API>/doctor/token')

const  token = await  response.json()

setDoctorToken(token)

setActionRef(buttonRef)

setPatient({

nome:  patient.name,

endereco:  patient.address?.streetAddress || '',

cidade:  patient.address?.city || '',

telefone:  patient.phoneNumber,

altura:  patient.height,

idExterno:  patient.identityDocument

})

}

  

if (patient) {

fetchDoctorToken()

}

}, [patient, setDoctorToken, setActionRef, setPatient])

  

return (

<Button  ref={buttonRef}  disabled={loadingModule}>

{loadingModule ? 'Loading...' : 'Prescrição'}

</Button>

)

}

Provider


import  React  from  'react'

import  ReactDOM  from  'react-dom'

import  MemedProvider  from  'reufy-memed-react'

  

ReactDOM.render(

<MemedProvider  color="#00B8D6"  scriptSrc={productionSrc}  scriptId={scriptId}>

<App  />

</MemedProvider>,

root

)

Embora as props sejam opcionais, você deve trocar scriptSrc para o src de produção após pegar as chaves de produção. Do contrário o default será a URL de sandbox da memed.

Licença

MIT

A empresa Memed não é resposável por atualizações dessa biblioteca. Qualquer atualização da lib principal que possa quebrar a execução dessa biblioteca é de minha responsabilidade e dos colaboradores. Caso você queira fazer a integração diretamente com os módulos oficiais, acesse esse link.