-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1579572
commit 08155a3
Showing
18 changed files
with
169 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import {UPDATE_TOAST} from './types' | ||
|
||
export const updateToast = (showToast = false, type = "success", message = "") => ({ | ||
type:UPDATE_TOAST, | ||
payload:{ | ||
showToast:showToast, | ||
message:message, | ||
type:type | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import {UPDATE_TOAST } from '../actions/types' | ||
import reducerRegistry from './ReducerRegistry' | ||
const INIT_STATE = { | ||
showToast:false, | ||
message:"", | ||
type:"success" | ||
} | ||
|
||
const reducerName = 'toastReducer' | ||
|
||
export default function toastReducer(state = INIT_STATE, action) { | ||
switch (action.type) { | ||
case UPDATE_TOAST: | ||
return { | ||
...state, | ||
showToast:action.payload.showToast, | ||
message:action.payload.message, | ||
type:action.payload.type | ||
} | ||
default: | ||
return { | ||
...state, | ||
} | ||
} | ||
} | ||
reducerRegistry.register(reducerName, toastReducer) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import React, { useEffect } from 'react' | ||
import { ToastContainer , toast} from "react-toastify"; | ||
import {useSelector, useDispatch} from 'react-redux' | ||
import { useTranslation } from 'react-i18next'; | ||
import {updateToast} from 'Redux/actions/ToastAction' | ||
function GluuToast(){ | ||
const dispatch = useDispatch(); | ||
const { t } = useTranslation() | ||
const {showToast, message, type} = useSelector(state => state.toastReducer) | ||
|
||
const ToastDesign = () => { | ||
return ( | ||
<div style={{textAlign:"left"}}> | ||
<strong>{type == 'success' ? "Success" : "Error" }</strong><br/> | ||
{message == "" ? type == "success" ? t('messages.success_in_saving') : t('messages.error_in_saving') : message} | ||
</div> | ||
) | ||
} | ||
const showTheToast = () => { | ||
if(type == "success"){ | ||
toast.success(<ToastDesign />) | ||
}else{ | ||
toast.error(<ToastDesign />) | ||
} | ||
} | ||
|
||
useEffect(() => { | ||
if(showToast){ | ||
showTheToast(); | ||
dispatch(updateToast(false, 'success', '')) | ||
|
||
} | ||
},[showToast]) | ||
|
||
return ( | ||
<ToastContainer | ||
autoClose={10000} | ||
closeOnClick | ||
newestOnTop | ||
draggable={false} | ||
/> | ||
) | ||
} | ||
|
||
export default GluuToast; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.