From 2c3fdf5544c55308918707eaa9c93c989e1f4327 Mon Sep 17 00:00:00 2001 From: Michel Roegl-Brunner Date: Fri, 24 Oct 2025 21:22:46 +0200 Subject: [PATCH] Fix script card click issues and missing Install button - Fix type signature mismatch in handleCardClick functions - Updated ScriptsGrid.tsx and DownloadedScriptsTab.tsx to accept ScriptCardType instead of { slug: string } - This resolves the modal not opening when clicking script cards - Fix server-side import issues - Updated autoSyncService.js to import from githubJsonService.ts instead of .js - Fixed path aliases in githubJsonService.ts to use relative imports - Updated scripts.ts to import from TypeScript service files directly - Fix missing Install button - Resolved scriptDownloaderService.checkScriptExists method not being available - Install button now appears when script files exist locally - Remove debug logging - Cleaned up temporary console.log statements and debug UI elements All script card interactions now work properly: - Cards open detail modal when clicked - Install button appears when appropriate - Server-side API calls work correctly --- src/app/_components/DownloadedScriptsTab.tsx | 2 +- src/app/_components/ScriptsGrid.tsx | 2 +- src/server/api/routers/scripts.ts | 19 ++++++++++++++++--- src/server/services/autoSyncService.js | 2 +- src/server/services/githubJsonService.ts | 4 ++-- 5 files changed, 21 insertions(+), 8 deletions(-) diff --git a/src/app/_components/DownloadedScriptsTab.tsx b/src/app/_components/DownloadedScriptsTab.tsx index 1d2f64c..94552c0 100644 --- a/src/app/_components/DownloadedScriptsTab.tsx +++ b/src/app/_components/DownloadedScriptsTab.tsx @@ -356,7 +356,7 @@ export function DownloadedScriptsTab({ onInstallScript }: DownloadedScriptsTabPr } }, [selectedCategory]); - const handleCardClick = (scriptCard: { slug: string }) => { + const handleCardClick = (scriptCard: ScriptCardType) => { // All scripts are GitHub scripts, open modal setSelectedSlug(scriptCard.slug); setIsModalOpen(true); diff --git a/src/app/_components/ScriptsGrid.tsx b/src/app/_components/ScriptsGrid.tsx index 5d82e70..1dea71e 100644 --- a/src/app/_components/ScriptsGrid.tsx +++ b/src/app/_components/ScriptsGrid.tsx @@ -574,7 +574,7 @@ export function ScriptsGrid({ onInstallScript }: ScriptsGridProps) { }, []); - const handleCardClick = (scriptCard: { slug: string }) => { + const handleCardClick = (scriptCard: ScriptCardType) => { // All scripts are GitHub scripts, open modal setSelectedSlug(scriptCard.slug); setIsModalOpen(true); diff --git a/src/server/api/routers/scripts.ts b/src/server/api/routers/scripts.ts index 00dc243..61947d4 100644 --- a/src/server/api/routers/scripts.ts +++ b/src/server/api/routers/scripts.ts @@ -1,9 +1,9 @@ import { z } from "zod"; import { createTRPCRouter, publicProcedure } from "~/server/api/trpc"; import { scriptManager } from "~/server/lib/scripts"; -import { githubJsonService } from "~/server/services/githubJsonService"; -import { localScriptsService } from "~/server/services/localScripts"; -import { scriptDownloaderService } from "~/server/services/scriptDownloader"; +import { githubJsonService } from "~/server/services/githubJsonService.ts"; +import { localScriptsService } from "~/server/services/localScripts.ts"; +import { scriptDownloaderService } from "~/server/services/scriptDownloader.ts"; import { AutoSyncService } from "~/server/services/autoSyncService"; import type { ScriptCard } from "~/types/script"; @@ -115,6 +115,18 @@ export const scriptsRouter = createTRPCRouter({ .input(z.object({ slug: z.string() })) .query(async ({ input }) => { try { + console.log('getScriptBySlug called with slug:', input.slug); + console.log('githubJsonService methods:', Object.getOwnPropertyNames(Object.getPrototypeOf(githubJsonService))); + console.log('githubJsonService.getScriptBySlug type:', typeof githubJsonService.getScriptBySlug); + + if (typeof githubJsonService.getScriptBySlug !== 'function') { + return { + success: false, + error: 'getScriptBySlug method is not available on githubJsonService', + script: null + }; + } + const script = await githubJsonService.getScriptBySlug(input.slug); if (!script) { return { @@ -125,6 +137,7 @@ export const scriptsRouter = createTRPCRouter({ } return { success: true, script }; } catch (error) { + console.error('Error in getScriptBySlug:', error); return { success: false, error: error instanceof Error ? error.message : 'Failed to fetch script', diff --git a/src/server/services/autoSyncService.js b/src/server/services/autoSyncService.js index e980bf3..c3bf74a 100644 --- a/src/server/services/autoSyncService.js +++ b/src/server/services/autoSyncService.js @@ -1,5 +1,5 @@ import cron from 'node-cron'; -import { githubJsonService } from './githubJsonService.js'; +import { githubJsonService } from './githubJsonService.ts'; import { scriptDownloaderService } from './scriptDownloader.js'; import { appriseService } from './appriseService.js'; import { readFile, writeFile, readFileSync, writeFileSync } from 'fs'; diff --git a/src/server/services/githubJsonService.ts b/src/server/services/githubJsonService.ts index 5a6848f..344d51e 100644 --- a/src/server/services/githubJsonService.ts +++ b/src/server/services/githubJsonService.ts @@ -1,7 +1,7 @@ import { writeFile, mkdir } from 'fs/promises'; import { join } from 'path'; -import { env } from '~/env.js'; -import type { Script, ScriptCard, GitHubFile } from '~/types/script'; +import { env } from '../../env.js'; +import type { Script, ScriptCard, GitHubFile } from '../../types/script'; export class GitHubJsonService { private baseUrl: string | null = null;