|
1 | | -import React, { useState } from 'react'; |
2 | | -import { Tab, Tabs, TabList, TabPanel } from 'react-tabs'; |
3 | | -import 'react-tabs/style/react-tabs.css'; |
4 | | -import { saveAs } from 'file-saver'; |
5 | | -import { toast, ToastContainer } from 'react-toastify'; |
6 | | -import 'react-toastify/dist/ReactToastify.css'; |
7 | | - |
8 | | -// Libraries for text extraction |
9 | | -import mammoth from 'mammoth'; // For DOCX files |
10 | | -import * as pdfjsLib from 'pdfjs-dist'; // For PDF files |
11 | | - |
12 | | -const ResumeBuilder = () => { |
13 | | - const [resumeText, setResumeText] = useState(''); |
14 | | - const [feedback, setFeedback] = useState(''); |
15 | | - const [score, setScore] = useState(''); |
16 | | - const [jobDescription, setJobDescription] = useState(''); |
17 | | - const [tabIndex, setTabIndex] = useState(0); |
18 | | - |
19 | | - // File upload and text extraction |
20 | | - const handleFileUpload = (event) => { |
21 | | - const file = event.target.files[0]; |
22 | | - if (!file) return; |
23 | | - |
24 | | - const fileType = file.name.split('.').pop(); |
25 | | - if (fileType === 'pdf') { |
26 | | - extractTextFromPDF(file); |
27 | | - } else if (fileType === 'docx') { |
28 | | - extractTextFromDOCX(file); |
29 | | - } else { |
30 | | - toast.error('Unsupported file type. Please upload a PDF or DOCX file.'); |
31 | | - } |
32 | | - }; |
33 | | - |
34 | | - const extractTextFromPDF = (file) => { |
35 | | - const fileReader = new FileReader(); |
36 | | - fileReader.onload = async () => { |
37 | | - const typedArray = new Uint8Array(fileReader.result); |
38 | | - const pdf = await pdfjsLib.getDocument(typedArray).promise; |
39 | | - let text = ''; |
40 | | - for (let i = 0; i < pdf.numPages; i++) { |
41 | | - const page = await pdf.getPage(i + 1); |
42 | | - const content = await page.getTextContent(); |
43 | | - text += content.items.map((item) => item.str).join(' '); |
44 | | - } |
45 | | - setResumeText(text); |
46 | | - toast.success('PDF text extracted successfully!'); |
47 | | - }; |
48 | | - fileReader.readAsArrayBuffer(file); |
49 | | - }; |
50 | | - |
51 | | - const extractTextFromDOCX = (file) => { |
52 | | - const fileReader = new FileReader(); |
53 | | - fileReader.onload = async () => { |
54 | | - const result = await mammoth.extractRawText({ arrayBuffer: fileReader.result }); |
55 | | - setResumeText(result.value); |
56 | | - toast.success('DOCX text extracted successfully!'); |
57 | | - }; |
58 | | - fileReader.readAsArrayBuffer(file); |
59 | | - }; |
60 | | - |
61 | | - // Mock AI responses |
62 | | - const analyzeResume = () => { |
63 | | - if (!resumeText) { |
64 | | - toast.error('Please upload a resume first.'); |
65 | | - return; |
66 | | - } |
67 | | - setFeedback(`Analysis of resume: ${resumeText.substring(0, 100)}...`); |
68 | | - toast.success('Resume analyzed successfully!'); |
69 | | - }; |
70 | | - |
71 | | - const getResumeScore = () => { |
72 | | - if (!resumeText) { |
73 | | - toast.error('Please upload a resume first.'); |
74 | | - return; |
75 | | - } |
76 | | - setScore('Your resume score is 85/100. Great job!'); |
77 | | - toast.success('Resume scored successfully!'); |
78 | | - }; |
79 | | - |
80 | | - const downloadImprovedResume = () => { |
81 | | - const blob = new Blob([resumeText], { type: 'text/plain;charset=utf-8' }); |
82 | | - saveAs(blob, 'Improved_Resume.txt'); |
83 | | - toast.success('Resume downloaded successfully!'); |
84 | | - }; |
85 | | - |
86 | | - return ( |
87 | | - <div> |
88 | | - <ToastContainer /> |
89 | | - <h1>🚀 AI ResumeXpert Analyst</h1> |
90 | | - <p>Upload your resume to get detailed AI feedback, ATS analysis, and job match insights!</p> |
91 | | - |
92 | | - <input type="file" onChange={handleFileUpload} /> |
93 | | - {resumeText && ( |
94 | | - <div> |
95 | | - <h3>Resume Text Extracted:</h3> |
96 | | - <textarea value={resumeText} readOnly rows="10" style={{ width: '100%' }}></textarea> |
97 | | - </div> |
98 | | - )} |
99 | | - |
100 | | - <Tabs selectedIndex={tabIndex} onSelect={(index) => setTabIndex(index)}> |
101 | | - <TabList> |
102 | | - <Tab>📂 Upload Resume</Tab> |
103 | | - <Tab>📊 Job Match Analysis</Tab> |
104 | | - <Tab>🚀 AI Project Suggestions</Tab> |
105 | | - <Tab>🤷♂ ATS Score Checker</Tab> |
106 | | - <Tab>📊 AI-Powered Resume Ranking</Tab> |
107 | | - </TabList> |
108 | | - |
109 | | - {/* Tab 1: Resume Upload and Analysis */} |
110 | | - <TabPanel> |
111 | | - <button onClick={analyzeResume}>Analyze Resume</button> |
112 | | - <button onClick={getResumeScore}>Get Resume Score</button> |
113 | | - <button onClick={downloadImprovedResume}>Download Improved Resume</button> |
114 | | - {feedback && ( |
115 | | - <p> |
116 | | - <strong>Feedback:</strong> {feedback} |
117 | | - </p> |
118 | | - )} |
119 | | - {score && ( |
120 | | - <p> |
121 | | - <strong>Score:</strong> {score} |
122 | | - </p> |
123 | | - )} |
124 | | - </TabPanel> |
125 | | - |
126 | | - {/* Tab 2: Job Match Analysis */} |
127 | | - <TabPanel> |
128 | | - <textarea |
129 | | - placeholder="Paste job description here..." |
130 | | - rows="5" |
131 | | - style={{ width: '100%' }} |
132 | | - value={jobDescription} |
133 | | - onChange={(e) => setJobDescription(e.target.value)} |
134 | | - ></textarea> |
135 | | - <button onClick={() => toast.info('Job match analysis coming soon!')}>Analyze Job Fit</button> |
136 | | - </TabPanel> |
137 | | - |
138 | | - {/* Tab 3: AI Project Suggestions */} |
139 | | - <TabPanel> |
140 | | - <button onClick={() => toast.info('Project suggestions coming soon!')}>Get Project Suggestions</button> |
141 | | - </TabPanel> |
142 | | - |
143 | | - {/* Tab 4: ATS Score Checker */} |
144 | | - <TabPanel> |
145 | | - <button onClick={() => toast.info('ATS Score Checker coming soon!')}>Check ATS Score</button> |
146 | | - </TabPanel> |
147 | | - |
148 | | - {/* Tab 5: AI-Powered Resume Ranking */} |
149 | | - <TabPanel> |
150 | | - <button onClick={() => toast.info('Resume ranking coming soon!')}>Rank Resumes</button> |
151 | | - </TabPanel> |
152 | | - </Tabs> |
153 | | - </div> |
154 | | - ); |
155 | | -}; |
156 | | - |
157 | | -export default ResumeBuilder; |
| 1 | +// import React, { useState } from 'react'; |
| 2 | +// import { Tab, Tabs, TabList, TabPanel } from 'react-tabs'; |
| 3 | +// import 'react-tabs/style/react-tabs.css'; |
| 4 | +// import { saveAs } from 'file-saver'; |
| 5 | +// import { toast, ToastContainer } from 'react-toastify'; |
| 6 | +// import 'react-toastify/dist/ReactToastify.css'; |
| 7 | + |
| 8 | +// // Libraries for text extraction |
| 9 | +// import mammoth from 'mammoth'; // For DOCX files |
| 10 | +// import * as pdfjsLib from 'pdfjs-dist'; // For PDF files |
| 11 | + |
| 12 | +// const ResumeBuilder = () => { |
| 13 | +// const [resumeText, setResumeText] = useState(''); |
| 14 | +// const [feedback, setFeedback] = useState(''); |
| 15 | +// const [score, setScore] = useState(''); |
| 16 | +// const [jobDescription, setJobDescription] = useState(''); |
| 17 | +// const [tabIndex, setTabIndex] = useState(0); |
| 18 | + |
| 19 | +// // File upload and text extraction |
| 20 | +// const handleFileUpload = (event) => { |
| 21 | +// const file = event.target.files[0]; |
| 22 | +// if (!file) return; |
| 23 | + |
| 24 | +// const fileType = file.name.split('.').pop(); |
| 25 | +// if (fileType === 'pdf') { |
| 26 | +// extractTextFromPDF(file); |
| 27 | +// } else if (fileType === 'docx') { |
| 28 | +// extractTextFromDOCX(file); |
| 29 | +// } else { |
| 30 | +// toast.error('Unsupported file type. Please upload a PDF or DOCX file.'); |
| 31 | +// } |
| 32 | +// }; |
| 33 | + |
| 34 | +// const extractTextFromPDF = (file) => { |
| 35 | +// const fileReader = new FileReader(); |
| 36 | +// fileReader.onload = async () => { |
| 37 | +// const typedArray = new Uint8Array(fileReader.result); |
| 38 | +// const pdf = await pdfjsLib.getDocument(typedArray).promise; |
| 39 | +// let text = ''; |
| 40 | +// for (let i = 0; i < pdf.numPages; i++) { |
| 41 | +// const page = await pdf.getPage(i + 1); |
| 42 | +// const content = await page.getTextContent(); |
| 43 | +// text += content.items.map((item) => item.str).join(' '); |
| 44 | +// } |
| 45 | +// setResumeText(text); |
| 46 | +// toast.success('PDF text extracted successfully!'); |
| 47 | +// }; |
| 48 | +// fileReader.readAsArrayBuffer(file); |
| 49 | +// }; |
| 50 | + |
| 51 | +// const extractTextFromDOCX = (file) => { |
| 52 | +// const fileReader = new FileReader(); |
| 53 | +// fileReader.onload = async () => { |
| 54 | +// const result = await mammoth.extractRawText({ arrayBuffer: fileReader.result }); |
| 55 | +// setResumeText(result.value); |
| 56 | +// toast.success('DOCX text extracted successfully!'); |
| 57 | +// }; |
| 58 | +// fileReader.readAsArrayBuffer(file); |
| 59 | +// }; |
| 60 | + |
| 61 | +// // Mock AI responses |
| 62 | +// const analyzeResume = () => { |
| 63 | +// if (!resumeText) { |
| 64 | +// toast.error('Please upload a resume first.'); |
| 65 | +// return; |
| 66 | +// } |
| 67 | +// setFeedback(`Analysis of resume: ${resumeText.substring(0, 100)}...`); |
| 68 | +// toast.success('Resume analyzed successfully!'); |
| 69 | +// }; |
| 70 | + |
| 71 | +// const getResumeScore = () => { |
| 72 | +// if (!resumeText) { |
| 73 | +// toast.error('Please upload a resume first.'); |
| 74 | +// return; |
| 75 | +// } |
| 76 | +// setScore('Your resume score is 85/100. Great job!'); |
| 77 | +// toast.success('Resume scored successfully!'); |
| 78 | +// }; |
| 79 | + |
| 80 | +// const downloadImprovedResume = () => { |
| 81 | +// const blob = new Blob([resumeText], { type: 'text/plain;charset=utf-8' }); |
| 82 | +// saveAs(blob, 'Improved_Resume.txt'); |
| 83 | +// toast.success('Resume downloaded successfully!'); |
| 84 | +// }; |
| 85 | + |
| 86 | +// return ( |
| 87 | +// <div> |
| 88 | +// <ToastContainer /> |
| 89 | +// <h1>🚀 AI ResumeXpert Analyst</h1> |
| 90 | +// <p>Upload your resume to get detailed AI feedback, ATS analysis, and job match insights!</p> |
| 91 | + |
| 92 | +// <input type="file" onChange={handleFileUpload} /> |
| 93 | +// {resumeText && ( |
| 94 | +// <div> |
| 95 | +// <h3>Resume Text Extracted:</h3> |
| 96 | +// <textarea value={resumeText} readOnly rows="10" style={{ width: '100%' }}></textarea> |
| 97 | +// </div> |
| 98 | +// )} |
| 99 | + |
| 100 | +// <Tabs selectedIndex={tabIndex} onSelect={(index) => setTabIndex(index)}> |
| 101 | +// <TabList> |
| 102 | +// <Tab>📂 Upload Resume</Tab> |
| 103 | +// <Tab>📊 Job Match Analysis</Tab> |
| 104 | +// <Tab>🚀 AI Project Suggestions</Tab> |
| 105 | +// <Tab>🤷♂ ATS Score Checker</Tab> |
| 106 | +// <Tab>📊 AI-Powered Resume Ranking</Tab> |
| 107 | +// </TabList> |
| 108 | + |
| 109 | +// {/* Tab 1: Resume Upload and Analysis */} |
| 110 | +// <TabPanel> |
| 111 | +// <button onClick={analyzeResume}>Analyze Resume</button> |
| 112 | +// <button onClick={getResumeScore}>Get Resume Score</button> |
| 113 | +// <button onClick={downloadImprovedResume}>Download Improved Resume</button> |
| 114 | +// {feedback && ( |
| 115 | +// <p> |
| 116 | +// <strong>Feedback:</strong> {feedback} |
| 117 | +// </p> |
| 118 | +// )} |
| 119 | +// {score && ( |
| 120 | +// <p> |
| 121 | +// <strong>Score:</strong> {score} |
| 122 | +// </p> |
| 123 | +// )} |
| 124 | +// </TabPanel> |
| 125 | + |
| 126 | +// {/* Tab 2: Job Match Analysis */} |
| 127 | +// <TabPanel> |
| 128 | +// <textarea |
| 129 | +// placeholder="Paste job description here..." |
| 130 | +// rows="5" |
| 131 | +// style={{ width: '100%' }} |
| 132 | +// value={jobDescription} |
| 133 | +// onChange={(e) => setJobDescription(e.target.value)} |
| 134 | +// ></textarea> |
| 135 | +// <button onClick={() => toast.info('Job match analysis coming soon!')}>Analyze Job Fit</button> |
| 136 | +// </TabPanel> |
| 137 | + |
| 138 | +// {/* Tab 3: AI Project Suggestions */} |
| 139 | +// <TabPanel> |
| 140 | +// <button onClick={() => toast.info('Project suggestions coming soon!')}>Get Project Suggestions</button> |
| 141 | +// </TabPanel> |
| 142 | + |
| 143 | +// {/* Tab 4: ATS Score Checker */} |
| 144 | +// <TabPanel> |
| 145 | +// <button onClick={() => toast.info('ATS Score Checker coming soon!')}>Check ATS Score</button> |
| 146 | +// </TabPanel> |
| 147 | + |
| 148 | +// {/* Tab 5: AI-Powered Resume Ranking */} |
| 149 | +// <TabPanel> |
| 150 | +// <button onClick={() => toast.info('Resume ranking coming soon!')}>Rank Resumes</button> |
| 151 | +// </TabPanel> |
| 152 | +// </Tabs> |
| 153 | +// </div> |
| 154 | +// ); |
| 155 | +// }; |
| 156 | + |
| 157 | +// export default ResumeBuilder; |
158 | 158 |
|
159 | 159 | // https://github.com/abhishekkumar62000/AI-ResumeXpert-Analyst/blob/main/App.py |
160 | 160 | // # Import Important Library |
|
0 commit comments