diff --git a/src/app/(protected)/profile/page.tsx b/src/app/(protected)/profile/page.tsx index 5077228c..a05caa93 100644 --- a/src/app/(protected)/profile/page.tsx +++ b/src/app/(protected)/profile/page.tsx @@ -22,6 +22,7 @@ import { } from "@/components/ui/card"; import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar"; import { Separator } from "@/components/ui/separator"; +import { Label } from "@/components/ui/label"; import { toast } from "sonner"; import { User, @@ -39,9 +40,18 @@ import { GraduationCap, HelpCircle, Shield, + Upload, } from "lucide-react"; +import { useUpdateUser } from "@/lib/api/user/hook"; import { Roofing, Room } from "@mui/icons-material"; import { jwtDecode } from "jwt-decode"; +import { + Dialog, + DialogContent, + DialogDescription, + DialogHeader, + DialogTitle, +} from "@/components/ui/dialog"; // Role definitions matching AuthGuard enum Role { @@ -95,7 +105,13 @@ export default function Profile() { isPending: isCreatingAppleWallet, } = useCreateAppleWalletPass(); + // Mutation for resume upload + const { mutateAsync: uploadResume, isPending: isUploadingResume } = + useUpdateUser(); + const [showQRCode, setShowQRCode] = useState(false); + const [showResumeModal, setShowResumeModal] = useState(false); + const [resumeFile, setResumeFile] = useState(null); // Feature flag check for HelpDesk const { data: helpDeskFlag } = useFlagState("HelpDesk"); @@ -246,6 +262,39 @@ export default function Profile() { ); }; + const handleResumeUpload = async () => { + if (!resumeFile) { + return toast.error("Please select a PDF file to upload"); + } + + // Validate file type + if (resumeFile.type !== "application/pdf") { + return toast.error("Only PDF files are accepted"); + } + + // Validate file size (5MB max) + if (resumeFile.size > 5 * 1024 * 1024) { + return toast.error("File size must be less than 5MB"); + } + + if (!userData?.id) { + return toast.error("User ID not found"); + } + + try { + await uploadResume({ + id: userData.id, + data: { resume: resumeFile } as any, + }); + toast.success("Resume uploaded successfully!"); + setResumeFile(null); + setShowResumeModal(false); + } catch (error) { + console.error("Error uploading resume:", error); + toast.error("Failed to upload resume. Please try again."); + } + }; + if (isLoading) { return (
@@ -486,6 +535,7 @@ export default function Profile() { + {/* Actions */} @@ -540,6 +590,17 @@ export default function Profile() { Manage Extra Credit + + {helpDeskFlag?.isEnabled && ( + + {/* Resume Upload Modal */} + + + + Upload Resume + + Upload your resume in PDF format (max 5MB) + + +
+
+ + { + const file = e.target.files?.[0] || null; + if (file && file.type !== "application/pdf") { + toast.error("Only PDF files are accepted"); + e.target.value = ""; + setResumeFile(null); + return; + } + setResumeFile(file); + }} + className="flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50" + /> +
+ + {resumeFile && ( +
+

+ Selected: {resumeFile.name} +

+

+ Size: {(resumeFile.size / 1024).toFixed(1)} KB +

+
+ )} + +
+ + +
+
+
+
);