Skip to content

Commit

Permalink
fix(questionnaire): ajouter substance dans le questionnaire et enleve…
Browse files Browse the repository at this point in the history
…r étape intermédiaire avec les notes
  • Loading branch information
tangimds committed Jan 6, 2022
1 parent a656764 commit 01c0c51
Show file tree
Hide file tree
Showing 8 changed files with 807 additions and 220 deletions.
3 changes: 1 addition & 2 deletions src/scenes/drugs/drugs.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,11 @@ const Drugs = ({navigation, route}) => {

const previousQuestion = () => {
if (route?.params?.backRedirect) {
console.log(route?.params?.backRedirect);
navigation.navigate(route?.params?.backRedirect, {
...route.params,
});
} else {
navigation.navigate('tabs');
navigation.goBack();
}
};

Expand Down
84 changes: 38 additions & 46 deletions src/scenes/status/notes.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,7 @@ const Notes = ({notes, date, onPress}) => {
!notes?.notesSymptoms &&
!notes?.notesToxic)
) {
if (canEdit(date)) {
return (
<TouchableOpacity onPress={onPress} style={styles.container}>
<View style={styles.label}>
<Icon
icon="NotesSvg"
color="#58C8D2"
width={20}
height={20}
styleContainer={styles.icon}
/>
<Text>Ajouter une note</Text>
</View>
<ArrowRightSvg color="#C7CED5" />
</TouchableOpacity>
);
} else {
return null;
}
return null;
}

const Note = ({title, text}) => {
Expand All @@ -47,33 +29,36 @@ const Notes = ({notes, date, onPress}) => {
};

return (
<TouchableOpacity
style={[
styles.container,
canEdit(date) && {
borderRadius: 10,
},
]}
onPress={onPress}
disabled={!canEdit(date)}>
<Icon
icon="NotesSvg"
color="#58C8D2"
width={20}
height={20}
styleContainer={styles.icon}
/>
{typeof notes === String ? (
//Retro compatibility
<Text style={styles.text}>{notes}</Text>
) : (
<View style={styles.textContainer}>
<Note title="Contexte" text={notes.notesEvents} />
<Note title="Ressentis" text={notes.notesSymptoms} />
<Note title="Toxique" text={notes.notesToxic} />
</View>
)}
</TouchableOpacity>
<>
<View style={styles.divider} />
<TouchableOpacity
style={[
styles.container,
canEdit(date) && {
borderRadius: 10,
},
]}
onPress={onPress}
disabled={!canEdit(date)}>
<Icon
icon="NotesSvg"
color="#58C8D2"
width={20}
height={20}
styleContainer={styles.icon}
/>
{typeof notes === String ? (
//Retro compatibility
<Text style={styles.text}>{notes}</Text>
) : (
<View style={styles.textContainer}>
<Note title="Contexte" text={notes.notesEvents} />
<Note title="Ressentis" text={notes.notesSymptoms} />
<Note title="Toxique" text={notes.notesToxic} />
</View>
)}
</TouchableOpacity>
</>
);
};

Expand All @@ -94,6 +79,13 @@ const styles = StyleSheet.create({
textContainer: {width: '100%'},
boldText: {fontWeight: 'bold'},
italic: {fontStyle: 'italic'},
divider: {
height: 1,
backgroundColor: '#6BD1F3',
marginVertical: 10,
width: '60%',
alignSelf: 'center',
},
});

export default Notes;
11 changes: 2 additions & 9 deletions src/scenes/status/status-item.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import localStorage from '../../utils/localStorage';
import Posology from './posology';
import {canEdit} from './utils/index.js';
import Button from '../../components/RoundButtonIcon';
import Toxic from './toxic';

export default ({navigation, patientState, date}) => {
const [customs, setCustoms] = useState([]);
Expand Down Expand Up @@ -35,7 +36,6 @@ export default ({navigation, patientState, date}) => {
};
navigation.navigate(tab, {
currentSurvey,
redirect: true,
});
};
const hasAnswerSurvey = () =>
Expand Down Expand Up @@ -72,12 +72,12 @@ export default ({navigation, patientState, date}) => {
/>
);
})}
<Toxic data={patientState?.TOXIC} />
<Posology
data={patientState?.POSOLOGY}
date={date}
onPress={() => handleEdit('drugs')}
/>
<View style={styles.divider} />
<Notes
notes={patientState?.NOTES}
date={date}
Expand Down Expand Up @@ -129,11 +129,4 @@ const styles = StyleSheet.create({
borderLeftWidth: 0.4,
borderColor: '#00CEF7',
},
divider: {
height: 1,
backgroundColor: '#6BD1F3',
marginVertical: 10,
width: '60%',
alignSelf: 'center',
},
});
51 changes: 51 additions & 0 deletions src/scenes/status/toxic.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import React from 'react';
import {StyleSheet, View} from 'react-native';
import Text from '../../components/MyText';

const Toxic = ({data}) => {
if (!data || !data.value) return null;

const Detail = ({title, text}) => {
if (!text) return null;
return (
<Text>
<Text style={styles.boldText}>{title} : </Text>
<Text style={styles.italic}>{text}</Text>
</Text>
);
};

return (
<>
<View style={styles.divider} />
<View style={styles.container}>
<View style={styles.textContainer}>
<Detail title="Substances" text={data.userComment || 'Oui'} />
</View>
</View>
</>
);
};

const styles = StyleSheet.create({
container: {
display: 'flex',
flexDirection: 'row',
justifyContent: 'space-between',
alignItems: 'center',
paddingHorizontal: 20,
paddingVertical: 10,
},
textContainer: {width: '100%'},
boldText: {fontWeight: 'bold'},
italic: {fontStyle: 'italic'},
divider: {
height: 1,
backgroundColor: '#6BD1F3',
marginVertical: 10,
width: '60%',
alignSelf: 'center',
},
});

export default Toxic;
Loading

0 comments on commit 01c0c51

Please sign in to comment.