-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat/add on click to update applied on date #81
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You could add a cypress test to verify that the data is saving in the back end (see the handleSave() function notes for additional context. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,6 +47,8 @@ function JobApplication() { | |
const [jobDescription, setJobDescription] = useState(''); | ||
const [applicationURL, setApplicationURL] = useState(''); | ||
const [companyId, setCompanyId] = useState(''); | ||
const [isEditing, setIsEditing] = useState(false); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could this be editing and setEditing instead of isEditing and setIsEditing? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree with you that editing and setEditing read better, but I was trying to maintain consistency with other boolean state syntax in showJobApplication.tsx. For example, modal state is managed through "isModalOpen, setIsModalOpen", and edit model state is managed through "isEditModelOpen, setIsEditModelOpen." There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I like the consistency that Danielle applied. It might be good to add an issue/ticket to refactor all of the "is" parts in the code into simply "set". |
||
const [editedDate, setEditedDate] = useState(jobApp ? jobApp.date_applied : '') | ||
|
||
useEffect(() => { | ||
if (jobAppId) { | ||
|
@@ -62,6 +64,7 @@ function JobApplication() { | |
setJobDescription(data.data.attributes.job_description) | ||
setApplicationURL(data.data.attributes.application_url) | ||
setCompanyId(data.data.attributes.company_id) | ||
setEditedDate(data.data.attributes.date_applied ? data.data.attributes.date_applied.toString() : '') | ||
|
||
} catch (err) { | ||
console.error("Failed to fetch job application:", err); | ||
|
@@ -72,6 +75,11 @@ function JobApplication() { | |
} | ||
}, [jobAppId]); | ||
|
||
const handleSave = () => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't believe that the You could add a cypress test to verify that the data is saving in the back end. |
||
setIsEditing(false) | ||
setEditedDate(editedDate) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because editedDate is already the current value in state, this code on line 80, |
||
} | ||
|
||
const openModal = () => setIsModalOpen(true); | ||
const closeModal = () => setIsModalOpen(false); | ||
|
||
|
@@ -91,7 +99,7 @@ function JobApplication() { | |
job_description: jobDescription, | ||
application_url: applicationURL | ||
} | ||
console.log(compileData) | ||
|
||
updateJobApplication(compileData) | ||
.then((updatedApplication) => { | ||
console.log("Application updated successfully:", updatedApplication); | ||
|
@@ -122,9 +130,25 @@ function JobApplication() { | |
</Link> | ||
<p className="font-medium mb-4"> | ||
Applied On:{" "} | ||
<span className="font-semibold"> | ||
{`${jobApp.date_applied}`} | ||
</span> | ||
{isEditing ? ( | ||
<input | ||
type="date" | ||
id="dateApplied" | ||
value={editedDate instanceof Date ? editedDate.toString().split('T')[0] : editedDate} | ||
onChange={(e) => setEditedDate(e.target.value)} | ||
className="p-2 border-4 border-slate-800 rounded-lg focus:outline-none focus:ring-2 transition-all duration-200 ease-in-out" | ||
onBlur={handleSave} | ||
required | ||
/> | ||
) : ( | ||
<span | ||
className="font-semibold cursor-pointer underline underline-dashed hover:text-blue-500 transition-all duration-150 ease-in-out" | ||
onClick={() => setIsEditing(true)} | ||
> | ||
{editedDate instanceof Date ? editedDate.toString().split('T')[0] : editedDate} | ||
</span> | ||
)} | ||
|
||
</p> | ||
<p className="mb-6"> | ||
Status:{" "} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like you accidentally listed your Github twice instead of adding the LinkedIn link.