-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.jsx
More file actions
303 lines (266 loc) · 8.76 KB
/
Copy pathindex.jsx
File metadata and controls
303 lines (266 loc) · 8.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
import {
DialogActions,
DialogContent,
DialogTitle,
Button,
IconButton,
Box,
} from "@mui/material/";
import { Add, Close, HighlightOff } from "@mui/icons-material";
import { useState, useEffect } from "react";
import { TextField, CircularProgress } from "@mui/material";
import { useHandleCopy } from "hooks";
import BootstrapDialog from "./BootstrapDialog";
import axios from "axios";
import { ErrorMessage } from "components";
const Module = ({
message,
coverLetter,
setCurrentCoverLetter,
setCurrentData,
currentData,
}) => {
const handleCopy = useHandleCopy();
const [open, setOpen] = useState(false);
const serverURL = process.env.REACT_APP_SERVER_URL;
const scrapeAPIUrl = `${serverURL}/scrape`;
const [companyNotFound, setCompanyNotFound] = useState(false);
const [jobNameNotFound, setJobNameNotFound] = useState(false);
const [loading, setLoading] = useState(false);
const setCompanyAndJobFound = (data) => {
setCompanyNotFound(data);
setJobNameNotFound(data);
};
//TODO: This needs to be consolidated somehow since we using it twice
const getScrapedData = (url) => {
setLoading(true);
axios
.get(`${scrapeAPIUrl}/${url}`)
.then((response) => {
if (response.data) {
setCurrentData((prev) => {
const updatedData = {
...prev,
jobName: response.data.jobTitle || "",
company: response.data.companyName || "",
};
setCurrentCoverLetter(generateCoverLetter(updatedData));
return updatedData;
});
setCompanyNotFound(!response.data.companyName);
setJobNameNotFound(!response.data.jobTitle);
}
})
.catch((error) => {
console.error("Failed to fetch:", error.message);
setCompanyAndJobFound(true);
})
.finally(() => {
setLoading(false);
});
};
const handleInputChange = (e) => {
const { name, value } = e.target;
if (name === "url") {
getScrapedData(value);
}
setCurrentData((prev) => {
const updatedData = { ...prev, [name]: value };
setCurrentCoverLetter(generateCoverLetter(updatedData));
return updatedData;
});
if (name === "company" && value.trim() !== "") {
setCompanyNotFound(false);
}
if (name === "jobName" && value.trim() !== "") {
setJobNameNotFound(false);
}
};
const handleClickOpen = () => {
setOpen(true);
};
const handleClose = () => {
setOpen(false);
};
const clearInput = (value) => {
setCurrentData((prev) => ({
...prev,
[value]: "",
}));
setCurrentData((prev) => {
const updatedData = { ...prev, [name]: value };
setCurrentCoverLetter(generateCoverLetter(updatedData));
return updatedData;
});
setCompanyAndJobFound(false);
};
const clearForm = () => {
setCurrentData({
url: "",
jobName: "",
company: "",
message: "",
});
setCurrentData((prev) => {
const updatedData = { ...prev, [name]: "" };
setCurrentCoverLetter(generateCoverLetter(updatedData));
return updatedData;
});
setCompanyNotFound(false);
setJobNameNotFound(false);
};
const moduleTextFieldInputs = [
{
label: "URL Link",
name: "url",
value: "",
required: true,
multiline: false,
},
{
label: "Job Name",
name: "jobName",
value: "",
required: true,
multiline: false,
},
{
label: "Company",
name: "company",
value: "",
required: true,
multiline: false,
},
{
label: "Message",
name: "message",
value: "",
required: true,
multiline: true,
},
];
const generateCoverLetter = (data) => `
Hi there, thanks for taking the time to review my application! My name is Som–I’m a Junior front-end developer, and I primarily code in Javascript. I am excited to be applying for ${data.jobName} at ${data.company}.
I have taken computer science classes at Fairleigh Dickinson University and I hold an associate degree in web development where I learned HTML, CSS & SQL.
When I finished my associate's degree, I went to the Rutgers Coding Bootcamp to further my knowledge of web development. At Rutgers, I learned more about HTML/CSS, and then I learned JavaScript & React.
After the bootcamp, I worked at Trendsetter as a software engineer intern for 7 months. Trendsetter is a digital marketing company that helps promote artists. The project I was working on was an internal dashboard application built on React, NextJS & TypeScript. I was mainly working on the front-end to help set up the initial project so the project could be shipped out to the team.
I am currently a fellow at Formation, a highly selective program where I work with top-tier engineers from companies like Meta, Airbnb & Amazon. I have been learning best practices for front-end development specifically related to React.
I am now looking for a Developer role with a company where I can contribute my skills within a strong team where I can learn, grow and make a meaningful impact.
I look forward to working at ${data.company} because ${data.message}.`;
useEffect(() => {
const observer = new ResizeObserver(() => {
window.requestAnimationFrame(() => {
window.dispatchEvent(new Event("resize"));
});
});
observer.observe(document.body);
return () => observer.disconnect();
}, []);
return (
<div style={{ maxWidth: "900px" }}>
<Button
variant="contained"
color="primary"
onClick={() => handleClickOpen()}
startIcon={<Add />}
>
{message}
</Button>
<BootstrapDialog
onClose={handleClose}
aria-labelledby="customized-dialog-title"
open={open}
sx={{ "& .MuiDialog-paper": { width: "900px", maxWidth: "100%" } }}
>
<DialogTitle sx={{ m: 0, p: 2 }} id="customized-dialog-title">
{message}
</DialogTitle>
<IconButton
aria-label="close"
onClick={handleClose}
sx={(theme) => ({
position: "absolute",
right: 8,
top: 8,
color: theme.palette.grey[500],
})}
>
<Close />
</IconButton>
<DialogContent dividers>
<TextField
id="outlined-textarea"
label={message}
placeholder={"Placeholder"}
value={coverLetter}
sx={{ width: "100%", marginBottom: "16px" }}
onChange={(event) => {
setCurrentCoverLetter(event.target.value);
}}
multiline
/>
{moduleTextFieldInputs.map((data, index) => (
<Box key={index} sx={{ position: "relative", mb: 2 }}>
<TextField
fullWidth
label={data.label}
name={data.name}
value={currentData[data.name]}
onChange={handleInputChange}
required={data.required}
multiline={data.multiline}
/>
{currentData[data.name] && (
<IconButton
sx={{
position: "absolute",
right: 10,
top: "50%",
transform: "translateY(-50%)",
}}
onClick={() => clearInput(data.name)}
>
<HighlightOff />
</IconButton>
)}
{(data.name === "jobName" || data.name === "company") &&
loading && (
<Box
sx={{
position: "absolute",
right: 10,
top: "50%",
transform: "translateY(-50%)",
zIndex: 1,
}}
>
<CircularProgress size={24} />
</Box>
)}
<ErrorMessage
fieldName="Company"
isFieldNotFound={companyNotFound && data.name === "company"}
/>
<ErrorMessage
fieldName="Job Title"
isFieldNotFound={jobNameNotFound && data.name === "jobName"}
/>
</Box>
))}
</DialogContent>
<DialogActions>
<Button autoFocus onClick={() => handleCopy(coverLetter)}>
Copy
</Button>
<Button autoFocus onClick={clearForm}>
Clear Form
</Button>
<Button autoFocus onClick={handleClose}>
Save changes (Add to cover letter board)
</Button>
</DialogActions>
</BootstrapDialog>
</div>
);
};
export default Module;