0.7.6 • Published 3 years ago

@hindawi/phenom-communications-ui v0.7.6

Weekly downloads
245
License
-
Repository
-
Last release
3 years ago

phenom-communications-ui

This library has the core ui component that interacts with the phenom-communications-backend

Installing

To install the component simply use

npm i @hindawi/phenom-communications-ui

Using the component

Import dependencies

import { MailTemplate, TemplateName } from '@hindawi/phenom-communications-ui';
import { ApolloClient, InMemoryCache } from '@apollo/client';

Import CSS

import '@hindawi/phenom-communications-ui/phenom-communications-ui.umd.css';

Instantiate a new apollo client

Old versions of apollo/client also work

const client = new ApolloClient({
  uri: 'http://localhost:4200/graphql',
  cache: new InMemoryCache(),
});

Pass the props to the component

<MailTemplate
  visible={true}
  mailMetadata={{
    templateName: TemplateName.invitationToHandleManuscript,
    mailInput: {
      to: {
        email: 'receiver@hindawi.com',
        name: 'Author',
      },
      from: {
        email: 'sender@hindawi.com',
        name: 'Triage Editor',
      },
      manuscript: {
        manuscriptId: '22222',
        manuscriptTitle: 'Manuscript title',
        journalName: 'Journal name',
        submittingAuthor: 'Jane Doe',
        authors: [
          { name: 'Jane Abc', affiliation: 'Multiverse' },
          { name: 'John Doe', affiliation: 'MyAffiliation' },
          { name: 'Anne Doe', affiliation: 'MyAffiliation' },
        ],
        abstract: 'abstract',
      },
    },
  }}
  client={client}
  onClose={() => {}}
  onBeforeSendMail={async () => {}}
  onSendEmail={(data, e) => {}}
  onError={(err) => {}}
/>

Using render props

Using render props will not display the component, but will provide access to the sendMail function.

<MailTemplate
  mailMetadata={{
    templateName: TemplateName.editorInvitationAccepted,
    mailInput: {
      to: {
        email: 'receiver@hindawi.com',
        name: 'Receiver',
      },
      from: {
        email: 'sender@hindawi.com',
        name: 'Sender Editor',
      },
      manuscript: {
        manuscriptId: '22222',
        manuscriptTitle: 'Manuscript title',
        journalName: 'Journal name',
        submittingAuthor: 'Jane Doe',
        comments: 'This is my comment',
        authors: [
          { name: 'Jane Abc', affiliation: 'Multiverse' },
          { name: 'John Doe', affiliation: 'MyAffiliation' },
          { name: 'Anne Doe', affiliation: 'MyAffiliation' },
        ],
        abstract: 'abstract',
      },
    },
  }}
  client={client}
  onBeforeSendMail={async () => {
    console.log('test before');
  }}
  onSendEmail={(data, e) => console.log(data, e)}
  onError={(err) => console.log(err)}
>
  {(handleSendMail) => (
    <button
      onClick={() => {
        handleSendMail();
      }}
    >
      Send email directly
    </button>
  )}
</MailTemplate>

Props

PropType
visible?boolean
mailMetadataTemplateInputDto
clientany apollo client
onClose?(e: React.MouseEvent<HTMLElement, MouseEvent>) => void
onBeforeSendMail?(e: React.MouseEvent<HTMLElement, MouseEvent>) => Promise<void>
onSendMail?(response: any) => void
onSendEmail?(data: SendMailResponseDto, e: React.MouseEvent<HTMLElement, MouseEvent>) => void
0.7.6

3 years ago

0.7.5

3 years ago

0.7.4

3 years ago

0.7.3

3 years ago

0.7.2

3 years ago

0.7.1

3 years ago

0.7.0

3 years ago

0.6.15

3 years ago

0.6.14

3 years ago

0.6.12

3 years ago

0.6.13

3 years ago

0.6.10

3 years ago

0.6.11

3 years ago

0.6.9

3 years ago

0.6.8

3 years ago

0.6.7

3 years ago

0.6.6

3 years ago

0.6.5

3 years ago

0.6.3

3 years ago

0.6.2

3 years ago

0.6.4

3 years ago

0.5.0

3 years ago

0.4.0

3 years ago

0.6.1

3 years ago

0.5.1

3 years ago

0.3.2

3 years ago

0.3.1

3 years ago

0.3.0

3 years ago

0.2.0

3 years ago

0.1.0

3 years ago

0.1.13

3 years ago

0.1.14

3 years ago

0.1.15

3 years ago

0.1.12

3 years ago

0.1.11

3 years ago

0.1.10

3 years ago

0.1.8

3 years ago

0.1.7

3 years ago

0.1.9

3 years ago

0.1.6

3 years ago

0.1.5

3 years ago

0.1.4

3 years ago