From 5885ba7f7ea82b868d6d83506c769483a95f083f Mon Sep 17 00:00:00 2001 From: shiva raj badu Date: Sun, 21 Sep 2025 16:11:41 +0545 Subject: [PATCH] fix(nextjs): New slide addition issue in presentation --- .../components/NewSlide.tsx | 2 ++ .../context/LayoutContext.tsx | 14 +++++++------- .../custom-template/hooks/useLayoutSaving.ts | 1 - .../presentation/components/SlideContent.tsx | 8 ++++---- 4 files changed, 13 insertions(+), 12 deletions(-) diff --git a/servers/nextjs/app/(presentation-generator)/components/NewSlide.tsx b/servers/nextjs/app/(presentation-generator)/components/NewSlide.tsx index 05a6b638..f23f1a5c 100644 --- a/servers/nextjs/app/(presentation-generator)/components/NewSlide.tsx +++ b/servers/nextjs/app/(presentation-generator)/components/NewSlide.tsx @@ -37,8 +37,10 @@ const NewSlide = ({ } }; const { getFullDataByGroup, loading } = useLayout(); + const fullData = getFullDataByGroup(group); + if (loading) { return (
diff --git a/servers/nextjs/app/(presentation-generator)/context/LayoutContext.tsx b/servers/nextjs/app/(presentation-generator)/context/LayoutContext.tsx index accbe69f..d8452d03 100644 --- a/servers/nextjs/app/(presentation-generator)/context/LayoutContext.tsx +++ b/servers/nextjs/app/(presentation-generator)/context/LayoutContext.tsx @@ -81,7 +81,7 @@ const createCacheKey = (groupName: string, fileName: string): string => // Extract Babel compilation logic into a utility function const compileCustomLayout = (layoutCode: string, React: any, z: any) => { - + const cleanCode = layoutCode .replace(/import\s+React\s+from\s+'react';?/g, "") .replace(/import\s*{\s*z\s*}\s*from\s+'zod';?/g, "") @@ -350,7 +350,7 @@ export const LayoutProvider: React.FC<{ "/api/v1/ppt/template-management/summary" ); const customGroupData = await customGroupResponse.json(); - + const customFonts = new Map(); const customGroup = customGroupData.presentations; for (const group of customGroup) { @@ -365,9 +365,9 @@ export const LayoutProvider: React.FC<{ ); const customLayoutsData = await customLayoutResponse.json(); const allLayout = customLayoutsData.layouts; - - - + + + const settings = { description: `Custom presentation layouts`, @@ -541,7 +541,7 @@ export const LayoutProvider: React.FC<{ layouts.push(layout); } } - setCustomTemplateFonts(customFonts); + setCustomTemplateFonts(customFonts); // Cache grouped layouts groupedLayouts.set(groupName, groupLayouts); fullDataByGroup.set(groupName, groupFullData); @@ -549,7 +549,7 @@ export const LayoutProvider: React.FC<{ } catch (err: any) { console.error("Compilation error:", err); } - + return { layoutsById, diff --git a/servers/nextjs/app/(presentation-generator)/custom-template/hooks/useLayoutSaving.ts b/servers/nextjs/app/(presentation-generator)/custom-template/hooks/useLayoutSaving.ts index a1529edb..ad06c260 100644 --- a/servers/nextjs/app/(presentation-generator)/custom-template/hooks/useLayoutSaving.ts +++ b/servers/nextjs/app/(presentation-generator)/custom-template/hooks/useLayoutSaving.ts @@ -95,7 +95,6 @@ export const useLayoutSaving = ( const uploadedFontUrls = UploadedFonts.map((font) => font.fontUrl); const googleFontCssUrls = fontsData?.internally_supported_fonts?.map(f => f.google_fonts_url).filter(Boolean) || []; const FontUrls = Array.from(new Set([...(uploadedFontUrls || []), ...googleFontCssUrls])); - console.log("FontUrls", FontUrls); for (let i = 0; i < slides.length; i++) { const slide = slides[i]; diff --git a/servers/nextjs/app/(presentation-generator)/presentation/components/SlideContent.tsx b/servers/nextjs/app/(presentation-generator)/presentation/components/SlideContent.tsx index ef5cbf1d..7cf72bba 100644 --- a/servers/nextjs/app/(presentation-generator)/presentation/components/SlideContent.tsx +++ b/servers/nextjs/app/(presentation-generator)/presentation/components/SlideContent.tsx @@ -75,12 +75,12 @@ const SlideContent = ({ slide, index, presentationId }: SlideContentProps) => { try { trackEvent(MixpanelEvent.Slide_Delete_API_Call); // Add current state to past - dispatch(addToHistory({ + dispatch(addToHistory({ slides: presentationData?.slides, actionType: "DELETE_SLIDE" })); dispatch(deletePresentationSlide(slide.index)); - + } catch (error: any) { console.error("Error deleting slide:", error); toast.error("Error deleting slide.", { @@ -176,12 +176,12 @@ const SlideContent = ({ slide, index, presentationId }: SlideContentProps) => { {showNewSlideSelection && !loading && ( )} - + {!isStreaming && !loading && (