-
Notifications
You must be signed in to change notification settings - Fork 106
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[#172992641] Check bonus eligibility #1841
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
7d754dd
#172962750 Create feature-flag for "bonus vacanze" & stub for folder …
fabriziofff 722a5ea
#172962750 move sagas folder under store.
fabriziofff 5043bff
Merge branch 'master' into 172962750-feature-flag-bonus-vacanze
Undermaken 0b8dcb8
Merge branch '172962750-feature-flag-bonus-vacanze' into 172992641-ch…
fabriziofff 7878a1c
Merge remote-tracking branch 'origin/master' into 172992641-check-bon…
fabriziofff d740985
Add CheckBonusEligibilityScreen
fabriziofff 976873c
Update locales/it/index.yml
fabriziofff File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
54 changes: 54 additions & 0 deletions
54
ts/features/bonusVacanze/components/GenericLoadingErrorScreen.tsx
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,54 @@ | ||
import { View } from "native-base"; | ||
import * as React from "react"; | ||
import { StyleSheet } from "react-native"; | ||
import { withLoadingSpinner } from "../../../components/helpers/withLoadingSpinner"; | ||
import GenericErrorComponent from "../../../components/screens/GenericErrorComponent"; | ||
import customVariables from "../../../theme/variables"; | ||
|
||
type Props = { | ||
isLoading: boolean; | ||
loadingCaption?: string; | ||
loadingOpacity?: number; | ||
errorText?: string; | ||
onRetry: () => void; | ||
onCancel?: () => void; | ||
}; | ||
|
||
const styles = StyleSheet.create({ | ||
main: { | ||
backgroundColor: customVariables.colorWhite, | ||
flex: 1, | ||
position: "absolute", | ||
top: 0, | ||
bottom: 0, | ||
left: 0, | ||
right: 0 | ||
} | ||
}); | ||
/** | ||
* This component is a generic error component composed with a loading. | ||
* In this way it is testable regardless of how it will be connected to the application flow. | ||
* This component, when {@link Props.isLoading} display a loading overlay, hiding the background, using | ||
* {@link withLoadingSpinner}. | ||
* When {@link Props.isLoading} is false, display a {@link GenericErrorComponent} displaying the reasons of the error | ||
* and two buttons to cancel the operation or retry. | ||
* @param props | ||
* @constructor | ||
*/ | ||
const InnerGenericLoadingErrorScreen: React.FunctionComponent< | ||
Props | ||
> = props => { | ||
return ( | ||
<View style={styles.main}> | ||
<GenericErrorComponent | ||
onRetry={props.onRetry} | ||
onCancel={props.onCancel} | ||
text={props.errorText} | ||
/> | ||
</View> | ||
); | ||
}; | ||
|
||
export const GenericLoadingErrorScreen = withLoadingSpinner( | ||
InnerGenericLoadingErrorScreen | ||
); |
52 changes: 52 additions & 0 deletions
52
ts/features/bonusVacanze/screens/CheckBonusEligibilityScreen.tsx
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,52 @@ | ||
import * as React from "react"; | ||
import { connect } from "react-redux"; | ||
import { Dispatch } from "redux"; | ||
import { RTron } from "../../../boot/configureStoreAndPersistor"; | ||
import I18n from "../../../i18n"; | ||
import { GlobalState } from "../../../store/reducers/types"; | ||
import { GenericLoadingErrorScreen } from "../components/GenericLoadingErrorScreen"; | ||
|
||
type Props = ReturnType<typeof mapDispatchToProps> & | ||
ReturnType<typeof mapStateToProps>; | ||
|
||
const loadingCaption = I18n.t( | ||
"bonus.bonusVacanza.checkBonusEligibility.loading" | ||
); | ||
/** | ||
* This component link the generic {@link GenericLoadingErrorScreen} with the application flow using the {@link connect} | ||
* of redux. | ||
* @param props | ||
* @constructor | ||
*/ | ||
const CheckBonusEligibilityScreen: React.FunctionComponent<Props> = props => { | ||
return ( | ||
<GenericLoadingErrorScreen | ||
{...props} | ||
loadingCaption={loadingCaption} | ||
loadingOpacity={1} | ||
/> | ||
); | ||
}; | ||
|
||
const mapDispatchToProps = (_: Dispatch) => ({ | ||
// TODO: link with the right dispatch action | ||
onCancel: () => { | ||
RTron.log("CANCEL"); | ||
}, | ||
// TODO: link with the right dispatch action | ||
onRetry: () => { | ||
RTron.log("RETRY"); | ||
} | ||
}); | ||
|
||
const mapStateToProps = (_: GlobalState) => ({ | ||
// TODO: link with the right reducer | ||
isLoading: true, | ||
// TODO: link with the right reducer | ||
errorText: "A text that explains why the operation failed" | ||
}); | ||
|
||
export default connect( | ||
mapStateToProps, | ||
mapDispatchToProps | ||
)(CheckBonusEligibilityScreen); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess the error could be a network error, otherwise we should receive a response from our backend.
Could it be a solution to show an error toast informing the user that something went wrong?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we want to have a generic error, I can remove the
errorText
and use the default message used within theGenericErrorComponent
("Ooops, qualcosa è andato storto! Probabilmente è un errore momentaneo, riprova per piacere!"). In this case we can also avoid a toast that which would repeat the error information. What you think?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good!