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
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user