Skip to content
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

Add resume removal #409

Merged
merged 1 commit into from
May 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 59 additions & 16 deletions src/pages/Networking/Networking.page.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useAuth as useAuthProvider } from "@/providers/auth.provider";
import { FormEventHandler, useEffect, useRef, useState } from "react";
import { MdOutlineEdit, MdOpenInNew, MdWarning } from "react-icons/md";
import { MdOutlineEdit, MdOpenInNew, MdWarning, MdOutlineRemoveCircleOutline } from "react-icons/md";
import { LoadingAnimation } from "@/components/LoadingAnimation";
import {
getResumeURL,
Expand Down Expand Up @@ -211,7 +211,7 @@ export const NetworkingPage = () => {
}
/>
{mediaValues[key] && (
<MdOutlineEdit className="absolute right-2 top-1/2 -translate-y-1/2 w-5 h-5" />
<MdOutlineEdit className="text-gray-500 absolute right-2 top-1/2 -translate-y-1/2 w-5 h-5" />
)}
</div>

Expand Down Expand Up @@ -250,7 +250,24 @@ export const NetworkingPage = () => {
</p>
)}
</div>

<div className="flex items-center gap-4">
<label
htmlFor="resume-file-input"
className="flex-grow rounded-lg px-4 py-2 bg-peachWhite hover:cursor-pointer overflow-hidden"
>
<span className="block overflow-hidden text-ellipsis whitespace-nowrap">
{file ? file.name : "Select new resume file"}
</span>
<input
id="resume-file-input"
className="sr-only"
type="file"
accept={allowedFileTypes.join(", ")}
onChange={handleFileInput}
/>
</label>

<button
title="Open Resume in new tab"
type="button"
Expand Down Expand Up @@ -283,21 +300,47 @@ export const NetworkingPage = () => {
>
<MdOpenInNew className="text-gray-500 w-6 h-6" />
</button>
<label
htmlFor="resume-file-input"
className="flex-grow rounded-lg px-4 py-2 bg-peachWhite hover:cursor-pointer overflow-hidden"

<button
title="Remove Resume"
type="button"
className="p-2 bg-peachWhite rounded-lg flex items-center justify-center hover:cursor-pointer flex-shrink-0"
onClick={async () => {
if (mediaValues.resumeRef) {
try {
await updateSocials({
...mediaValues,
resumeRef: "",
});
setSocials(
socials
? {
...socials,
resumeRef: "",
}
: null
);
setMediaValues({
...mediaValues,
resumeRef: "",
});
} catch (error) {
showNotification({
title: "Error",
message:
"Failed to remove resume. Please try again.",
});
}
} else {
showNotification({
title: "Error",
message: "No resume found to remove.",
});
}
}}
>
<span className="block overflow-hidden text-ellipsis whitespace-nowrap">
{file ? file.name : "Select new resume file"}
</span>
<input
id="resume-file-input"
className="sr-only"
type="file"
accept={allowedFileTypes.join(", ")}
onChange={handleFileInput}
/>
</label>
<MdOutlineRemoveCircleOutline className="text-red-500 w-6 h-6" />
</button>
</div>
{editMode === "resume" && (
<div className="mt-4 flex gap-2">
Expand Down