Skip to content

Commit

Permalink
fix: inability to refresh custom forms on or offline
Browse files Browse the repository at this point in the history
  • Loading branch information
hopetambala committed Feb 4, 2021
1 parent 71eee85 commit 21c85e9
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 6 deletions.
14 changes: 12 additions & 2 deletions domains/DataCollection/FormGallery/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
} from 'react-native';
import {
Button, Card,
IconButton,
Paragraph, Text, Title
} from 'react-native-paper';

Expand All @@ -15,7 +16,7 @@ import { layout, theme } from '../../../modules/theme';

const FormGallery = (props) => {
const {
navigateToNewRecord, navigateToCustomForm, puenteForms, customForms
navigateToNewRecord, navigateToCustomForm, puenteForms, customForms, refreshCustomForms
} = props;
return (
<View>
Expand All @@ -28,7 +29,16 @@ const FormGallery = (props) => {
/>
</View>
<View style={layout.screenRow}>
<Text style={styles.header}>{I18n.t('formsGallery.customForms')}</Text>
<View style={{ flexDirection: 'row' }}>
<Text style={styles.header}>{I18n.t('formsGallery.customForms')}</Text>
<IconButton
style={{ bottom: 7 }}
color={theme.colors.primary}
size={20}
icon="refresh"
onPress={refreshCustomForms}
/>
</View>
<ScrollView horizontal>
{customForms && customForms.map((form) => (
<Card
Expand Down
9 changes: 7 additions & 2 deletions domains/DataCollection/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,12 @@ const DataCollection = ({ navigation }) => {
getData('currentUser').then((user) => {
setSurveyingUser(`${user.firstname || ''} ${user.lastname || ''}`);
});

getData('organization').then((org) => {
setSurveyingOrganization(org || surveyingOrganization);
}).catch(() => {
setSurveyingOrganization(surveyingOrganization || '');
});
customFormsQuery(surveyingOrganization).then((forms) => {
getData('customForms').then((forms) => {
setCustomForms(forms);
});
}, [surveyingUser, surveyingOrganization]);
Expand Down Expand Up @@ -115,6 +114,11 @@ const DataCollection = ({ navigation }) => {
});
};

const refreshCustomForms = async () => {
customFormsQuery(surveyingOrganization).then((forms) => {
setCustomForms(forms);
});
};
const logOut = () => {
retrieveSignOutFunction().then(() => {
navigation.navigate('Sign In');
Expand Down Expand Up @@ -220,6 +224,7 @@ const DataCollection = ({ navigation }) => {
navigateToCustomForm={navigateToCustomForm}
puenteForms={puenteForms}
customForms={customForms}
refreshCustomForms={refreshCustomForms}
/>
</View>
)}
Expand Down
3 changes: 2 additions & 1 deletion modules/i18n/english/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"lName": "Last Name",
"city": "City",
"commName": "Community Name",
"notes": "Notes"
"notes": "Notes",
"refresh": "Refresh"
},
"signUp": {
"firstName": "First Name",
Expand Down
3 changes: 2 additions & 1 deletion modules/i18n/spanish/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"lName": "Apellido",
"city": "Ciudad",
"commName": "Nombre de comunidad",
"notes": "Notas"
"notes": "Notas",
"refresh": "Actualiza"
},
"signUp": {
"firstName": "Nombre de verdadero",
Expand Down

0 comments on commit 21c85e9

Please sign in to comment.