🪻 distributed transcription service thistle.dunkirk.sh
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

bug: fix the add classes button

+31 -12
+31 -12
src/components/admin-classes.ts
··· 34 34 @state() isLoading = true; 35 35 @state() error = ""; 36 36 @state() searchTerm = ""; 37 - @state() showCreateModal = false; 37 + 38 38 @state() activeTab: "classes" | "waitlist" = "classes"; 39 39 @state() approvingEntry: WaitlistEntry | null = null; 40 + @state() showModal = false; 40 41 @state() meetingTimes: MeetingTime[] = []; 41 42 @state() editingClass = { 42 43 courseCode: "", ··· 621 622 } 622 623 623 624 private handleCreateClass() { 624 - this.showCreateModal = true; 625 + // Set empty form for creating new class 626 + this.approvingEntry = null; 627 + this.editingClass = { 628 + courseCode: "", 629 + courseName: "", 630 + professor: "", 631 + semester: "", 632 + year: new Date().getFullYear(), 633 + }; 634 + this.meetingTimes = []; 635 + this.showModal = true; 625 636 } 626 637 627 638 private getFilteredClasses() { ··· 673 684 : this.renderWaitlist() 674 685 } 675 686 676 - ${this.approvingEntry ? this.renderApprovalModal() : ""} 687 + ${this.showModal ? this.renderApprovalModal() : ""} 677 688 `; 678 689 } 679 690 ··· 816 827 } else { 817 828 this.meetingTimes = []; 818 829 } 830 + this.showModal = true; 819 831 } 820 832 821 833 private handleMeetingTimesChange(e: CustomEvent) { ··· 828 840 } 829 841 830 842 private cancelApproval() { 843 + this.showModal = false; 831 844 this.approvingEntry = null; 832 845 this.meetingTimes = []; 833 846 this.editingClass = { ··· 840 853 } 841 854 842 855 private async submitApproval() { 843 - if (!this.approvingEntry) return; 844 - 845 856 if (this.meetingTimes.length === 0) { 846 857 this.error = "Please add at least one meeting time"; 847 858 return; ··· 870 881 throw new Error(data.error || "Failed to create class"); 871 882 } 872 883 873 - await fetch(`/api/admin/waitlist/${this.approvingEntry.id}`, { 874 - method: "DELETE", 875 - }); 884 + // If approving from waitlist, delete the waitlist entry 885 + if (this.approvingEntry) { 886 + await fetch(`/api/admin/waitlist/${this.approvingEntry.id}`, { 887 + method: "DELETE", 888 + }); 889 + } 876 890 877 891 await this.loadData(); 878 892 879 893 this.activeTab = "classes"; 894 + this.showModal = false; 880 895 this.approvingEntry = null; 881 896 this.meetingTimes = []; 882 897 this.editingClass = { ··· 891 906 this.error = 892 907 error instanceof Error 893 908 ? error.message 894 - : "Failed to approve waitlist entry. Please try again."; 909 + : "Failed to create class. Please try again."; 895 910 } 896 911 } 897 912 898 913 private renderApprovalModal() { 899 - if (!this.approvingEntry) return ""; 914 + const isApproving = !!this.approvingEntry; 915 + const title = isApproving ? "Review & Create Class" : "Create New Class"; 916 + const description = isApproving 917 + ? "Review the class details and make any edits before creating" 918 + : "Enter the class details below"; 900 919 901 920 return html` 902 921 <div class="modal-overlay" @click=${this.cancelApproval}> 903 922 <div class="modal" @click=${(e: Event) => e.stopPropagation()}> 904 - <h2 class="modal-title">Review & Create Class</h2> 923 + <h2 class="modal-title">${title}</h2> 905 924 906 925 <p style="margin-bottom: 1.5rem; color: var(--paynes-gray);"> 907 - Review the class details and make any edits before creating 926 + ${description} 908 927 </p> 909 928 910 929 ${this.error ? html`<div class="error-message">${this.error}</div>` : ""}