fossology / FOSSologyUI

Repository to hold the new UI framework for FOSSology built with React
https://fossology.github.io/FOSSologyUI/
GNU General Public License v2.0
49 stars 88 forks source link

added useAlert hook to display danger and success alerts #180

Closed pushkarsaneja closed 2 years ago

pushkarsaneja commented 2 years ago

References to the issues

157

155

154

Description

useAlert hook to display success and danger snackbars. The alert message disappears after 5 seconds or if the user closes the alert message.

Changes

Added an AlertProvider component that provides a useAlert() hook which uses react context under the hood. The hook returns a function alertUser(message,type) which accepts message and type as parameters.

Implementation

The alertUser() is implemented in Pages>Home>index.jsx at line 80 and 88. Other Alerts can be changed to use hooks as well (will do it after the code is reviewed).

https://user-images.githubusercontent.com/83173777/158048302-0c07cea4-b10c-4468-8f71-c626625ddf1a.mp4

github-actions[bot] commented 2 years ago

This pull request has conflicts, please rebase to resolve those before we can evaluate the pull request.