···
year: new Date().getFullYear(),
48
+
@state() deleteState: {
50
+
type: "class" | "waitlist";
52
+
timeout: number | null;
static override styles = css`
···
508
-
private async handleDelete(classId: string, courseName: string) {
511
-
`Are you sure you want to delete ${courseName}? This will remove all associated data and cannot be undone.`,
514
+
private handleDeleteClick(id: string, type: "class" | "waitlist") {
515
+
// If this is a different item or timeout expired, reset
516
+
if (!this.deleteState || this.deleteState.id !== id || this.deleteState.type !== type) {
517
+
// Clear any existing timeout
518
+
if (this.deleteState?.timeout) {
519
+
clearTimeout(this.deleteState.timeout);
523
+
const timeout = window.setTimeout(() => {
524
+
this.deleteState = null;
527
+
this.deleteState = { id, type, clicks: 1, timeout };
531
+
// Increment clicks
532
+
const newClicks = this.deleteState.clicks + 1;
534
+
// Clear existing timeout
535
+
if (this.deleteState.timeout) {
536
+
clearTimeout(this.deleteState.timeout);
539
+
// Third click - actually delete
540
+
if (newClicks === 3) {
541
+
this.deleteState = null;
542
+
if (type === "class") {
543
+
this.performDeleteClass(id);
545
+
this.performDeleteWaitlist(id);
550
+
// Second click - reset timeout
551
+
const timeout = window.setTimeout(() => {
552
+
this.deleteState = null;
555
+
this.deleteState = { id, type, clicks: newClicks, timeout };
558
+
private getDeleteButtonText(id: string, type: "class" | "waitlist"): string {
559
+
if (!this.deleteState || this.deleteState.id !== id || this.deleteState.type !== type) {
563
+
if (this.deleteState.clicks === 1) {
564
+
return "Are you sure?";
567
+
if (this.deleteState.clicks === 2) {
568
+
return "Final warning!";
574
+
private async performDeleteClass(classId: string) {
const response = await fetch(`/api/classes/${classId}`, {
···
532
-
private handleCreateClass() {
533
-
this.showCreateModal = true;
536
-
private async handleDeleteWaitlist(id: string, courseCode: string) {
539
-
`Are you sure you want to delete this waitlist request for ${courseCode}?`,
590
+
private async performDeleteWaitlist(id: string) {
const response = await fetch(`/api/admin/waitlist/${id}`, {
···
this.error = "Failed to delete waitlist entry. Please try again.";
606
+
private handleCreateClass() {
607
+
this.showCreateModal = true;
private getFilteredClasses() {
···
655
-
@click=${() => this.handleDelete(cls.id, cls.course_code)}
705
+
@click=${() => this.handleDeleteClick(cls.id, "class")}
707
+
${this.getDeleteButtonText(cls.id, "class")}
···
709
-
@click=${() => this.handleDeleteWaitlist(entry.id, entry.course_code)}
759
+
@click=${() => this.handleDeleteClick(entry.id, "waitlist")}
761
+
${this.getDeleteButtonText(entry.id, "waitlist")}