-
Notifications
You must be signed in to change notification settings - Fork 8
feat(status-item): integrate new status-item design #444
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR introduces a new status item design with significant refactoring of the CircledIcon component and a new NewStatusItem component. However, the implementation contains several critical issues including hardcoded placeholder data, missing React keys, potential memory leaks, and extensive commented-out code that suggests the feature is incomplete. The NewStatusItem component appears to contain debugging/placeholder code that shouldn't be in production.
{[0, 1, 2, 3].map((item) => ( | ||
<View className="flex-1 flex-row items-center mb-2"> | ||
<View className="h-3 w-3 rounded-full mr-2 bg-red"></View> | ||
<View> | ||
<Text>Anxiété, Irritabilité</Text> | ||
</View> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This hardcoded text and the map over [0,1,2,3] appears to be placeholder/debug code. Hardcoded strings like 'Anxiété, Accablement, Contrariété, Jalousie,' should be replaced with dynamic data or at minimum moved to constants.
{[0, 1, 2, 3].map((item) => ( | |
<View className="flex-1 flex-row items-center mb-2"> | |
<View className="h-3 w-3 rounded-full mr-2 bg-red"></View> | |
<View> | |
<Text>Anxiété, Irritabilité</Text> | |
</View> | |
{patientStateRecordKeys.map((key) => { | |
let patientStateRecord = patientState[key]; | |
if (!patientStateRecord || patientStateRecord?.value === null || patientStateRecord.value === undefined) { | |
return null; | |
} | |
const indicator = indicateurs.find((i) => i.genericUuid === key) || indicateurs.find((i) => i.uuid === key); | |
return ( | |
<View key={key} className="flex-1 flex-row items-center mb-2"> | |
<View className="h-3 w-3 rounded-full mr-2 bg-red"></View> | |
<View> | |
<Text>{indicator?.name || 'Unknown Indicator'}</Text> | |
</View> |
/> | ||
)} | ||
<View className="ml-2 p-2 flex-1"> | ||
<Text className={mergeClassNames(typography.textSmMedium, "text-cnam-primary-950")}>Anxiété, Accablement, Contrariété, Jalousie,</Text> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hardcoded placeholder text should be replaced with dynamic data based on the actual patient state indicators.
<Text className={mergeClassNames(typography.textSmMedium, "text-cnam-primary-950")}>Anxiété, Accablement, Contrariété, Jalousie,</Text> | |
<Text className={mergeClassNames(typography.textSmMedium, "text-cnam-primary-950")}> | |
{patientStateRecordKeys.map(key => { | |
const indicator = indicateurs.find(i => i.genericUuid === key) || indicateurs.find(i => i.uuid === key); | |
return indicator?.name; | |
}).filter(Boolean).join(', ')} | |
</Text> |
const hasAnswerSurvey = () => | ||
patientStateRecordKeys.some((key) => patientState[key]?.value !== undefined) || goalsData?.records?.byDate?.[date]?.length > 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function calls hasAnswerSurvey()
before patientStateRecordKeys
is defined, which will cause a ReferenceError. The function definition should be moved after the patientStateRecordKeys declaration.
const hasAnswerSurvey = () => | |
patientStateRecordKeys.some((key) => patientState[key]?.value !== undefined) || goalsData?.records?.byDate?.[date]?.length > 0; | |
// hasAnswerSurvey function moved after patientStateRecordKeys definition |
}) | ||
: []; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add the hasAnswerSurvey function definition after patientStateRecordKeys is available, and fix the logic to handle the case when patientStateRecordKeys is empty.
}) | |
: []; | |
}) | |
: []; | |
const hasAnswerSurvey = () => | |
patientStateRecordKeys.some((key) => patientState[key]?.value !== undefined) || goalsData?.records?.byDate?.[date]?.length > 0; |
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]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The mounted ref pattern is being used but the cleanup in useEffect return is not properly implemented. The ref should be properly typed and the cleanup should set mounted.current = false.
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 mounted = useRef(true); |
</View> | ||
{/* <View> | ||
{patientStateRecordKeys.map((key) => { | ||
let patientStateRecord = patientState[key]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove the large blocks of commented-out code. This appears to be old implementation that should either be deleted or moved to a separate branch/PR if it's still needed for reference.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR introduces a new status item design with modern styling. While the overall structure is good, there are several critical issues that need attention: a logic error in date display, dead code that should be removed, and potential rendering issues from removing the noData check. The TypeScript migration is incomplete, and there are some architectural concerns with the large component size.
app/src/scenes/status/DiaryList.js
Outdated
) : ( | ||
<TouchableOpacity style={styles.item} onPress={() => navigation.navigate("too-late", { date })}> | ||
<View className="bg-red"> | ||
{!canEdit(date) && ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This condition appears to be inverted. Currently, the date container is only shown when canEdit(date) returns false, which seems backward. The date should typically be shown for all entries, or only for editable ones.
{!canEdit(date) && ( | |
{canEdit(date) && ( |
}; | ||
|
||
const newItemCard = ({ emotionValue, handlePressItem }: { emotionValue: number; handlePressItem: any }) => { | ||
<TouchableOpacity className="rounded-2xl border border-gray-500 flex-col my-4 p-6" onPress={() => handlePressItem({ editingSurvey: true })}> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function is defined but never used, creating dead code. It should be removed to keep the codebase clean.
{noData() ? ( | ||
<NoData navigation={navigation} /> | ||
) : ongletActif === "all" && !bannerProNPSVisible ? ( | ||
{ongletActif === "all" && !bannerProNPSVisible ? ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removing the noData() check could cause the DiaryList to render even when there's no data, potentially leading to empty states or unexpected behavior. Consider adding appropriate empty state handling.
{ongletActif === "all" && !bannerProNPSVisible ? ( | |
{!noData() && ongletActif === "all" && !bannerProNPSVisible ? ( |
<View style={styles.buttonsContainer}> | ||
<Button icon="pencil" visible={true} onPress={() => handlePressItem({ editingSurvey: true })} /> | ||
</View> | ||
) : null} */} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Large commented code blocks should be removed rather than left in the codebase. This improves readability and reduces maintenance overhead.
title={canEdit(date) ? "Renseigner mon état pour ce jour-là" : "Je ne peux plus saisir mon questionnaire pour ce jour"} | ||
image={{ source: require("./../../../assets/imgs/indicateur.png") }} | ||
onPress={handlePressItem} | ||
/> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another large commented code block should be removed to keep the codebase clean.
app/src/scenes/status/DiaryList.js
Outdated
<Text style={styles.dateLabel}>{formatDateThread(date)}</Text> | ||
) : ( | ||
<TouchableOpacity style={styles.item} onPress={() => navigation.navigate("too-late", { date })}> | ||
<View className="bg-red"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This debug className 'bg-red' should be removed before production deployment.
<View className="bg-red"> | |
<View> |
|
WIP: j'attends des précisions de Melissa