Fix ListWithoutSelect
continuous-integration/drone/push Build is passing Details

pull/24/head^2
Louison PARANT 1 year ago
parent 704f8d9682
commit b7e51a2fa0

@ -84,7 +84,6 @@ export default function FiltersSelection(props) {
}) })
await AsyncStorage.setItem('profiles', JSON.stringify(profiles)); await AsyncStorage.setItem('profiles', JSON.stringify(profiles));
fetchProfiles() fetchProfiles()
console.log("handleSaveSelectedProfiles: __________________________________________________")
EventEmitter.emit("selectedProfilesUpdated") EventEmitter.emit("selectedProfilesUpdated")
} catch (error) { } catch (error) {
console.error('Error occured when updating active profiles:', error); console.error('Error occured when updating active profiles:', error);
@ -95,8 +94,8 @@ export default function FiltersSelection(props) {
updateDiets() updateDiets()
updateAllergies() updateAllergies()
EventEmitter.emit("updateDietsAllergies") EventEmitter.emit("updateDietsAllergies")
console.log("Filters Selection: -------------------------------------------------")
isSelectedProfilesUpdated = true isSelectedProfilesUpdated = true
console.log("Filters Selection: ---------------------------------------------------")
subscriptionUpdateProfiles.remove(); subscriptionUpdateProfiles.remove();
EventEmitter.removeAllListeners('profileAdded') EventEmitter.removeAllListeners('profileAdded')
EventEmitter.removeAllListeners('updateDietsAllergies') EventEmitter.removeAllListeners('updateDietsAllergies')
@ -111,12 +110,12 @@ export default function FiltersSelection(props) {
profile.diets.forEach((diet) => { profile.diets.forEach((diet) => {
retType = true retType = true
dieTemp.forEach((val) => { dieTemp.forEach((val) => {
if(val.value == diet){ if(val == diet){
retType = false retType = false
} }
}) })
if(retType){ if(retType){
dieTemp.push({value: diet}) dieTemp.push(diet)
} }
}) })
} }
@ -132,12 +131,12 @@ export default function FiltersSelection(props) {
profile.allergies.forEach((allergy) => { profile.allergies.forEach((allergy) => {
retType = true retType = true
allTemp.forEach((val) => { allTemp.forEach((val) => {
if(val.value == allergy){ if(val == allergy){
retType = false retType = false
} }
}) })
if(retType){ if(retType){
allTemp.push({value: allergy}) allTemp.push(allergy)
} }
}) })
} }
@ -185,8 +184,8 @@ export default function FiltersSelection(props) {
function isInProfileDiets(element) { function isInProfileDiets(element) {
let retType = true let retType = true
dieProfiles.forEach(function (diet) { dieProfiles.forEach((diet) => {
if(diet.value==element.value){ if(diet==element.value){
retType = false retType = false
} }
}) })
@ -305,9 +304,9 @@ export default function FiltersSelection(props) {
<Text style={styles.filters}>Additional Filters</Text> <Text style={styles.filters}>Additional Filters</Text>
<Text style={styles.nbSelected}>{dieAdd.length} available</Text> <Text style={styles.nbSelected}>{dieAdd.length} available</Text>
</View> </View>
<ListSelect title="Diets" content={dieAdd} setSelected={handleSelectedDiets}/> <ListSelect title="Additional Diets" content={dieAdd} setSelected={handleSelectedDiets}/>
<View style={{marginTop: "3%"}}/> <View style={{marginTop: "3%"}}/>
<ListWithoutSelect title="Allergies" content={allAdd}></ListWithoutSelect> <ListWithoutSelect title="Additional Allergies" content={allAdd}></ListWithoutSelect>
<View style={{marginTop: "3%"}}/> <View style={{marginTop: "3%"}}/>
<ValidateButton title="Add Allergy" image="plus.png" colour={colors.buttonDetail} backColour={colors.buttonBackground} todo={() => props.navigation.navigate("IngredientSelection")}></ValidateButton> <ValidateButton title="Add Allergy" image="plus.png" colour={colors.buttonDetail} backColour={colors.buttonBackground} todo={() => props.navigation.navigate("IngredientSelection")}></ValidateButton>
</View> </View>

@ -121,7 +121,6 @@ export default function HomePage({ navigation, props }) {
const subscriptionUpdateSelectedProfile = EventEmitter.addListener('selectedProfilesUpdated', async () => { const subscriptionUpdateSelectedProfile = EventEmitter.addListener('selectedProfilesUpdated', async () => {
fetchProfiles(); fetchProfiles();
console.log("Home Page: ===================================================================")
subscriptionUpdateSelectedProfile.remove(); subscriptionUpdateSelectedProfile.remove();
EventEmitter.removeAllListeners('profileAdded') EventEmitter.removeAllListeners('profileAdded')
EventEmitter.removeAllListeners('profileDeleted') EventEmitter.removeAllListeners('profileDeleted')

Loading…
Cancel
Save