feat(i18n): implement new locale resolution logic and service layer

This commit is contained in:
poyrazavsever
2026-07-20 10:25:40 +03:00
parent 9365dfd215
commit 7805a9a19a
9 changed files with 384 additions and 118 deletions
+6 -18
View File
@@ -545,28 +545,16 @@ export function setClientPortalLocale(
.where(eq(clients.id, clientId))
.run();
if (ownedClient.authUserId) {
tx.insert(userPreferences)
.values({
ownerUserId: ownedClient.authUserId,
language: locale,
})
.onConflictDoUpdate({
target: userPreferences.ownerUserId,
set: {
language: locale,
updatedAt: new Date().toISOString(),
},
})
.run();
tx.delete(session).where(eq(session.userId, ownedClient.authUserId)).run();
}
tx.insert(authAuditEvents)
.values({
type: "client_locale_updated",
authUserId: actor.user.id,
metadata: { clientId, locale, targetAuthUserId: ownedClient.authUserId },
metadata: {
clientId,
locale,
targetAuthUserId: ownedClient.authUserId,
userPreferencePreserved: Boolean(ownedClient.authUserId),
},
})
.run();