From ee9875183fc3a45480b2276295213eda5fcab4f5 Mon Sep 17 00:00:00 2001 From: Donkoko Date: Tue, 4 Jun 2024 15:36:27 +0300 Subject: [PATCH] removing download button + other minor adjustments --- .../booking/generate-booking-pdf.tsx | 35 ++----------------- ...bookingId.generate-pdf.$fileName[.pdf].tsx | 1 - 2 files changed, 2 insertions(+), 34 deletions(-) diff --git a/app/components/booking/generate-booking-pdf.tsx b/app/components/booking/generate-booking-pdf.tsx index f75adf48f..0cb847c4f 100644 --- a/app/components/booking/generate-booking-pdf.tsx +++ b/app/components/booking/generate-booking-pdf.tsx @@ -1,6 +1,7 @@ -import { useRef, useState } from "react"; +import { useState } from "react"; import type { Asset, Booking } from "@prisma/client"; import { Button } from "~/components/shared/button"; + import { tw } from "~/utils/tw"; import { Dialog, DialogPortal } from "../layout/dialog"; import { Spinner } from "../shared/spinner"; @@ -17,7 +18,6 @@ export const GenerateBookingPdf = ({ timeStamp: number; }) => { const [iframeLoaded, setIframeLoaded] = useState(false); - const iframeRef = useRef(null); // Add ref for the iframe const totalAssets = booking.assets.length; const url = `/bookings/${booking.id.toString()}/generate-pdf/booking-checklist-${new Date() .toISOString() @@ -30,27 +30,6 @@ export const GenerateBookingPdf = ({ window.location.href = url; }; - const handleDownload = (e: React.MouseEvent) => { - try { - e.preventDefault(); - const iframe = iframeRef.current; - if (iframe && iframe?.contentDocument) { - const pdfData = iframe?.contentDocument?.body?.innerHTML; // Adjust if necessary to access PDF data - const blob = new Blob([pdfData], { type: "application/pdf" }); - const downloadUrl = URL.createObjectURL(blob); - const a = document.createElement("a"); - a.href = downloadUrl; - a.download = `booking-checklist-${new Date() - .toISOString() - .slice(0, 10)}.pdf`; - a.click(); - URL.revokeObjectURL(downloadUrl); - } - } catch (err) { - //do nothing for now. - } - }; - const [isDialogOpen, setIsDialogOpen] = useState(false); const handleOpenDialog = () => { @@ -103,7 +82,6 @@ export const GenerateBookingPdf = ({ width="100%" height="100%" onLoad={handleIframeLoad} - ref={iframeRef} src={url} title="Booking PDF" allowFullScreen={true} @@ -115,15 +93,6 @@ export const GenerateBookingPdf = ({ - diff --git a/app/routes/_layout+/bookings.$bookingId.generate-pdf.$fileName[.pdf].tsx b/app/routes/_layout+/bookings.$bookingId.generate-pdf.$fileName[.pdf].tsx index b53a00ac7..89c9d1042 100644 --- a/app/routes/_layout+/bookings.$bookingId.generate-pdf.$fileName[.pdf].tsx +++ b/app/routes/_layout+/bookings.$bookingId.generate-pdf.$fileName[.pdf].tsx @@ -94,7 +94,6 @@ const styles = { marginTop: "10px", marginBottom: "20px", border: "1px solid #bfbfbf", - borderRadius: "4px", }, infoRow: { display: "flex",