@@ -21,19 +21,19 @@ defmodule AdminWeb.NotificationLive.Show do
2121
2222 < . list >
2323 <: item title = "Name " > { @ notification . name } </: item >
24- <: item title = "Target Audience " > { @ notification . audience } </: item >
24+ <: item title = "Target Audience " > { @ notification . audience } { length ( @ recipients ) } </: item >
2525 <: item title = "Default language " >
2626 < div class = "flex flex-col gap-2 " >
2727 { @ notification . default_language }
28-
28+ <%!--
2929 <label class="label text-sm">
3030 <input
3131 type="checkbox"
3232 phx-click="toggle_strict_languages"
3333 checked={if @notification.use_strict_languages, do: "checked", else: nil}
3434 class="checkbox checkbox-primary"
3535 /> Use only specified languages
36- </ label >
36+ </label> --%>
3737 </ div >
3838 </: item >
3939 </ . list >
@@ -100,6 +100,11 @@ defmodule AdminWeb.NotificationLive.Show do
100100 < div role = "alert " class = "alert alert-error alert-soft " >
101101 < . icon name = "hero-exclamation-circle " class = "size-6 " />
102102 < span > Missing the email template for the default language.</ span >
103+ < . button navigate = {
104+ ~p" /notifications/#{ @ notification } /messages/new?language=#{ @ notification . default_language } "
105+ } >
106+ Add locale
107+ </ . button >
103108 </ div >
104109 <% end %>
105110 </ Layouts . admin >
@@ -112,24 +117,44 @@ defmodule AdminWeb.NotificationLive.Show do
112117 Notifications . subscribe_notifications ( socket . assigns . current_scope , id )
113118 end
114119
120+ notification = Notifications . get_notification! ( socket . assigns . current_scope , id )
121+ included_langs = notification . localized_emails |> Enum . map ( & & 1 . language )
122+
123+ { :ok , recipients } =
124+ Notifications . get_target_audience (
125+ socket . assigns . current_scope ,
126+ notification . audience ,
127+ if ( notification . use_strict_languages , do: [ only_langs: included_langs ] , else: [ ] )
128+ )
129+
115130 { :ok ,
116131 socket
117132 |> assign ( :page_title , "Show Mail" )
118133 |> assign (
119134 :notification ,
120- Notifications . get_notification! ( socket . assigns . current_scope , id )
121- ) }
135+ notification
136+ )
137+ |> assign ( :recipients , recipients ) }
122138 end
123139
124140 @ impl true
125141 def handle_event ( "toggle_strict_languages" , _ , socket ) do
126- { :ok , _notification } =
142+ { :ok , notification } =
127143 Notifications . toggle_strict_languages (
128144 socket . assigns . current_scope ,
129145 socket . assigns . notification
130146 )
131147
132- { :noreply , socket }
148+ included_langs = notification . localized_emails |> Enum . map ( & & 1 . language )
149+
150+ { :ok , recipients } =
151+ Notifications . get_target_audience (
152+ socket . assigns . current_scope ,
153+ notification . audience ,
154+ if ( notification . use_strict_languages , do: [ only_langs: included_langs ] , else: [ ] )
155+ )
156+
157+ { :noreply , socket |> assign ( :recipients , recipients ) }
133158 end
134159
135160 def handle_event ( "delete" , % { "id" => id } = _params , socket ) do
0 commit comments