From d94505301407a5f28125563efa74e2e92c6acd8c Mon Sep 17 00:00:00 2001 From: Michel Roegl-Brunner Date: Wed, 10 Sep 2025 15:18:31 +0200 Subject: [PATCH] fix: Fix TextViewer tRPC hook usage error - Replace direct tRPC hook calls with fetch requests - Fix 'hooks[lastArg] is not a function' error - Use proper tRPC API endpoint format with JSON encoding - Remove unused tRPC import from TextViewer component --- src/app/_components/TextViewer.tsx | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/app/_components/TextViewer.tsx b/src/app/_components/TextViewer.tsx index 9e88266..a49d9ae 100644 --- a/src/app/_components/TextViewer.tsx +++ b/src/app/_components/TextViewer.tsx @@ -3,7 +3,6 @@ import { useState, useEffect } from 'react'; import { Prism as SyntaxHighlighter } from 'react-syntax-highlighter'; import { tomorrow } from 'react-syntax-highlighter/dist/esm/styles/prism'; -import { api } from '~/trpc/react'; interface TextViewerProps { scriptName: string; @@ -37,18 +36,24 @@ export function TextViewer({ scriptName, isOpen, onClose }: TextViewerProps) { try { const [ctResponse, installResponse] = await Promise.allSettled([ - api.scripts.getScriptContent.query({ path: `ct/${scriptName}` }), - api.scripts.getScriptContent.query({ path: `install/${slug}-install.sh` }) + fetch(`/api/trpc/scripts.getScriptContent?input=${encodeURIComponent(JSON.stringify({ json: { path: `ct/${scriptName}` } }))}`), + fetch(`/api/trpc/scripts.getScriptContent?input=${encodeURIComponent(JSON.stringify({ json: { path: `install/${slug}-install.sh` } }))}`) ]); const content: ScriptContent = {}; - if (ctResponse.status === 'fulfilled' && ctResponse.value.success) { - content.ctScript = ctResponse.value.content; + if (ctResponse.status === 'fulfilled' && ctResponse.value.ok) { + const ctData = await ctResponse.value.json(); + if (ctData.result?.data?.json?.success) { + content.ctScript = ctData.result.data.json.content; + } } - if (installResponse.status === 'fulfilled' && installResponse.value.success) { - content.installScript = installResponse.value.content; + if (installResponse.status === 'fulfilled' && installResponse.value.ok) { + const installData = await installResponse.value.json(); + if (installData.result?.data?.json?.success) { + content.installScript = installData.result.data.json.content; + } } setScriptContent(content);