@@ -59,6 +59,7 @@ const els = {
5959 adminAchievementsList : document . getElementById ( "adminAchievementsList" ) ,
6060 achievementStatus : document . getElementById ( "achievementStatus" ) ,
6161 notificationEditor : document . getElementById ( "notificationEditor" ) ,
62+ notificationTypeInput : document . getElementById ( "notificationTypeInput" ) ,
6263 publishNotificationBtn : document . getElementById ( "publishNotificationBtn" ) ,
6364 notificationHistoryList : document . getElementById ( "notificationHistoryList" ) ,
6465 notificationAdminStatus : document . getElementById ( "notificationAdminStatus" ) ,
@@ -659,9 +660,10 @@ function renderNotificationHistory() {
659660 const content = html || fallback ;
660661 const creator = escapeHtml ( String ( item . created_by_username || "admin" ) ) ;
661662 const createdAt = escapeHtml ( formatDateTime ( item . created_at ) ) ;
663+ const type = escapeHtml ( String ( item . notification_type || "general" ) ) ;
662664 return `
663665 <article class="admin-notification-item">
664- <div class="admin-notification-meta">${ createdAt } • by ${ creator } </div>
666+ <div class="admin-notification-meta">${ createdAt } • ${ type } • by ${ creator } </div>
665667 <p>${ content } </p>
666668 </article>
667669 ` ;
@@ -684,20 +686,28 @@ async function loadNotificationHistory() {
684686async function publishNotificationFromEditor ( ) {
685687 const html = String ( els . notificationEditor ?. innerHTML || "" ) . trim ( ) ;
686688 const text = extractNotificationTextFromHtml ( html ) ;
689+ const notificationType = String ( els . notificationTypeInput ?. value || "general" ) . trim ( ) . toLowerCase ( ) ;
687690 if ( ! text ) {
688691 setStatus ( els . notificationAdminStatus , "Notification text is required." , "error" ) ;
689692 return ;
690693 }
694+ if ( ! [ "security" , "general" , "updates" ] . includes ( notificationType ) ) {
695+ setStatus ( els . notificationAdminStatus , "Notification type is invalid." , "error" ) ;
696+ return ;
697+ }
691698
692699 if ( els . publishNotificationBtn ) {
693700 els . publishNotificationBtn . disabled = true ;
694701 }
695702 setStatus ( els . notificationAdminStatus , "Publishing notification..." ) ;
696703 try {
697- await api . admin . createNotification ( { messageHtml : html } ) ;
704+ await api . admin . createNotification ( { messageHtml : html , notificationType } ) ;
698705 if ( els . notificationEditor ) {
699706 els . notificationEditor . innerHTML = "" ;
700707 }
708+ if ( els . notificationTypeInput ) {
709+ els . notificationTypeInput . value = "general" ;
710+ }
701711 await loadNotificationHistory ( ) ;
702712 setStatus ( els . notificationAdminStatus , "Notification published." , "ok" ) ;
703713 } catch ( err ) {
0 commit comments