-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(webapp): show a message when select a language with an incomplet…
…e translation
- Loading branch information
1 parent
2e874e1
commit 5273496
Showing
7 changed files
with
70 additions
and
3 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
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,31 @@ | ||
import { useTranslation } from 'react-i18next' | ||
|
||
import { useSharedState } from '../../context/state.context' | ||
import { useSnackbarMessageState } from '../../context/snackbar-message.context' | ||
import { generalConfig } from '../../config' | ||
|
||
const useAlertTranslationState = () => { | ||
const [{ translationinProgress }, { updateTranslationAlertsState }] = | ||
useSharedState() | ||
const [, { showMessage }] = useSnackbarMessageState() | ||
const { t } = useTranslation('') | ||
|
||
const showAlertMessage = (language, ignoreStatus = false) => { | ||
if (!generalConfig.languagesInProgress.includes(language)) return | ||
if (!ignoreStatus && translationinProgress?.isAlertShown[language]) return | ||
|
||
showMessage({ | ||
type: 'info', | ||
content: t('translationInProgress'), | ||
anchorOrigin: { | ||
vertical: 'top', | ||
horizontal: 'center', | ||
} | ||
}) | ||
updateTranslationAlertsState(language) | ||
} | ||
|
||
return [{}, { showAlertMessage }] | ||
} | ||
|
||
export default useAlertTranslationState |
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