remove temp notification settings
This commit is contained in:
parent
cf4cda5628
commit
a0b2702bed
1 changed files with 227 additions and 72 deletions
|
@ -3,7 +3,8 @@
|
||||||
import allMajors from "../../data/allUCSDMajors.txt?raw";
|
import allMajors from "../../data/allUCSDMajors.txt?raw";
|
||||||
const majorsList: string[] = allMajors
|
const majorsList: string[] = allMajors
|
||||||
.split("\n")
|
.split("\n")
|
||||||
.filter((major: string) => major.trim());
|
.filter((major: string) => major.trim())
|
||||||
|
.sort((a, b) => a.localeCompare(b)); // Sort alphabetically
|
||||||
---
|
---
|
||||||
|
|
||||||
<div class="card bg-base-100 shadow-xl">
|
<div class="card bg-base-100 shadow-xl">
|
||||||
|
@ -144,82 +145,136 @@ const majorsList: string[] = allMajors
|
||||||
>Upload your latest resume</span
|
>Upload your latest resume</span
|
||||||
>
|
>
|
||||||
</label>
|
</label>
|
||||||
<div class="flex flex-col gap-2">
|
<div class="space-y-4">
|
||||||
<p
|
<!-- Current Resume Display -->
|
||||||
id="currentResume"
|
<div id="resumeDisplay" class="hidden">
|
||||||
class="text-sm text-base-content/70"
|
<div
|
||||||
>
|
class="flex items-center gap-2 p-3 bg-base-100 rounded-lg border border-base-300"
|
||||||
No resume uploaded
|
>
|
||||||
</p>
|
<div class="flex-1 flex items-center gap-3">
|
||||||
<input
|
<svg
|
||||||
type="file"
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
id="resumeUpload"
|
class="h-8 w-8 text-primary"
|
||||||
accept=".pdf,.doc,.docx"
|
viewBox="0 0 20 20"
|
||||||
class="file-input file-input-bordered file-input-sm w-full"
|
fill="currentColor"
|
||||||
/>
|
>
|
||||||
<label class="label">
|
<path
|
||||||
|
fill-rule="evenodd"
|
||||||
|
d="M4 4a2 2 0 012-2h4.586A2 2 0 0112 2.586L15.414 6A2 2 0 0116 7.414V16a2 2 0 01-2 2H6a2 2 0 01-2-2V4zm2 6a1 1 0 011-1h6a1 1 0 110 2H7a1 1 0 01-1-1zm1 3a1 1 0 100 2h6a1 1 0 100-2H7z"
|
||||||
|
clip-rule="evenodd"></path>
|
||||||
|
</svg>
|
||||||
|
<div class="flex-1 min-w-0">
|
||||||
|
<p
|
||||||
|
id="currentResume"
|
||||||
|
class="text-sm font-medium truncate"
|
||||||
|
>
|
||||||
|
No resume uploaded
|
||||||
|
</p>
|
||||||
|
<p
|
||||||
|
class="text-xs text-base-content/70"
|
||||||
|
>
|
||||||
|
PDF, DOC, or DOCX
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="flex-none flex gap-2">
|
||||||
|
<button
|
||||||
|
id="previewResume"
|
||||||
|
class="btn btn-sm btn-ghost"
|
||||||
|
onclick="resumeViewer.showModal()"
|
||||||
|
>
|
||||||
|
<svg
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
class="h-4 w-4"
|
||||||
|
viewBox="0 0 20 20"
|
||||||
|
fill="currentColor"
|
||||||
|
>
|
||||||
|
<path
|
||||||
|
d="M10 12a2 2 0 100-4 2 2 0 000 4z"
|
||||||
|
></path>
|
||||||
|
<path
|
||||||
|
fill-rule="evenodd"
|
||||||
|
d="M.458 10C1.732 5.943 5.522 3 10 3s8.268 2.943 9.542 7c-1.274 4.057-5.064 7-9.542 7S1.732 14.057.458 10zM14 10a4 4 0 11-8 0 4 4 0 018 0z"
|
||||||
|
clip-rule="evenodd"></path>
|
||||||
|
</svg>
|
||||||
|
Preview
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Upload Input -->
|
||||||
|
<div class="flex items-center gap-2">
|
||||||
|
<input
|
||||||
|
type="file"
|
||||||
|
id="resumeUpload"
|
||||||
|
accept=".pdf,.doc,.docx"
|
||||||
|
class="file-input file-input-bordered file-input-primary w-full"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Upload Status -->
|
||||||
|
<div class="text-sm">
|
||||||
<span id="uploadStatus" class="label-text-alt"
|
<span id="uploadStatus" class="label-text-alt"
|
||||||
></span>
|
></span>
|
||||||
</label>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Notification Preferences Section -->
|
|
||||||
<div class="bg-base-200 rounded-box p-6">
|
|
||||||
<div class="flex items-center gap-2 mb-6">
|
|
||||||
<svg
|
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
|
||||||
class="h-5 w-5"
|
|
||||||
viewBox="0 0 20 20"
|
|
||||||
fill="currentColor"
|
|
||||||
>
|
|
||||||
<path
|
|
||||||
d="M10 2a6 6 0 00-6 6v3.586l-.707.707A1 1 0 004 14h12a1 1 0 00.707-1.707L16 11.586V8a6 6 0 00-6-6zM10 18a3 3 0 01-3-3h6a3 3 0 01-3 3z"
|
|
||||||
></path>
|
|
||||||
</svg>
|
|
||||||
<h3 class="text-xl font-medium">
|
|
||||||
Notification Preferences
|
|
||||||
</h3>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="grid gap-4">
|
|
||||||
<div class="flex items-center justify-between">
|
|
||||||
<div>
|
|
||||||
<h3 class="font-medium">Event Reminders</h3>
|
|
||||||
<p class="text-sm text-base-content/70">
|
|
||||||
Get notified about upcoming events
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
<input
|
|
||||||
type="checkbox"
|
|
||||||
class="toggle toggle-primary"
|
|
||||||
checked
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<div class="flex items-center justify-between">
|
|
||||||
<div>
|
|
||||||
<h3 class="font-medium">Newsletter</h3>
|
|
||||||
<p class="text-sm text-base-content/70">
|
|
||||||
Receive our monthly newsletter
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
<input
|
|
||||||
type="checkbox"
|
|
||||||
class="toggle toggle-primary"
|
|
||||||
checked
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- Resume Viewer Modal -->
|
||||||
|
<dialog id="resumeViewer" class="modal">
|
||||||
|
<div class="modal-box w-11/12 max-w-5xl h-[80vh]">
|
||||||
|
<div class="flex justify-between items-center mb-4">
|
||||||
|
<h3 class="font-bold text-lg" id="resumeTitle">Resume Preview</h3>
|
||||||
|
<div class="flex items-center gap-2">
|
||||||
|
<a
|
||||||
|
id="resumeExternalLink"
|
||||||
|
href="#"
|
||||||
|
target="_blank"
|
||||||
|
class="btn btn-sm btn-ghost"
|
||||||
|
>
|
||||||
|
<svg
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
class="h-4 w-4 mr-1"
|
||||||
|
viewBox="0 0 20 20"
|
||||||
|
fill="currentColor"
|
||||||
|
>
|
||||||
|
<path
|
||||||
|
d="M11 3a1 1 0 100 2h2.586l-6.293 6.293a1 1 0 101.414 1.414L15 6.414V9a1 1 0 102 0V4a1 1 0 00-1-1h-5z"
|
||||||
|
></path>
|
||||||
|
<path
|
||||||
|
d="M5 5a2 2 0 00-2 2v8a2 2 0 002 2h8a2 2 0 002-2v-3a1 1 0 10-2 0v3H5V7h3a1 1 0 000-2H5z"
|
||||||
|
></path>
|
||||||
|
</svg>
|
||||||
|
Open in New Tab
|
||||||
|
</a>
|
||||||
|
<form method="dialog">
|
||||||
|
<button class="btn btn-sm btn-circle btn-ghost">✕</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="h-[calc(100%-4rem)]">
|
||||||
|
<iframe
|
||||||
|
id="resumeFrame"
|
||||||
|
class="w-full h-full rounded-lg border-2 border-base-300"
|
||||||
|
src=""></iframe>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<form method="dialog" class="modal-backdrop">
|
||||||
|
<button>close</button>
|
||||||
|
</form>
|
||||||
|
</dialog>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { StoreAuth } from "../auth/StoreAuth";
|
import { StoreAuth } from "../auth/StoreAuth";
|
||||||
|
import { SendLog } from "../auth/SendLog";
|
||||||
const auth = new StoreAuth();
|
const auth = new StoreAuth();
|
||||||
|
const logger = new SendLog();
|
||||||
|
|
||||||
// Get form elements
|
// Get form elements
|
||||||
const memberIdInput = document.getElementById(
|
const memberIdInput = document.getElementById(
|
||||||
|
@ -238,6 +293,19 @@ const majorsList: string[] = allMajors
|
||||||
const uploadStatus = document.getElementById("uploadStatus");
|
const uploadStatus = document.getElementById("uploadStatus");
|
||||||
const saveSettings = document.getElementById("saveSettings");
|
const saveSettings = document.getElementById("saveSettings");
|
||||||
|
|
||||||
|
// Add resume preview functionality
|
||||||
|
const resumeDisplay = document.getElementById("resumeDisplay");
|
||||||
|
const previewResume = document.getElementById("previewResume");
|
||||||
|
const resumeViewer = document.getElementById(
|
||||||
|
"resumeViewer"
|
||||||
|
) as HTMLDialogElement;
|
||||||
|
const resumeFrame = document.getElementById(
|
||||||
|
"resumeFrame"
|
||||||
|
) as HTMLIFrameElement;
|
||||||
|
const resumeExternalLink = document.getElementById(
|
||||||
|
"resumeExternalLink"
|
||||||
|
) as HTMLAnchorElement;
|
||||||
|
|
||||||
// Load current user data
|
// Load current user data
|
||||||
const loadUserData = () => {
|
const loadUserData = () => {
|
||||||
const authState = auth.getAuthState();
|
const authState = auth.getAuthState();
|
||||||
|
@ -249,9 +317,22 @@ const majorsList: string[] = allMajors
|
||||||
gradYearSelect.value = user.graduation_year || "";
|
gradYearSelect.value = user.graduation_year || "";
|
||||||
|
|
||||||
// Update resume display
|
// Update resume display
|
||||||
if (currentResume && user.resume) {
|
if (currentResume && resumeDisplay) {
|
||||||
const fileName = user.resume.toString().split("/").pop();
|
if (user.resume) {
|
||||||
currentResume.textContent = fileName || "Resume uploaded";
|
const fileName = user.resume.toString().split("/").pop();
|
||||||
|
currentResume.textContent = fileName || "Resume uploaded";
|
||||||
|
resumeDisplay.classList.remove("hidden");
|
||||||
|
|
||||||
|
// Set up preview URLs - using the correct PocketBase file URL format
|
||||||
|
const resumeUrl = `${import.meta.env.POCKETBASE_URL}/api/files/users/${user.id}/${user.resume}`;
|
||||||
|
if (resumeFrame) resumeFrame.src = resumeUrl;
|
||||||
|
if (resumeExternalLink) resumeExternalLink.href = resumeUrl;
|
||||||
|
} else {
|
||||||
|
currentResume.textContent = "No resume uploaded";
|
||||||
|
resumeDisplay.classList.add("hidden");
|
||||||
|
if (resumeFrame) resumeFrame.src = "";
|
||||||
|
if (resumeExternalLink) resumeExternalLink.href = "#";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -266,9 +347,23 @@ const majorsList: string[] = allMajors
|
||||||
await auth.handleResumeUpload(file);
|
await auth.handleResumeUpload(file);
|
||||||
uploadStatus.textContent = "Resume uploaded successfully";
|
uploadStatus.textContent = "Resume uploaded successfully";
|
||||||
if (currentResume) currentResume.textContent = file.name;
|
if (currentResume) currentResume.textContent = file.name;
|
||||||
|
|
||||||
|
// Log successful resume upload
|
||||||
|
await logger.send(
|
||||||
|
"update",
|
||||||
|
"resume upload",
|
||||||
|
`Successfully uploaded resume: ${file.name}`
|
||||||
|
);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error("Resume upload error:", err);
|
console.error("Resume upload error:", err);
|
||||||
uploadStatus.textContent = "Failed to upload resume";
|
uploadStatus.textContent = "Failed to upload resume";
|
||||||
|
|
||||||
|
// Log resume upload error
|
||||||
|
await logger.send(
|
||||||
|
"error",
|
||||||
|
"resume upload",
|
||||||
|
`Failed to upload resume: ${file.name}. Error: ${err instanceof Error ? err.message : "Unknown error"}`
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -281,13 +376,48 @@ const majorsList: string[] = allMajors
|
||||||
button.classList.add("loading");
|
button.classList.add("loading");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const data = {
|
const authState = auth.getAuthState();
|
||||||
member_id: memberIdInput?.value,
|
const oldData = {
|
||||||
major: majorSelect?.value,
|
major: authState.model?.major || null,
|
||||||
graduation_year: gradYearSelect?.value,
|
graduation_year: authState.model?.graduation_year || null,
|
||||||
|
member_id: authState.model?.member_id || null,
|
||||||
};
|
};
|
||||||
|
|
||||||
await auth.updateProfileSettings(data);
|
const newData = {
|
||||||
|
major: majorSelect?.value || null,
|
||||||
|
graduation_year: gradYearSelect?.value
|
||||||
|
? parseInt(gradYearSelect.value)
|
||||||
|
: null,
|
||||||
|
member_id: memberIdInput?.value || null,
|
||||||
|
} as const;
|
||||||
|
|
||||||
|
await auth.updateProfileSettings(newData);
|
||||||
|
|
||||||
|
// Create detailed log message of changes
|
||||||
|
const changes = [];
|
||||||
|
if (oldData.major !== newData.major) {
|
||||||
|
changes.push(
|
||||||
|
`Major: "${oldData.major || "none"}" → "${newData.major || "none"}"`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (oldData.graduation_year !== newData.graduation_year) {
|
||||||
|
changes.push(
|
||||||
|
`Graduation Year: "${oldData.graduation_year || "none"}" → "${newData.graduation_year || "none"}"`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (oldData.member_id !== newData.member_id) {
|
||||||
|
changes.push(
|
||||||
|
`IEEE Member ID: "${oldData.member_id || "none"}" → "${newData.member_id || "none"}"`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (changes.length > 0) {
|
||||||
|
await logger.send(
|
||||||
|
"update",
|
||||||
|
"profile settings",
|
||||||
|
`Updated profile settings:\n${changes.join("\n")}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// Show success toast
|
// Show success toast
|
||||||
const toast = document.createElement("div");
|
const toast = document.createElement("div");
|
||||||
|
@ -308,6 +438,25 @@ const majorsList: string[] = allMajors
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error("Failed to save settings:", err);
|
console.error("Failed to save settings:", err);
|
||||||
|
|
||||||
|
// Log the settings update error with details
|
||||||
|
const errorDetails = {
|
||||||
|
attempted_major: majorSelect?.value || "none",
|
||||||
|
attempted_graduation_year: gradYearSelect?.value || "none",
|
||||||
|
attempted_member_id: memberIdInput?.value || "none",
|
||||||
|
error_message:
|
||||||
|
err instanceof Error ? err.message : "Unknown error",
|
||||||
|
};
|
||||||
|
|
||||||
|
await logger.send(
|
||||||
|
"error",
|
||||||
|
"profile settings",
|
||||||
|
`Failed to update profile settings:\nAttempted changes:\n` +
|
||||||
|
`Major: ${errorDetails.attempted_major}\n` +
|
||||||
|
`Graduation Year: ${errorDetails.attempted_graduation_year}\n` +
|
||||||
|
`IEEE Member ID: ${errorDetails.attempted_member_id}\n` +
|
||||||
|
`Error: ${errorDetails.error_message}`
|
||||||
|
);
|
||||||
|
|
||||||
// Show error toast
|
// Show error toast
|
||||||
const toast = document.createElement("div");
|
const toast = document.createElement("div");
|
||||||
toast.className =
|
toast.className =
|
||||||
|
@ -338,3 +487,9 @@ const majorsList: string[] = allMajors
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.hidden {
|
||||||
|
display: none !important;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
Loading…
Reference in a new issue