diff --git a/app/resume-builder/app/how-to-start/[template]/contact/components/contact-section.js b/app/resume-builder/app/how-to-start/[template]/contact/components/contact-section.js index 98107ae..51f0d0f 100644 --- a/app/resume-builder/app/how-to-start/[template]/contact/components/contact-section.js +++ b/app/resume-builder/app/how-to-start/[template]/contact/components/contact-section.js @@ -2,7 +2,7 @@ import { useState, useRef, useEffect } from "react"; import { useRouter, usePathname } from "next/navigation"; import { inputs } from "@/utils/resume-builder/builder/contact"; -import { errorToast } from "@/utils/error-toast"; +//import { errorToast } from "@/utils/error-toast"; export default function ContactSection() { const router = useRouter(); diff --git a/app/resume-builder/app/how-to-start/[template]/finish/components/Finish.js b/app/resume-builder/app/how-to-start/[template]/finish/components/Finish.js index 358c956..bdc6d93 100644 --- a/app/resume-builder/app/how-to-start/[template]/finish/components/Finish.js +++ b/app/resume-builder/app/how-to-start/[template]/finish/components/Finish.js @@ -1,18 +1,22 @@ "use client"; -import { useEffect, useState } from "react"; +import { useEffect, useState, useRef } from "react"; import { plans } from "@/utils/resume-builder/builder/finish"; import { useRouter } from "next/navigation"; import Cookies from "js-cookie"; import Link from "next/link"; - +import html2canvas from "html2canvas"; +import resumeTemplates from "@/resources/resume-builder/resume-templates.json"; import GuestLayout from "@/components/application/layouts/guest"; import CheckoutForm from "./checkout-form"; export default function FinishYourResume() { const [data, setData] = useState(null); + const [TemplateComponent, setTemplateComponent] = useState(null); + const [imageSrc, setImageSrc] = useState(null); const [selectedPaymentMenu, setSelectedPaymentMenu] = useState("14-day"); const [user, setUser] = useState(null); const router = useRouter(); + const templateRef = useRef(); useEffect(() => { const storedResumeData = localStorage.getItem("resumeInfo"); @@ -25,6 +29,34 @@ export default function FinishYourResume() { } }, []); + useEffect(() => { + if (data) { + const templateEntry = resumeTemplates.find(template => template.id === data.template); + if (templateEntry && templateEntry.linkToTemplate) { + import(`@/components/application/templates/resume/${data.template}`).then(module => { + const TemplateComponent = module.default; + setTemplateComponent(() => TemplateComponent); + }).catch(error => { + console.error("Error importing template:", error); + }); + } else { + console.error("Template path not found for:", data.template); + } + } + }, [data]); + + // Convert the rendered template to an image using html2canvas + useEffect(() => { + if (TemplateComponent && data) { + html2canvas(templateRef.current).then((canvas) => { + const imgData = canvas.toDataURL("image/png"); + setImageSrc(imgData); + }).catch(error => { + console.error("Error generating image:", error); + }); + } + }, [TemplateComponent, data]); + const handleContinueForFree = () => { if (!user) { router.push("/login"); @@ -41,11 +73,18 @@ export default function FinishYourResume() {
Upgrade now for Unlimited Access to all pro features!
-