Added jsdocs and proptypes
This commit is contained in:
1 parent
8bd8c292b8
commit
91abe374f6
2 files changed
+31
No files matched your search
@@ -1,6 +1,16 @@
|
||||
import PropTypes from "prop-types";
|
||||
import { toast } from "react-toastify";
|
||||
import Alert from "../Components/Alert";
|
||||
|
||||
/**
|
||||
* @param {object} props
|
||||
* @param {'info' | 'error' | 'warning'} - The variant of the alert (e.g., "info", "error").
|
||||
* @param {string} props.title - The title of the alert.
|
||||
* @param {string} props.body - The body/content of the alert.
|
||||
* @param {boolean} props.hasIcon - Whether the alert should include an icon.
|
||||
* @param {object} [props.config] - Additional configuration props for the toast.
|
||||
*/
|
||||
|
||||
export const createToast = ({ variant, title, body, hasIcon, config = {} }) => {
|
||||
const toastConfig = {
|
||||
position: "bottom-right",
|
||||
@@ -24,3 +34,11 @@ export const createToast = ({ variant, title, body, hasIcon, config = {} }) => {
|
||||
toastConfig
|
||||
);
|
||||
};
|
||||
|
||||
createToast.propTypes = {
|
||||
variant: PropTypes.oneOf(["info", "error", "warning"]).isRequired,
|
||||
title: PropTypes.string,
|
||||
body: PropTypes.string,
|
||||
hasIcon: PropTypes.bool,
|
||||
config: PropTypes.object,
|
||||
};
|
||||
Reference in new issue
Block a user