From 66a81fd8a3fcda2a0c7b711a460a7d24e3df420f Mon Sep 17 00:00:00 2001 From: Cristiano Tofani Date: Tue, 12 May 2020 18:39:27 +0200 Subject: [PATCH] [#172437575] Disables button to add a new favourite local services if 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 Co-authored-by: Matteo Boschi --- locales/en/index.yml | 1 + locales/it/index.yml | 1 + ts/components/services/ServicesSectionsList.tsx | 12 ++++++++++-- ts/components/services/ServicesTab.tsx | 1 + ts/screens/services/ServicesHomeScreen.tsx | 4 +--- 5 files changed, 14 insertions(+), 5 deletions(-) diff --git a/locales/en/index.yml b/locales/en/index.yml index 46c714300d0..f40b59c5303 100644 --- a/locales/en/index.yml +++ b/locales/en/index.yml @@ -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. diff --git a/locales/it/index.yml b/locales/it/index.yml index 7801e393e44..a8129f0ddc6 100644 --- a/locales/it/index.yml +++ b/locales/it/index.yml @@ -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. diff --git a/ts/components/services/ServicesSectionsList.tsx b/ts/components/services/ServicesSectionsList.tsx index e16bc4f9e40..14d78ce5d07 100644 --- a/ts/components/services/ServicesSectionsList.tsx +++ b/ts/components/services/ServicesSectionsList.tsx @@ -40,6 +40,7 @@ type OwnProps = { onRefresh: () => void; onSelect: (service: ServicePublic) => void; readServices: ReadStateByServicesId; + isSelectableOrgsEmpty?: boolean; }; type Props = AnimatedProps & OwnProps; @@ -85,7 +86,9 @@ class ServicesSectionsList extends React.PureComponent { this.props.isLocal && ( - {I18n.t("services.areasOfInterest.selectMessage")} + {this.props.isSelectableOrgsEmpty + ? I18n.t("services.areasOfInterest.selectMessageEmptyOrgs") + : I18n.t("services.areasOfInterest.selectMessage")} { style={styles.button} block={true} onPress={this.props.onChooserAreasOfInterestPress} + disabled={this.props.isSelectableOrgsEmpty} > @@ -134,7 +138,11 @@ class ServicesSectionsList extends React.PureComponent { 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 + } > {I18n.t("services.areasOfInterest.editButton")} diff --git a/ts/components/services/ServicesTab.tsx b/ts/components/services/ServicesTab.tsx index a68ec471bdd..53360c37cd4 100644 --- a/ts/components/services/ServicesTab.tsx +++ b/ts/components/services/ServicesTab.tsx @@ -228,6 +228,7 @@ class ServicesTab extends React.PureComponent { return ( { currentTabServicesId: [], isLongPressEnabled: false, enableServices: false, - toastErrorMessage: EMPTY_MESSAGE, + toastErrorMessage: I18n.t("global.genericError"), isInnerContentRendered: false }; }