Pages corrections pages health
This commit is contained in:
parent
e5254c8bc8
commit
091b598d1b
@ -753,6 +753,16 @@ export default function CarnetPage() {
|
|||||||
noteContentCache.set(payload.id, payload.content);
|
noteContentCache.set(payload.id, payload.content);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// For Health folder, update selectedNote with the new content so the form reflects the saved data
|
||||||
|
if (selectedFolder === 'Health' && selectedNote?.id === fileKey) {
|
||||||
|
console.log(`[handleSaveNote] Updating selectedNote content for Health form`);
|
||||||
|
setSelectedNote({
|
||||||
|
...selectedNote,
|
||||||
|
content: payload.content,
|
||||||
|
lastModified: new Date().toISOString()
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// Refresh the list of notes (skip cache to get fresh data)
|
// Refresh the list of notes (skip cache to get fresh data)
|
||||||
// Only refresh if not Health folder to avoid constant flickering during form updates
|
// Only refresh if not Health folder to avoid constant flickering during form updates
|
||||||
// Health folder updates are handled by the form itself and don't need immediate list refresh
|
// Health folder updates are handled by the form itself and don't need immediate list refresh
|
||||||
|
|||||||
@ -59,6 +59,25 @@ export const HealthForm: React.FC<HealthFormProps> = ({ content, onContentChange
|
|||||||
// Use ref to track last sent content to prevent infinite loops
|
// Use ref to track last sent content to prevent infinite loops
|
||||||
const lastSentContentRef = useRef<string>('');
|
const lastSentContentRef = useRef<string>('');
|
||||||
|
|
||||||
|
// Update data when content prop changes (e.g., after save or when note is loaded)
|
||||||
|
useEffect(() => {
|
||||||
|
if (content && content !== lastSentContentRef.current) {
|
||||||
|
try {
|
||||||
|
const parsed = JSON.parse(content);
|
||||||
|
// Only update if the parsed content is different from current data
|
||||||
|
// This prevents overwriting user's current edits
|
||||||
|
const currentJson = JSON.stringify(data);
|
||||||
|
const newJson = JSON.stringify(parsed);
|
||||||
|
if (currentJson !== newJson) {
|
||||||
|
console.log('[HealthForm] Updating data from content prop');
|
||||||
|
setData(parsed);
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
// If not valid JSON, ignore
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, [content]); // Only depend on content, not on data to avoid loops
|
||||||
|
|
||||||
// Initialize date if not set
|
// Initialize date if not set
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!data.date && date) {
|
if (!data.date && date) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user