From 97753f764733f4da80a5423eb34216f329f63adb Mon Sep 17 00:00:00 2001 From: Michel Roegl-Brunner Date: Wed, 10 Sep 2025 14:54:07 +0200 Subject: [PATCH] fix: Handle notes as objects with text and type properties - Update Script type to handle notes as objects with text and type - Add ScriptNote interface for structured note format - Update ScriptDetailModal to render notes with proper styling based on type - Add backward compatibility for string notes - Fix React error 'Objects are not valid as a React child' --- server.log | 29 ++++++++++++++++++++ src/app/_components/ScriptDetailModal.tsx | 33 +++++++++++++++++++---- src/types/script.ts | 7 ++++- 3 files changed, 63 insertions(+), 6 deletions(-) create mode 100644 server.log diff --git a/server.log b/server.log new file mode 100644 index 0000000..fb78229 --- /dev/null +++ b/server.log @@ -0,0 +1,29 @@ + +> pve-scripts-local@0.1.0 dev +> node server.js + +Error: listen EADDRINUSE: address already in use 0.0.0.0:3000 + at (Error: listen EADDRINUSE: address already in use 0.0.0.0:3000) { + code: 'EADDRINUSE', + errno: -98, + syscall: 'listen', + address: '0.0.0.0', + port: 3000 +} + ⨯ uncaughtException: Error: listen EADDRINUSE: address already in use 0.0.0.0:3000 + at (Error: listen EADDRINUSE: address already in use 0.0.0.0:3000) { + code: 'EADDRINUSE', + errno: -98, + syscall: 'listen', + address: '0.0.0.0', + port: 3000 +} + ⨯ uncaughtException: Error: listen EADDRINUSE: address already in use 0.0.0.0:3000 + at (Error: listen EADDRINUSE: address already in use 0.0.0.0:3000) { + code: 'EADDRINUSE', + errno: -98, + syscall: 'listen', + address: '0.0.0.0', + port: 3000 +} +Terminated diff --git a/src/app/_components/ScriptDetailModal.tsx b/src/app/_components/ScriptDetailModal.tsx index 3b5a182..2596f28 100644 --- a/src/app/_components/ScriptDetailModal.tsx +++ b/src/app/_components/ScriptDetailModal.tsx @@ -218,11 +218,34 @@ export function ScriptDetailModal({ script, isOpen, onClose }: ScriptDetailModal

Notes

    - {script.notes.map((note, index) => ( -
  • - {note} -
  • - ))} + {script.notes.map((note, index) => { + // Handle both object and string note formats + const noteText = typeof note === 'string' ? note : note.text; + const noteType = typeof note === 'string' ? 'info' : note.type; + + return ( +
  • +
    + + {noteType} + + {noteText} +
    +
  • + ); + })}
)} diff --git a/src/types/script.ts b/src/types/script.ts index fc6b343..9824ae9 100644 --- a/src/types/script.ts +++ b/src/types/script.ts @@ -17,6 +17,11 @@ export interface ScriptCredentials { password: string | null; } +export interface ScriptNote { + text: string; + type: string; +} + export interface Script { name: string; slug: string; @@ -33,7 +38,7 @@ export interface Script { description: string; install_methods: ScriptInstallMethod[]; default_credentials: ScriptCredentials; - notes: string[]; + notes: (ScriptNote | string)[]; } export interface ScriptCard {