Skip to content

Conversation

LucasCharrier
Copy link
Contributor

@LucasCharrier LucasCharrier commented Sep 8, 2025

WIP: j'attends des précisions de Melissa

@revu-bot revu-bot bot requested a review from revu-bot September 8, 2025 16:02
@LucasCharrier LucasCharrier marked this pull request as draft September 8, 2025 16:02
Copy link
Collaborator

@revu-bot revu-bot left a 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.

Comment on lines 132 to 137
{[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>
Copy link
Collaborator

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.

Suggested change
{[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>
Copy link
Collaborator

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.

Suggested change
<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>

Comment on lines +75 to +76
const hasAnswerSurvey = () =>
patientStateRecordKeys.some((key) => patientState[key]?.value !== undefined) || goalsData?.records?.byDate?.[date]?.length > 0;
Copy link
Collaborator

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.

Suggested change
const hasAnswerSurvey = () =>
patientStateRecordKeys.some((key) => patientState[key]?.value !== undefined) || goalsData?.records?.byDate?.[date]?.length > 0;
// hasAnswerSurvey function moved after patientStateRecordKeys definition

Comment on lines +98 to +99
})
: [];
Copy link
Collaborator

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.

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

Comment on lines +47 to +60
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]);
Copy link
Collaborator

@revu-bot revu-bot Sep 8, 2025

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.

Suggested change
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];
Copy link
Collaborator

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.

Copy link
Collaborator

@revu-bot revu-bot left a 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.

) : (
<TouchableOpacity style={styles.item} onPress={() => navigation.navigate("too-late", { date })}>
<View className="bg-red">
{!canEdit(date) && (
Copy link
Collaborator

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.

Suggested change
{!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 })}>
Copy link
Collaborator

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 ? (
Copy link
Collaborator

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.

Suggested change
{ongletActif === "all" && !bannerProNPSVisible ? (
{!noData() && ongletActif === "all" && !bannerProNPSVisible ? (

<View style={styles.buttonsContainer}>
<Button icon="pencil" visible={true} onPress={() => handlePressItem({ editingSurvey: true })} />
</View>
) : null} */}
Copy link
Collaborator

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}
/>
Copy link
Collaborator

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.

<Text style={styles.dateLabel}>{formatDateThread(date)}</Text>
) : (
<TouchableOpacity style={styles.item} onPress={() => navigation.navigate("too-late", { date })}>
<View className="bg-red">
Copy link
Collaborator

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.

Suggested change
<View className="bg-red">
<View>

Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
19.5% Duplication on New Code (required ≤ 15%)
C Reliability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants