From a8b7961f66ae32986b17f67c60e138ec4622c3a8 Mon Sep 17 00:00:00 2001 From: Eric Rosenbaum Date: Fri, 20 Aug 2021 14:04:09 -0400 Subject: [PATCH] alerts default to 6 seconds --- src/components/alert/alert-provider.jsx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/components/alert/alert-provider.jsx b/src/components/alert/alert-provider.jsx index 2a75acd80..f6649f049 100644 --- a/src/components/alert/alert-provider.jsx +++ b/src/components/alert/alert-provider.jsx @@ -4,6 +4,8 @@ import PropTypes from 'prop-types'; import AlertStatus from './alert-status.js'; import AlertContext from './alert-context.js'; +const DEFAULT_TIMEOUT_SECONDS = 6; + const AlertProvider = ({children}) => { const defaultState = { status: AlertStatus.NONE, @@ -19,7 +21,7 @@ const AlertProvider = ({children}) => { setState(defaultState); }; - const handleAlert = (status, data, timeoutSeconds = 3) => { + const handleAlert = (status, data, timeoutSeconds = DEFAULT_TIMEOUT_SECONDS) => { if (timeoutRef.current) clearTimeout(timeoutRef.current); setState({status, data, showClear: !timeoutSeconds}); if (timeoutSeconds) { @@ -37,9 +39,9 @@ const AlertProvider = ({children}) => { data: state.data, showClear: state.showClear, clearAlert: clearAlert, - successAlert: (newData, timeoutSeconds = 3) => + successAlert: (newData, timeoutSeconds = DEFAULT_TIMEOUT_SECONDS) => handleAlert(AlertStatus.SUCCESS, newData, timeoutSeconds), - errorAlert: (newData, timeoutSeconds = 3) => + errorAlert: (newData, timeoutSeconds = DEFAULT_TIMEOUT_SECONDS) => handleAlert(AlertStatus.ERROR, newData, timeoutSeconds) }} >