used new fileviewermodal
This commit is contained in:
parent
f3efea865b
commit
cca038397c
1 changed files with 23 additions and 17 deletions
|
@ -182,7 +182,6 @@ const majorsList: string[] = allMajors
|
||||||
<button
|
<button
|
||||||
id="previewResume"
|
id="previewResume"
|
||||||
class="btn btn-sm btn-ghost"
|
class="btn btn-sm btn-ghost"
|
||||||
onclick="showResumePreview(resumeUrl, fileName)"
|
|
||||||
>
|
>
|
||||||
<svg
|
<svg
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
@ -266,21 +265,15 @@ const majorsList: string[] = allMajors
|
||||||
const resumeDisplay = document.getElementById("resumeDisplay");
|
const resumeDisplay = document.getElementById("resumeDisplay");
|
||||||
const previewResume = document.getElementById("previewResume");
|
const previewResume = document.getElementById("previewResume");
|
||||||
|
|
||||||
// Function to show resume in FileViewerModal
|
// Helper function to get file type
|
||||||
const showResumePreview = (url: string, fileName: string) => {
|
const getFileType = (fileName: string): string => {
|
||||||
// Create and dispatch custom event for FileViewerModal
|
const extension = fileName.split(".").pop()?.toLowerCase() || "";
|
||||||
const showFileViewerEvent = new CustomEvent("showFileViewer", {
|
const mimeTypes: Record<string, string> = {
|
||||||
detail: {
|
pdf: "application/pdf",
|
||||||
files: {
|
doc: "application/msword",
|
||||||
url,
|
docx: "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
||||||
name: fileName,
|
};
|
||||||
type: fileName.toLowerCase().endsWith(".pdf")
|
return mimeTypes[extension] || "application/octet-stream";
|
||||||
? "application/pdf"
|
|
||||||
: "application/octet-stream",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
window.dispatchEvent(showFileViewerEvent);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Load current user data
|
// Load current user data
|
||||||
|
@ -311,7 +304,20 @@ const majorsList: string[] = allMajors
|
||||||
// Update preview button to use new modal
|
// Update preview button to use new modal
|
||||||
if (previewResume) {
|
if (previewResume) {
|
||||||
previewResume.onclick = () => {
|
previewResume.onclick = () => {
|
||||||
showResumePreview(resumeUrl, fileName);
|
// Dispatch custom event for FileViewerModal
|
||||||
|
const showFileViewerEvent = new CustomEvent(
|
||||||
|
"showFileViewer",
|
||||||
|
{
|
||||||
|
detail: {
|
||||||
|
files: {
|
||||||
|
url: resumeUrl,
|
||||||
|
name: fileName,
|
||||||
|
type: getFileType(fileName),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
);
|
||||||
|
window.dispatchEvent(showFileViewerEvent);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue