@@ -6,7 +6,7 @@ import { Tag } from 'primereact/tag';
66import { Badge } from 'primereact/badge' ;
77import { __ } from '@wordpress/i18n' ;
88
9- const SendNotifications = ( { label, postId, status, targetGroupsCount, visibilityGroupsCount, isNotificationDryRun, isDirty, isAutoSaving } ) => {
9+ const SendNotifications = ( { label, postId, postType , status, targetGroupsCount, visibilityGroupsCount, isNotificationDryRun, isDirty, isAutoSaving } ) => {
1010 const [ visible , setVisible ] = useState ( false ) ;
1111 const toast = useRef ( null ) ;
1212 const [ nonce , setNonce ] = useState ( null ) ;
@@ -19,10 +19,14 @@ const SendNotifications = ({ label, postId, status, targetGroupsCount, visibilit
1919
2020 const showToast = ( status ) => {
2121 const messages = {
22- success : { severity : 'success' , summary : __ ( 'Success' , 'bcc-login' ) , detail : __ ( 'Notifications sent!' , 'bcc-login' ) } ,
22+ success : { severity : 'success' , summary : __ ( 'Success' , 'bcc-login' ) , detail : __ ( 'Notifications sent!' , 'bcc-login' ) , life : 5000 } ,
2323 error : { severity : 'error' , summary : __ ( 'Error' , 'bcc-login' ) , detail : __ ( 'Error sending notifications.' , 'bcc-login' ) , sticky : true } ,
24- info : { severity : 'info' , summary : __ ( 'Info' , 'bcc-login' ) , detail : __ ( 'Sending notifications ...' , 'bcc-login' ) } ,
24+ info : { severity : 'info' , summary : __ ( 'Info' , 'bcc-login' ) , detail : __ ( 'Sending notifications ...' , 'bcc-login' ) , sticky : true } ,
2525 } ;
26+
27+ // First remove the info toast if it's showing
28+ toast . current . remove ( messages . info ) ;
29+
2630 toast . current . show ( messages [ status ] ) ;
2731 } ;
2832
@@ -52,6 +56,13 @@ const SendNotifications = ({ label, postId, status, targetGroupsCount, visibilit
5256 throw new Error ( `Request failed (${ response . status } ): ${ text } ` ) ;
5357 }
5458
59+ window . dispatchEvent ( new CustomEvent ( 'bcc:notificationSent' , {
60+ detail : {
61+ date : new Date ( ) . toLocaleString ( ) ,
62+ no_of_groups : targetGroupsCount + visibilityGroupsCount
63+ }
64+ } ) ) ;
65+
5566 showToast ( 'success' ) ;
5667 } catch ( error ) {
5768 console . error ( 'Error sending notifications:' , error ) ;
@@ -121,7 +132,7 @@ const SendNotifications = ({ label, postId, status, targetGroupsCount, visibilit
121132 < div class = "bcc-send-notifications__translations" >
122133 < p > { __ ( 'Translations' , 'bcc-login' ) } : { translations === null
123134 ? < Tag icon = "dashicons dashicons-info" severity = "info" className = "italic" value = { __ ( 'Loading translations ...' , 'bcc-login' ) } />
124- : ( translations . length == 0 ? < Tag icon = "dashicons dashicons-warning " severity = "warning " value = { __ ( 'No translations available' , 'bcc-login' ) } /> : '' )
135+ : ( translations . length == 0 ? < Tag icon = "dashicons dashicons-info " severity = "info " value = { __ ( 'No translations available' , 'bcc-login' ) } /> : '' )
125136 } </ p >
126137
127138 { translations !== null && translations . length > 0 ? (
@@ -164,6 +175,8 @@ const SendNotifications = ({ label, postId, status, targetGroupsCount, visibilit
164175 ) : (
165176 < Tag icon = "dashicons dashicons-no" severity = "danger" value = { __ ( 'No groups' , 'bcc-login' ) } > </ Tag >
166177 ) }
178+
179+ < p className = 'bcc-send-notifications__info' > * { __ ( 'The email will be sent immediately when you click "Send"' , 'bcc-login' ) } </ p >
167180 </ div >
168181
169182 { isNotificationDryRun && (
0 commit comments