|
| 1 | +import { useState } from "react"; |
| 2 | +import { Input } from "@/components/ui/input"; |
| 3 | +import { Button } from "@/components/ui/button"; |
| 4 | +import { Textarea } from "@/components/ui/textarea"; |
| 5 | +import { Card, CardContent } from "@/components/ui/card"; |
| 6 | +import { UploadCloud } from "lucide-react"; |
| 7 | +import PenIcon from "@/assets/svg/pen-icon"; |
| 8 | +import { useRef } from "react"; |
| 9 | +import UploadIcon from "@/assets/svg/upload-icon"; |
| 10 | + |
| 11 | +const CoverLetterGenerator = () => { |
| 12 | + const [file, setFile] = useState(null); |
| 13 | + const [prompt, setPrompt] = useState(""); |
| 14 | + const [showPreview, setShowPreview] = useState(false); |
| 15 | + const [loading, setLoading] = useState(false); |
| 16 | + |
| 17 | + // Ref to access the hidden file input |
| 18 | + const fileInputRef = useRef(null); |
| 19 | + |
| 20 | + const handleFileChange = (e) => { |
| 21 | + const selected = e.target.files?.[0]; |
| 22 | + if (selected && selected.type.includes("pdf")) { |
| 23 | + setFile(selected); |
| 24 | + } else { |
| 25 | + alert("Only PDF files are supported for now."); |
| 26 | + } |
| 27 | + }; |
| 28 | + |
| 29 | + const handleGenerate = () => { |
| 30 | + if (file && prompt.trim() !== "") { |
| 31 | + setLoading(true); |
| 32 | + setTimeout(() => { |
| 33 | + setShowPreview(true); |
| 34 | + setLoading(false); |
| 35 | + }, 2000); |
| 36 | + } |
| 37 | + }; |
| 38 | + return ( |
| 39 | + <div className="min-h-screen bg-[#F9FAFB] p-4 md:p-8"> |
| 40 | + {/* Header */} |
| 41 | + <div |
| 42 | + className="max-w-7xl mx-auto text-center md:text-left mb-10" |
| 43 | + data-aos="fade-up" |
| 44 | + > |
| 45 | + <h1 className="text-[#191919] font-poppins text-3xl md:text-5xl lg:text-[64px] font-semibold leading-tight max-w-5xl"> |
| 46 | + Build Your Professional Cover Letter |
| 47 | + </h1> |
| 48 | + <p className="text-[#717171] font-poppins text-lg md:text-xl lg:text-[24px] mt-4"> |
| 49 | + Let’s take the next step in your career today |
| 50 | + </p> |
| 51 | + </div> |
| 52 | + |
| 53 | + {/* Main Grid */} |
| 54 | + <div className="grid grid-cols-1 lg:grid-cols-2 gap-6 max-w-7xl mx-auto"> |
| 55 | + {/* Left Side */} |
| 56 | + <Card |
| 57 | + className="p-6 flex flex-col justify-between gap-6 border-0 shadow-xl h-auto" |
| 58 | + data-aos="fade-right" |
| 59 | + > |
| 60 | + <div> |
| 61 | + <div className="border border-dashed border-gray-300 bg-[#F6F8FE] rounded-md p-6 flex flex-col items-center justify-center cursor-pointer"> |
| 62 | + <UploadIcon className="w-10 h-5 text-gray-500" /> |
| 63 | + <h2 className="text-[#020817] text-center font-poppins text-[16px] font-normal leading-none mb-2 mt-2"> |
| 64 | + Upload your Resume / Job Description |
| 65 | + </h2> |
| 66 | + <span className="text-[#6B7280] text-center font-poppins text-[14px] font-normal leading-none mb-2"> |
| 67 | + Drag and drop your resume/job description or click to browse |
| 68 | + </span> |
| 69 | + <Button |
| 70 | + type="button" |
| 71 | + onClick={() => fileInputRef.current?.click()} |
| 72 | + className="bg-gradient-to-r from-primary to-secondary rounded-full font-normal mb-1" |
| 73 | + > |
| 74 | + Select File |
| 75 | + </Button> |
| 76 | + <span className="text-[#6B7280] text-center font-poppins text-[14px] font-normal leading-none"> |
| 77 | + Supported formats: PDF, DOCX, TXT |
| 78 | + </span> |
| 79 | + {/* Hidden file input */} |
| 80 | + <Input |
| 81 | + ref={fileInputRef} |
| 82 | + type="file" |
| 83 | + accept=".pdf,.docx,.txt" |
| 84 | + className="hidden" |
| 85 | + onChange={handleFileChange} |
| 86 | + /> |
| 87 | + </div> |
| 88 | + |
| 89 | + {file && ( |
| 90 | + <p className="text-sm text-green-600 mt-2 text-center md:text-left"> |
| 91 | + ✅ {file.name} selected |
| 92 | + </p> |
| 93 | + )} |
| 94 | + </div> |
| 95 | + |
| 96 | + {/* Prompt */} |
| 97 | + <div> |
| 98 | + <label |
| 99 | + htmlFor="prompt" |
| 100 | + className="flex items-center gap-2 text-sm font-bold mb-2" |
| 101 | + > |
| 102 | + <PenIcon /> |
| 103 | + Prompt |
| 104 | + </label> |
| 105 | + <Textarea |
| 106 | + id="prompt" |
| 107 | + placeholder="Enter prompt here..." |
| 108 | + className="bg-[#F6F8FE]" |
| 109 | + value={prompt} |
| 110 | + onChange={(e) => setPrompt(e.target.value)} |
| 111 | + /> |
| 112 | + </div> |
| 113 | + |
| 114 | + {/* Buttons */} |
| 115 | + <div className="flex flex-col md:flex-row items-center gap-4 mt-2"> |
| 116 | + <Button variant="outline" className="w-full md:w-auto"> |
| 117 | + Sample Prompts |
| 118 | + </Button> |
| 119 | + <Button variant="outline" className="w-full md:w-auto"> |
| 120 | + Job Description |
| 121 | + </Button> |
| 122 | + <Button |
| 123 | + onClick={handleGenerate} |
| 124 | + className="w-full md:w-auto bg-gradient-to-r from-primary to-secondary" |
| 125 | + disabled={loading} |
| 126 | + > |
| 127 | + {loading ? ( |
| 128 | + <span className="flex items-center gap-2"> |
| 129 | + <svg |
| 130 | + className="animate-spin h-4 w-4 text-white" |
| 131 | + xmlns="http://www.w3.org/2000/svg" |
| 132 | + fill="none" |
| 133 | + viewBox="0 0 24 24" |
| 134 | + > |
| 135 | + <circle |
| 136 | + className="opacity-25" |
| 137 | + cx="12" |
| 138 | + cy="12" |
| 139 | + r="10" |
| 140 | + stroke="currentColor" |
| 141 | + strokeWidth="4" |
| 142 | + /> |
| 143 | + <path |
| 144 | + className="opacity-75" |
| 145 | + fill="currentColor" |
| 146 | + d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z" |
| 147 | + /> |
| 148 | + </svg> |
| 149 | + Generating... |
| 150 | + </span> |
| 151 | + ) : ( |
| 152 | + "Generate Cover" |
| 153 | + )} |
| 154 | + </Button> |
| 155 | + </div> |
| 156 | + </Card> |
| 157 | + |
| 158 | + {/* Right Side */} |
| 159 | + {showPreview && ( |
| 160 | + <Card className="p-6" data-aos="fade-left"> |
| 161 | + <CardContent className="space-y-4 text-sm text-gray-700"> |
| 162 | + <div className="text-right text-xs text-gray-400"> |
| 163 | + 09 February 2024 |
| 164 | + </div> |
| 165 | + <h1 className="text-xl font-bold">Nazmul Hasan</h1> |
| 166 | + <p className="text-sm font-medium text-gray-600">UX Designer</p> |
| 167 | + |
| 168 | + <p>Dear Hiring Manager,</p> |
| 169 | + |
| 170 | + <p> |
| 171 | + I am excited to express my strong interest in the UX/UI Product |
| 172 | + Designer role at Mixamprint. With a passion for creating |
| 173 | + seamless digital experiences and a track record of delivering |
| 174 | + innovative user-centered designs, I am confident in my ability |
| 175 | + to contribute to your team’s success... |
| 176 | + </p> |
| 177 | + |
| 178 | + <p> |
| 179 | + Thank you for your consideration, and I eagerly await the |
| 180 | + opportunity to discuss this exciting opportunity further. |
| 181 | + </p> |
| 182 | + |
| 183 | + <p> |
| 184 | + Sincerely, |
| 185 | + <br /> |
| 186 | + Nazmul Hasan |
| 187 | + </p> |
| 188 | + </CardContent> |
| 189 | + </Card> |
| 190 | + )} |
| 191 | + </div> |
| 192 | + </div> |
| 193 | + ); |
| 194 | +}; |
| 195 | + |
| 196 | +export default CoverLetterGenerator; |
0 commit comments