i18n(users): translate the terminated-sessions toast
Both toasts printed the endpoint's own message field verbatim, so a Russian UI
answered "Terminated 0 sessions". That string is assembled in Python and can
never be translated where it is built, so the endpoints now also return the raw
count and the phrase is composed on the client.
message is kept: it goes to the audit log and may have other consumers, and
adding a field breaks no one.
Russian needs three forms, and zero does not land in the obvious one — 0 is the
"many" category ("сессий", not "сессии") — hence four keys against English's
two.
Fixes both call sites: the per-user button in the table row and Terminate all
sessions on the Sessions tab, which shared the same untranslated string.
This commit is contained in:
@@ -173,11 +173,20 @@ export function useUnlockUser() {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* `message` is the backend's own English wording and is not shown to the user;
|
||||
* the toast is built from `count` so it can be translated and declined.
|
||||
*/
|
||||
export interface TerminateSessionsResult {
|
||||
message: string;
|
||||
count: number;
|
||||
}
|
||||
|
||||
export function useTerminateUserSessions() {
|
||||
const qc = useQueryClient();
|
||||
return useMutation({
|
||||
mutationFn: (userId: number) =>
|
||||
apiClient.post<{ message: string }>(`/admin/api/users/${userId}/terminate-sessions`),
|
||||
apiClient.post<TerminateSessionsResult>(`/admin/api/users/${userId}/terminate-sessions`),
|
||||
onSuccess: () => qc.invalidateQueries({ queryKey: userKeys.sessions }),
|
||||
});
|
||||
}
|
||||
@@ -337,7 +346,7 @@ export function useTerminateSession() {
|
||||
export function useTerminateAllSessions() {
|
||||
const qc = useQueryClient();
|
||||
return useMutation({
|
||||
mutationFn: () => apiClient.post<{ message: string }>('/admin/api/sessions/terminate-all'),
|
||||
mutationFn: () => apiClient.post<TerminateSessionsResult>('/admin/api/sessions/terminate-all'),
|
||||
onSuccess: () => qc.invalidateQueries({ queryKey: userKeys.sessions }),
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user