Skip to content

Commit

Permalink
[#172437575] Disables button to add a new favourite local services if…
Browse files Browse the repository at this point in the history
… no orgs available (#1791)

* Fix red empty toast

* [#172437575] Disables button to add a new favourite local services if no orgs available

* Fixes lint

* Update locales/en/index.yml

Co-authored-by: Matteo Boschi <[email protected]>

Co-authored-by: Matteo Boschi <[email protected]>
  • Loading branch information
CrisTofani and Undermaken authored May 12, 2020
1 parent 2c6f9f3 commit 66a81fd
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 5 deletions.
1 change: 1 addition & 0 deletions locales/en/index.yml
Original file line number Diff line number Diff line change
Expand Up @@ -960,6 +960,7 @@ services:
contactPhone: Phone
areasOfInterest:
selectMessage: Choose the geographical areas (municipalities, regions, etc.) where you reside or that you usually visit to see the relative services here. You can change them at any time.
selectMessageEmptyOrgs: At the moment it is not possible to add a location. Please pull down to refresh the data and try again.
addButton: Add your areas of interest
editButton: Change the areas of interest
searchEmpty: If you do not find your area of interest, it means that the organizations of that territory do not yet exhibit services on IO.
Expand Down
1 change: 1 addition & 0 deletions locales/it/index.yml
Original file line number Diff line number Diff line change
Expand Up @@ -996,6 +996,7 @@ services:
contactPhone: Telefono
areasOfInterest:
selectMessage: Scegli le aree geografiche (comuni, regioni, etc.) dove risiedi o che frequenti solitamente per vederne qui i relativi servizi. Potrai modificarle in ogni momento.
selectMessageEmptyOrgs: Al momento non è possibile aggiungere una località. Per favore trascina in basso per aggiornare i dati e riprova a selezionare un'area.
addButton: Aggiungi le tue aree di interesse
editButton: Modifica le aree di interesse
searchEmpty: Se non trovi la tua area di interesse, significa che gli enti di quel territorio non espongono ancora servizi su IO.
Expand Down
12 changes: 10 additions & 2 deletions ts/components/services/ServicesSectionsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ type OwnProps = {
onRefresh: () => void;
onSelect: (service: ServicePublic) => void;
readServices: ReadStateByServicesId;
isSelectableOrgsEmpty?: boolean;
};

type Props = AnimatedProps & OwnProps;
Expand Down Expand Up @@ -85,7 +86,9 @@ class ServicesSectionsList extends React.PureComponent<Props> {
this.props.isLocal && (
<View style={styles.headerContentWrapper}>
<Text style={styles.message}>
{I18n.t("services.areasOfInterest.selectMessage")}
{this.props.isSelectableOrgsEmpty
? I18n.t("services.areasOfInterest.selectMessageEmptyOrgs")
: I18n.t("services.areasOfInterest.selectMessage")}
</Text>
<View spacer={true} large={true} />
<ButtonDefaultOpacity
Expand All @@ -94,6 +97,7 @@ class ServicesSectionsList extends React.PureComponent<Props> {
style={styles.button}
block={true}
onPress={this.props.onChooserAreasOfInterestPress}
disabled={this.props.isSelectableOrgsEmpty}
>
<IconFont name="io-plus" style={styles.icon} />
<Text style={styles.textButton}>
Expand Down Expand Up @@ -134,7 +138,11 @@ class ServicesSectionsList extends React.PureComponent<Props> {
style={styles.button}
block={true}
onPress={this.props.onChooserAreasOfInterestPress}
disabled={this.props.isRefreshing || this.props.isLongPressEnabled}
disabled={
this.props.isRefreshing ||
this.props.isLongPressEnabled ||
this.props.isSelectableOrgsEmpty
}
>
<Text style={styles.textButton}>
{I18n.t("services.areasOfInterest.editButton")}
Expand Down
1 change: 1 addition & 0 deletions ts/components/services/ServicesTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ class ServicesTab extends React.PureComponent<Props> {
return (
<ServicesSectionsList
isLocal={this.props.isLocal}
isSelectableOrgsEmpty={this.props.selectableOrganizations.length === 0}
isAll={this.props.isAll}
sections={this.props.sections}
profile={this.props.profile}
Expand Down
4 changes: 1 addition & 3 deletions ts/screens/services/ServicesHomeScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,6 @@ type DataLoadFailure =
| "userMetadaLoadFailure"
| undefined;

const EMPTY_MESSAGE = "";

const styles = StyleSheet.create({
container: {
flex: 1
Expand Down Expand Up @@ -252,7 +250,7 @@ class ServicesHomeScreen extends React.Component<Props, State> {
currentTabServicesId: [],
isLongPressEnabled: false,
enableServices: false,
toastErrorMessage: EMPTY_MESSAGE,
toastErrorMessage: I18n.t("global.genericError"),
isInnerContentRendered: false
};
}
Expand Down

0 comments on commit 66a81fd

Please sign in to comment.