From ed597bfa8a31a50d8f13e1440c8d2047d299399d Mon Sep 17 00:00:00 2001 From: keplyx Date: Thu, 1 Aug 2019 11:04:27 +0200 Subject: [PATCH] Changed data source for proximo to use proximo's website --- components/FetchedDataSectionList.js | 1 + screens/Proximo/ProximoListScreen.js | 10 ++--- screens/Proximo/ProximoMainScreen.js | 62 +++++++++++++++------------- translations/en.json | 3 +- translations/fr.json | 3 +- 5 files changed, 44 insertions(+), 35 deletions(-) diff --git a/components/FetchedDataSectionList.js b/components/FetchedDataSectionList.js index 553571a..a41dfe3 100644 --- a/components/FetchedDataSectionList.js +++ b/components/FetchedDataSectionList.js @@ -27,6 +27,7 @@ export default class FetchedDataSectionList extends React.Component { { - console.log(IMG_URL + item.name + '.jpg') + console.log(item.image) }} > - + {item.name} + + {item.quantity + ' ' + i18n.t('proximoScreen.inStock')} + diff --git a/screens/Proximo/ProximoMainScreen.js b/screens/Proximo/ProximoMainScreen.js index 05cd745..4ea9c04 100644 --- a/screens/Proximo/ProximoMainScreen.js +++ b/screens/Proximo/ProximoMainScreen.js @@ -1,12 +1,13 @@ // @flow import * as React from 'react'; +import {View} from 'react-native' import {Badge, Body, H2, Left, ListItem, Right, Text} from 'native-base'; import i18n from "i18n-js"; import CustomMaterialIcon from "../../components/CustomMaterialIcon"; import FetchedDataSectionList from "../../components/FetchedDataSectionList"; -const DATA_URL = "https://etud.insa-toulouse.fr/~vergnet/appli-amicale/dataProximo.json"; +const DATA_URL = "https://srv-falcon.etud.insa-toulouse.fr/~proximo/data/stock.json"; const typesIcons = { Nouveau: "alert-decagram", @@ -78,33 +79,38 @@ export default class ProximoMainScreen extends FetchedDataSectionList { } getRenderItem(item: Object, section : Object, data : Object) { - return ( - { - this.props.navigation.navigate('ProximoListScreen', item); - }} - > - - - - - - {item.type} - - - {item.data.length} {item.data.length > 1 ? i18n.t('proximoScreen.articles') : i18n.t('proximoScreen.article')} - - - - - - - ); + if (item.data.length > 0) { + return ( + { + this.props.navigation.navigate('ProximoListScreen', item); + }} + > + + + + + + {item.type} + + + {item.data.length} {item.data.length > 1 ? i18n.t('proximoScreen.articles') : i18n.t('proximoScreen.article')} + + + + + + + ); + } else { + return ; + } + } getRenderSectionHeader(title: String) { diff --git a/translations/en.json b/translations/en.json index bd0387f..f354422 100644 --- a/translations/en.json +++ b/translations/en.json @@ -49,7 +49,8 @@ "listUpdated": "Article list updated!", "listUpdateFail": "Error while updating article list", "loading": "Loading...", - "listTitle": "Choose a category" + "listTitle": "Choose a category", + "inStock": "in stock" }, "proxiwashScreen": { "dryer": "Dryer", diff --git a/translations/fr.json b/translations/fr.json index 8224d4e..d49a2ae 100644 --- a/translations/fr.json +++ b/translations/fr.json @@ -49,7 +49,8 @@ "listUpdated": "Liste d'articles mise à jour !", "listUpdateFail": "Erreur lors de la mise à jour de la list d'articles", "loading": "Chargement...", - "listTitle": "Choisissez une catégorie" + "listTitle": "Choisissez une catégorie", + "inStock": "en stock" }, "proxiwashScreen": { "dryer": "Sèche Linge",