Use a switch for returns
This commit is contained in:
@@ -46,22 +46,10 @@ export function TranslatedPost({
|
|||||||
[post, langPrefs.primaryLanguage],
|
[post, langPrefs.primaryLanguage],
|
||||||
)
|
)
|
||||||
|
|
||||||
if (translationState.status === 'error') {
|
switch (translationState.status) {
|
||||||
return (
|
case 'loading':
|
||||||
<TranslationError
|
|
||||||
clearTranslation={clearTranslation}
|
|
||||||
message={translationState.message}
|
|
||||||
postText={postText}
|
|
||||||
primaryLanguage={langPrefs.primaryLanguage}
|
|
||||||
/>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (translationState.status === 'loading') {
|
|
||||||
return <TranslationLoading />
|
return <TranslationLoading />
|
||||||
}
|
case 'success':
|
||||||
|
|
||||||
if (translationState.status === 'success') {
|
|
||||||
return (
|
return (
|
||||||
<TranslationResult
|
<TranslationResult
|
||||||
clearTranslation={clearTranslation}
|
clearTranslation={clearTranslation}
|
||||||
@@ -71,8 +59,16 @@ export function TranslatedPost({
|
|||||||
translatedText={translationState.translatedText}
|
translatedText={translationState.translatedText}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
}
|
case 'error':
|
||||||
|
return (
|
||||||
|
<TranslationError
|
||||||
|
clearTranslation={clearTranslation}
|
||||||
|
message={translationState.message}
|
||||||
|
postText={postText}
|
||||||
|
primaryLanguage={langPrefs.primaryLanguage}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
default:
|
||||||
return (
|
return (
|
||||||
needsTranslation && (
|
needsTranslation && (
|
||||||
<TranslationLink
|
<TranslationLink
|
||||||
@@ -83,6 +79,7 @@ export function TranslatedPost({
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function TranslationLoading() {
|
function TranslationLoading() {
|
||||||
const t = useTheme()
|
const t = useTheme()
|
||||||
|
|||||||
Reference in New Issue
Block a user