Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Write a generalised error handling/success notification component using react-hot-toast #27

Open
simenandre opened this issue Nov 19, 2021 · 1 comment

Comments

@simenandre
Copy link
Member

Moved here from indivorg/app#457. Originally created by @braaar

Currently, Alert requires a lot of manual implementation.

I think it could be useful to make a component that shows react-hot-toast notifications for common operations.

I think it would be simplest if this component can just take in the data, error and loading objects you get from query and mutation hooks:

const [
    updatePlanMutation,
    {data: updateData, loading: updateLoading, error: updateError},
  ] = useUpdatePlanMutation({
    variables: {
      id: planId, // value for 'id'
      plan: null, // value for 'plan'
      tenantId, // value for 'tenantId'
    },
  });

Not sure how we would want it to behave. Let's discuss!

For mutations (create, update, delete):

  • Start a progress/loading type animation when you submit the mutation.
  • Success check mark when complete
  • Red error message if error
  • Possibly show a link or other action in the toast ("User created! Click here to go to user")

For queries:

  • Show errors?
  • Loading progress is probably best reflected by having loading components like <Loading/>, etc..
@braaar
Copy link
Contributor

braaar commented Nov 23, 2021

I have already implemented some functions in app/src/services/toast-helpers.ts to make it easy to show toasts when we perform mutations. I'm not sure how an improved Alert component would look like, but I think there are some improvements that could be made.

What if we make the Skeleton component a part of this? If we get an error the skeletons can become orange or something?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants