Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .talismanrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ fileignoreconfig:
- filename: .kontinuous/env/prod/templates/api.sealed-secret.yaml
checksum: f1dfe60bbe8a6604443fe3629b2239fa969304beeca8eff2b7528cf9b5728e3d
- filename: CHANGELOG.md
checksum: 441705e556a107db776bf6cbbf07db3cdd8a6048973824058e9917111d15cc80
checksum: af668c3480c223bf8e2e6bfd6942c7cfb95d50d751e48b305a8d36f5a1d1c675
- filename: README.md
checksum: 979473d3e8ad091d57424dc057cf0b40a884f0fbf6821554ea0121e63a173d6b
- filename: api/src/config.ts
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,4 @@
import React from "react";
import VeryGoodSvg from "../../assets/svg/veryGood.svg";
import GoodSvg from "../../assets/svg/good.svg";
import MiddleSvg from "../../assets/svg/middle.svg";
import BadSvg from "../../assets/svg/bad.svg";
import VeryBadSvg from "../../assets/svg/veryBad.svg";
import TodaySvg from "../../assets/svg/today.svg";
import YesterdaySvg from "../../assets/svg/yesterday.svg";
import NotesSvg from "../../assets/svg/notes.svg";
import DrugsSvg from "../../assets/svg/drugs.svg";
import HeartsSvg from "../../assets/svg/hearts.svg";
import PlusSvg from "../../assets/svg/plus-1.svg";
import QuestionMarkSvg from "../../assets/svg/QuestionMark.js";

import { StyleSheet, View } from "react-native";
Expand All @@ -18,6 +7,7 @@ import SmileyGood from "@assets/svg/smileys/good";
import SmileyMiddle from "@assets/svg/smileys/middle";
import SmileyBad from "@assets/svg/smileys/bad";
import SmileyVeryBad from "@assets/svg/smileys/veryBad";
import PlusIcon from "@assets/svg/icon/plus";

const styles = StyleSheet.create({
iconContainer: {
Expand All @@ -40,13 +30,8 @@ const mapIconToSvg = (icon) => {
MiddleSvg: SmileyMiddle,
BadSvg: SmileyBad,
VeryBadSvg: SmileyVeryBad,
TodaySvg,
YesterdaySvg,
NotesSvg,
DrugsSvg,
HeartsSvg,
PlusSvg,
QuestionMarkSvg,
Plus: PlusIcon,
};
return iconMap[icon];
};
Expand Down
3 changes: 3 additions & 0 deletions app/src/scenes/goals/status/GoalsStatus.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ export const GoalsStatus = ({ goalsData, date, withSeparator }) => {
const records = recordIds
.map((id) => goalsData?.records?.data?.[id])
.sort((a, b) => goalsData?.goals?.byOrder?.indexOf?.(a?.goalId) - goalsData?.goals?.byOrder?.indexOf?.(b?.goalId));
if (!records.length) {
return null;
}
return (
<>
{withSeparator && <Separator style={{ paddingHorizontal: 40 }} />}
Expand Down
19 changes: 3 additions & 16 deletions app/src/scenes/status/DiaryList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { DiaryDataAnswer } from "@/entities/DiaryData";
import { answers } from "../survey-v2/utils";
import { SquircleView } from "expo-squircle-view";
import { TW_COLORS } from "@/utils/constants";
import NewStatusItem from "./NewStatusItem";

export const DiaryList = forwardRef(({ ...props }, ref) => {
const navigation = useNavigation();
Expand Down Expand Up @@ -56,7 +57,7 @@ export const DiaryList = forwardRef(({ ...props }, ref) => {

const renderItem = useCallback(
({ item: date }) => {
const moodIndicator = indicateurs?.find((ind) => ind.uuid === INDICATEURS_HUMEUR.uuid);
const moodIndicator = indicateurs?.find((ind) => ind.active && ind.uuid === INDICATEURS_HUMEUR.uuid);
if (isToday(parseISO(date)) && !diaryData[date] && moodIndicator) {
return (
<SquircleView
Expand All @@ -76,21 +77,7 @@ export const DiaryList = forwardRef(({ ...props }, ref) => {
</SquircleView>
);
} else {
return (
<View>
<View style={styles.dateContainer}>
<View style={styles.dateDot} />
{canEdit(date) ? (
<Text style={styles.dateLabel}>{formatDateThread(date)}</Text>
) : (
<TouchableOpacity style={styles.item} onPress={() => navigation.navigate("too-late", { date })}>
<Text style={styles.dateLabel}>{formatDateThread(date)}</Text>
</TouchableOpacity>
)}
</View>
<StatusItem date={date} indicateurs={indicateurs} patientState={diaryData[date]} goalsData={goalsData} navigation={navigation} />
</View>
);
return <NewStatusItem date={date} indicateurs={indicateurs} patientState={diaryData[date]} goalsData={goalsData} navigation={navigation} />;
}
},
[diaryData, goalsData, indicateurs]
Expand Down
260 changes: 260 additions & 0 deletions app/src/scenes/status/NewStatusItem.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,260 @@
import React, { useEffect, useState, useRef } from "react";
import { StyleSheet, View, TouchableOpacity, Text } from "react-native";
import PatientStateItem from "./patient-state-item";
import { displayedCategories, TW_COLORS } from "../../utils/constants";
import Notes from "./notes";
import localStorage from "../../utils/localStorage";
import Posology from "./posology";
import { canEdit } from "./utils/index.js";
import Context from "./context";
import logEvents from "../../services/logEvents";
import {
GENERIC_INDICATOR_SUBSTANCE,
INDICATEURS_HUMEUR,
INDICATEURS_LIST,
STATIC_UUID_FOR_INSTANCE_OF_GENERIC_INDICATOR_SUBSTANCE,
} from "../../utils/liste_indicateurs.1";
import { GoalsStatus } from "../goals/status/GoalsStatus";
import { Card } from "../../components/Card";
import { GoalsStatusNoData } from "../goals/status/GoalsStatusNoData";
import { generateIndicatorFromPredefinedIndicator, Indicator } from "@/entities/Indicator";
import { DiaryDataAnswer, DiaryEntry } from "@/entities/DiaryData";
import { GoalRecordsData, GoalsData } from "@/entities/Goal";
import { BasicIcon } from "@/components/CircledIcon";
import { answers as emojis } from "../survey-v2/utils";
import { typography } from "@/utils/typography";
import { mergeClassNames } from "@/utils/className";
import { formatDateThread, formatRelativeDate } from "@/utils/date/helpers";
import ArrowIcon from "@assets/svg/icon/Arrow";
import { colors } from "@/utils/colors";
import { SquircleButton } from "expo-squircle-view";

export default ({
navigation,
indicateurs = [],
patientState,
goalsData,
date,
}: {
navigation: any;
indicateurs: Indicator[];
patientState: DiaryEntry;
goalsData: GoalsData;
date: Date;
}) => {
const [customs, setCustoms] = useState([]);
const [oldCustoms, setOldCustoms] = useState([]);
let mounted = useRef(true);

useEffect(() => {
(async () => {
const c = await localStorage.getCustomSymptoms();
if (c && mounted) setCustoms(c);

//retrocompatibility
const t = c.map((e) => `${e}_FREQUENCE`);
if (t && mounted) setOldCustoms(t);
return;
})();
return () => (mounted = false);
}, [patientState]);

const handleEdit = (tab, editingSurvey = false, toGoals) => {
if (!canEdit(date)) return;
const currentSurvey = {
date,
answers: patientState,
};
navigation.navigate(tab, {
currentSurvey,
editingSurvey,
toGoals,
});
};

const hasAnswerSurvey = () =>
patientStateRecordKeys.some((key) => patientState[key]?.value !== undefined) || goalsData?.records?.byDate?.[date]?.length > 0;

const handlePressItem = ({ editingSurvey, toGoals } = {}) => {
if (!canEdit(date)) return navigation.navigate("too-late", { date });
logEvents.logFeelingEditButtonClick();
handleEdit("day-survey", editingSurvey, toGoals);
};

// DiaryDataAnswer;
const patientStateRecordKeys = patientState
? Object.keys(patientState)
.filter((key) => {
return !["CONTEXT", "POSOLOGY", "NOTES", "PRISE_DE_TRAITEMENT", "PRISE_DE_TRAITEMENT_SI_BESOIN", "becks"].includes(key);
})
.filter((key) => !!patientState[key])
.filter((key) => key)
.sort((_a, _b) => {
const a = patientState[_a];
const b = patientState[_b];
const aIndex = indicateurs?.findIndex?.((indicateur) => indicateur?.uuid === a?._indicateur?.uuid) || 0;
const bIndex = indicateurs?.findIndex?.((indicateur) => indicateur?.uuid === b?._indicateur?.uuid) || 0;
return aIndex - bIndex;
})
: [];

if (hasAnswerSurvey()) {
const emotion = Object.keys(patientState).find(
(key) => (key === INDICATEURS_HUMEUR.uuid || key === INDICATEURS_HUMEUR.name) && patientState[key].value !== undefined
);
let emotionValue;
if (emotion) {
emotionValue = patientState[emotion].value;
}
return (
<SquircleButton
preserveSmoothing={true}
cornerSmoothing={100}
className="flex-col my-4 p-6"
style={{
borderColor: TW_COLORS.GRAY_500,
borderRadius: 20,
borderWidth: 1,
}}
onPress={() => handlePressItem({ editingSurvey: true })}
>
<View className="mb-4 flex-row justify-between">
<Text className={mergeClassNames(typography.textMdBold, "text-cnam-primary-950 capitalize")}>{formatRelativeDate(date)}</Text>
{canEdit(date) && <ArrowIcon />}
</View>
<View>
<View>
{patientStateRecordKeys.map((key) => {
let patientStateRecord = patientState[key];
if (!patientStateRecord || patientStateRecord?.value === null || patientStateRecord.value === undefined) {
return;
}
let [categoryName] = key.split("_");
if (categoryName === "TOXIC") {
// for user with historic value in 'TOXIC', we replace category name by uuid for indicator substance
key = STATIC_UUID_FOR_INSTANCE_OF_GENERIC_INDICATOR_SUBSTANCE;
patientStateRecord = {
...patientStateRecord,
_indicateur: {
...generateIndicatorFromPredefinedIndicator(GENERIC_INDICATOR_SUBSTANCE),
uuid: key,
},
};
}
const indicator = indicateurs.find((i) => i.genericUuid === key) || indicateurs.find((i) => i.uuid === key);
return (
<PatientStateItem
key={key}
category={key}
patientStateRecord={patientStateRecord}
label={
indicator?.name ||
patientStateRecord?._indicateur?.name ||
INDICATEURS_LIST[key] ||
displayedCategories[key] ||
categoryName ||
"Unknown Indicator"
}
/>
);
})}

<GoalsStatus goalsData={goalsData} date={date} withSeparator={patientStateRecordKeys?.length > 0} />
<Context data={patientState?.CONTEXT} />
<Posology posology={patientState?.POSOLOGY} patientState={patientState} date={date} onPress={() => handleEdit("drugs")} />
<Notes notes={patientState?.NOTES} date={date} onPress={() => handleEdit("notes")} />
</View>
</View>
</SquircleButton>
);
} else {
return (
<>
{canEdit(date) && (
<SquircleButton
preserveSmoothing={true}
cornerSmoothing={100}
style={{
borderColor: TW_COLORS.GRAY_500,
borderRadius: 20,
borderWidth: 1,
}}
className="flex-col my-4 p-6"
onPress={() => handlePressItem({ editingSurvey: true })}
>
<View className="mb-4 flex-row justify-between">
<Text className={mergeClassNames(typography.textMdBold, "text-cnam-primary-950 capitalize")}>{formatRelativeDate(date)}</Text>
<ArrowIcon />
</View>
<View className="flex-row items-center">
<BasicIcon
color={TW_COLORS.CNAM_CYAN_50_LIGHTEN_90}
borderColor={TW_COLORS.CNAM_PRIMARY_500}
iconColor={TW_COLORS.GRAY_950}
icon={"Plus"}
borderWidth={1}
iconContainerStyle={{ marginRight: 0 }}
iconWidth={32}
iconHeight={32}
/>
<View className="ml-2 p-2 flex-1">
<Text className={mergeClassNames(typography.textSmMedium, "text-cnam-primary-950")}>Complétez l'observation</Text>
</View>
</View>
</SquircleButton>
)}
{!canEdit(date) && (
<View>
<View style={styles.dateContainer}>
<View style={styles.dateDot} />
<TouchableOpacity onPress={() => navigation.navigate("too-late", { date })}>
<Text style={styles.dateLabel}>{formatDateThread(date)}</Text>
</TouchableOpacity>
</View>
<View style={styles.container}>
<View style={styles.emptyItem} />
</View>
</View>
)}
</>
);
}
};

const styles = StyleSheet.create({
emptyItem: {
marginVertical: 15,
},
itemWithSpaceAbove: {
marginTop: 25,
paddingTop: 20,
},
container: {
paddingLeft: 15,
marginLeft: 4,
borderLeftWidth: 0.4,
borderColor: "#00CEF7",
},
noDataContainer: {
marginVertical: 5,
paddingTop: 12,
paddingBottom: 39,
},
dateLabel: {
color: "#000",
fontSize: 13,
textAlign: "left",
paddingLeft: 10,
fontWeight: "600",
},
dateContainer: {
flexDirection: "row",
alignItems: "center",
},
dateDot: {
width: 8,
height: 8,
borderRadius: 4,
backgroundColor: colors.LIGHT_BLUE,
},
});
2 changes: 1 addition & 1 deletion app/src/scenes/status/context.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const styles = StyleSheet.create({
display: "flex",
justifyContent: "space-between",
alignItems: "flex-start",
paddingHorizontal: 20,
// paddingHorizontal: 20,
paddingVertical: 10,
},
divider: {
Expand Down
4 changes: 1 addition & 3 deletions app/src/scenes/status/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -253,9 +253,7 @@ const Status = ({ navigation, startSurvey }) => {
<NPS forceView={NPSvisible} close={() => setNPSvisible(false)} />
<Header title={"Mes observations 🌱"} navigation={navigation} scrollY={scrollY} scrollThreshold={75} />
<TabPicker ongletActif={ongletActif} onChange={setOngletActif} />
{noData() ? (
<NoData navigation={navigation} />
) : ongletActif === "all" && !bannerProNPSVisible ? (
{ongletActif === "all" && !bannerProNPSVisible ? (
<DiaryList
ListHeaderComponent={renderHeader}
ListFooterComponent={renderFooter}
Expand Down
2 changes: 1 addition & 1 deletion app/src/scenes/status/notes.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ const styles = StyleSheet.create({
flexDirection: "row",
justifyContent: "space-between",
alignItems: "center",
paddingHorizontal: 20,
// paddingHorizontal: 20,
},
textContainer: { width: "100%" },
boldText: { fontWeight: "bold" },
Expand Down
Loading
Loading