remove(sidepanel,api/dashboard): remove thumbnail logic,api endpoint & SS package
This commit is contained in:
parent
a95e8c148f
commit
33ed6eaa5b
3 changed files with 2 additions and 64 deletions
|
|
@ -5,7 +5,6 @@ import ToolTip from "@/components/ToolTip";
|
|||
import { Button } from "@/components/ui/button";
|
||||
import { useDispatch, useSelector } from "react-redux";
|
||||
import { RootState } from "@/store/store";
|
||||
import { DashboardApi } from "@/app/dashboard/api/dashboard";
|
||||
import {
|
||||
DndContext,
|
||||
closestCenter,
|
||||
|
|
@ -20,7 +19,6 @@ import {
|
|||
sortableKeyboardCoordinates,
|
||||
verticalListSortingStrategy,
|
||||
} from "@dnd-kit/sortable";
|
||||
import * as htmlToImage from "html-to-image";
|
||||
import { setPresentationData } from "@/store/slices/presentationGeneration";
|
||||
import { SortableSlide } from "./SortableSlide";
|
||||
import { SortableListItem } from "./SortableListItem";
|
||||
|
|
@ -58,18 +56,7 @@ const SidePanel = ({
|
|||
}
|
||||
}, [isMobilePanelOpen]);
|
||||
|
||||
useEffect(() => {
|
||||
if (
|
||||
presentationData?.presentation?.thumbnail === null &&
|
||||
presentationData.slides.some(
|
||||
(slide) => slide.images && slide.images.length > 0
|
||||
)
|
||||
) {
|
||||
setTimeout(() => {
|
||||
setSlideThumbnail();
|
||||
}, 4000);
|
||||
}
|
||||
}, [presentationData]);
|
||||
|
||||
const sensors = useSensors(
|
||||
useSensor(PointerSensor),
|
||||
useSensor(KeyboardSensor, {
|
||||
|
|
@ -84,17 +71,6 @@ const SidePanel = ({
|
|||
}
|
||||
};
|
||||
|
||||
const dataUrlToFile = (dataUrl: string, filename: string) => {
|
||||
const arr = dataUrl.split(",");
|
||||
const mime = arr[0].match(/:(.*)/)?.[1];
|
||||
const bstr = atob(arr[1]);
|
||||
let n = bstr.length;
|
||||
const u8arr = new Uint8Array(n);
|
||||
while (n--) {
|
||||
u8arr[n] = bstr.charCodeAt(n);
|
||||
}
|
||||
return new File([u8arr], filename, { type: mime });
|
||||
};
|
||||
|
||||
const handleDragEnd = (event: any) => {
|
||||
const { active, over } = event;
|
||||
|
|
@ -130,23 +106,6 @@ const SidePanel = ({
|
|||
}
|
||||
};
|
||||
|
||||
const setSlideThumbnail = async () => {
|
||||
const slideContainer = document.querySelector(".slide-container");
|
||||
if (!slideContainer) return;
|
||||
const image = await htmlToImage
|
||||
.toPng(slideContainer as HTMLElement)
|
||||
.then((dataUrl) => {
|
||||
return dataUrl;
|
||||
});
|
||||
|
||||
const file = dataUrlToFile(image, "thumbnail.png");
|
||||
|
||||
const response = await DashboardApi.setSlideThumbnail(
|
||||
presentationData?.presentation?.id!,
|
||||
file
|
||||
);
|
||||
};
|
||||
|
||||
// Loading shimmer component
|
||||
if (
|
||||
!presentationData ||
|
||||
|
|
|
|||
|
|
@ -83,25 +83,5 @@ export class DashboardApi {
|
|||
throw error;
|
||||
}
|
||||
}
|
||||
static async setSlideThumbnail(presentation_id: string, file: any) {
|
||||
const formData = new FormData();
|
||||
|
||||
formData.append("presentation_id", presentation_id);
|
||||
formData.append("thumbnail", file);
|
||||
try {
|
||||
const response = await fetch(
|
||||
`/api/v1/ppt/presentation/thumbnail`,
|
||||
{
|
||||
method: "POST",
|
||||
headers: getHeaderForFormData(),
|
||||
body: formData,
|
||||
}
|
||||
);
|
||||
const data = await response.json();
|
||||
return data;
|
||||
} catch (error) {
|
||||
console.error("Error setting slide thumbnail:", error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,7 +42,6 @@
|
|||
"class-variance-authority": "^0.7.0",
|
||||
"clsx": "^2.1.1",
|
||||
"cmdk": "^1.0.0",
|
||||
"html-to-image": "^1.11.13",
|
||||
"jsonrepair": "^3.12.0",
|
||||
"lucide-react": "^0.447.0",
|
||||
"marked": "^15.0.11",
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue