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

uxi-business

v2.0.1

Published

[![npm version](https://badge.fury.io/js/uxi-business.svg)](https://badge.fury.io/js/uxi-business) [![CircleCI](https://circleci.com/gh/uxilab/uxi.svg?style=svg)](https://circleci.com/gh/uxilab/uxi-business) --- # uxi-business

Downloads

277

Readme

npm version CircleCI

uxi-business

Common business component that are 'ready' to use and follow UX best practises.

  • signin ok
  • forgot ok
  • find client by id : ok
  • save url : ok
  • signup user :
  • reset pwd : ok

Provider

In order to use uxi-business component library you need to se the UxiBusinessProvider component.

It comes with a default context which does 'nothing'. It is up to the consumer to configue how the list of component should behave.

Example:

   import { UxiBusinessProvider } from 'uxi-business';

   const MyApp = () => (
     <UxiBusinessProvider log={(e) => {console.log(e)}} onSessionExpired={() => {alert('test)}}>
       <Application />
     </UxiBusinessProvider>
   )

Here are the list of contextual props that you can override:

  • log: used when you want to log something
  • onSessionExpired: used when the session of the user has overidden or because a defualt handler throws a 401 in a REST API request.
  • logoutUrl: the URL used to logout the user.
  • loginUrl: the URL used to redirect ot a signin page.

Error Handling

Module related on how to handle errors in your application.

withDefaultErrorHandler

HOC which decorates any component and show an Error Message if the component throw a JS exception. This component has the duty to avoid having the whole page breaking due to an violation error.

You can use it this way:

   import { withDefaultErrorHandler } from 'uxi-business/errorHandling';

   const MyComponent = () => {

     throw new Error("Oh snap");
   };

   export default withDefaultErrorHandler(MyComponent);

withDefaultCatch

Takes a promise and add a default catch for a fetch method.

const fetchUser = withDefaultCatch(fetch('/users.json'));

The defaultCatch provides a default behaviors in terms of error for a fetch request.

Used from the action withDefaultErrorHandlingActions from User Message module, it will give you a set of default messages for common succes/error messages.

User Message

Module related to the Message you want to send to your user (success/warning/error/info).

import {
  reducer as userMessage,
  UserMessageProvider,
} from 'uxi-business/userMessage';
import { showSuccess, showWarning, showError, showInfo } from 'uxi-business/userMessage/actions';

const rootReducer = combineReducers({
  form: formReducer,
  userMessage,
});

const store = createStore(rootReducer)

const App = () => (
  <Provider store={store}>
    <UserMessageProvider>
      <h1>Title</h1>
      <button onClick={() => {dispatch(showSuccess('Good job!'))}}>Trigger some actions</button>
    </UserMessageProvider>
  </Provider>
);

render(<App />, document.getElementById('root'));

Redux Actions

showSuccess

Show a sucess message

showWarning

Show a warning message

showError

Show an Error message

showInfo

Show an info message

Default REST error handling

  • HTTP Status : 200 => success message
  • HTTP Status : 202 => warning queue message
  • HTTP Status : 403 => access denied error message
  • HTTP Status : 404 => entity notfound error message
  • HTTP Status : 409 => conflict error message
  • HTTP Status : 5xx => unknow error message
  • HTTP Status : 4xx => unknow error message

How to decorate my action to receive the default User Message behavior?

  • User the method withDefaultCatch
  • Decorate your thunk (redux) with withDefaultErrorHandlingActions

Example:

import { withDefaultCatch } from 'uxi-business/errorHandling';
import { withDefaultErrorHandlingActions } from 'uxi-business/userMessage/actions';


export const shouldFetchUser = withDefaultErrorHandlingActions((dispatch) => (
  withDefaultCatch(fetch('/users.json')).then((data) => {
    dispatch({
      type: 'RECEIVE_USER',
      data,
    })
  }))
));