-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into kiram15/ENT-8657
- Loading branch information
Showing
28 changed files
with
740 additions
and
32 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
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
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
40 changes: 40 additions & 0 deletions
40
...mponents/learner-credit-management/data/hooks/useSuccessfulInvitationToastContextValue.js
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,40 @@ | ||
import { useCallback, useMemo, useState } from 'react'; | ||
import { makePlural } from '../../../../utils'; | ||
|
||
const useSuccessfulInvitationToastContextValue = () => { | ||
const [isToastOpen, setIsToastOpen] = useState(false); | ||
const [learnersInvitedCount, setLearnersInvitedCount] = useState(0); | ||
|
||
const handleDisplayToast = useCallback(({ totalLearnersInvited }) => { | ||
setLearnersInvitedCount(totalLearnersInvited); | ||
setIsToastOpen(true); | ||
}, []); | ||
|
||
const handleCloseToast = useCallback(() => { | ||
setIsToastOpen(false); | ||
}, []); | ||
|
||
const toastMessages = []; | ||
if (learnersInvitedCount > 0) { | ||
toastMessages.push(`${makePlural(learnersInvitedCount, 'new member')} successfully added.`); | ||
} | ||
const successfulInvitationToastMessage = toastMessages.join(' '); | ||
|
||
const successfulInvitationToast = useMemo(() => ({ | ||
isSuccessfulInvitationToastOpen: isToastOpen, | ||
displayToastForInvitation: handleDisplayToast, | ||
closeToastForInvitation: handleCloseToast, | ||
totalLearnersInvited: learnersInvitedCount, | ||
successfulInvitationToastMessage, | ||
}), [ | ||
isToastOpen, | ||
handleDisplayToast, | ||
handleCloseToast, | ||
learnersInvitedCount, | ||
successfulInvitationToastMessage, | ||
]); | ||
|
||
return successfulInvitationToast; | ||
}; | ||
|
||
export default useSuccessfulInvitationToastContextValue; |
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.