···
year: new Date().getFullYear(),
+
@state() deleteState: {
+
type: "class" | "waitlist";
+
timeout: number | null;
static override styles = css`
···
+
private handleDeleteClick(id: string, type: "class" | "waitlist") {
+
// If this is a different item or timeout expired, reset
+
if (!this.deleteState || this.deleteState.id !== id || this.deleteState.type !== type) {
+
// Clear any existing timeout
+
if (this.deleteState?.timeout) {
+
clearTimeout(this.deleteState.timeout);
+
const timeout = window.setTimeout(() => {
+
this.deleteState = null;
+
this.deleteState = { id, type, clicks: 1, timeout };
+
const newClicks = this.deleteState.clicks + 1;
+
// Clear existing timeout
+
if (this.deleteState.timeout) {
+
clearTimeout(this.deleteState.timeout);
+
// Third click - actually delete
+
this.deleteState = null;
+
if (type === "class") {
+
this.performDeleteClass(id);
+
this.performDeleteWaitlist(id);
+
// Second click - reset timeout
+
const timeout = window.setTimeout(() => {
+
this.deleteState = null;
+
this.deleteState = { id, type, clicks: newClicks, timeout };
+
private getDeleteButtonText(id: string, type: "class" | "waitlist"): string {
+
if (!this.deleteState || this.deleteState.id !== id || this.deleteState.type !== type) {
+
if (this.deleteState.clicks === 1) {
+
return "Are you sure?";
+
if (this.deleteState.clicks === 2) {
+
return "Final warning!";
+
private async performDeleteClass(classId: string) {
const response = await fetch(`/api/classes/${classId}`, {
···
+
private async performDeleteWaitlist(id: string) {
const response = await fetch(`/api/admin/waitlist/${id}`, {
···
this.error = "Failed to delete waitlist entry. Please try again.";
+
private handleCreateClass() {
+
this.showCreateModal = true;
private getFilteredClasses() {
···
+
@click=${() => this.handleDeleteClick(cls.id, "class")}
+
${this.getDeleteButtonText(cls.id, "class")}
···
+
@click=${() => this.handleDeleteClick(entry.id, "waitlist")}
+
${this.getDeleteButtonText(entry.id, "waitlist")}