Update tenant store on changing settings

This commit is contained in:
Karl Ludwig Weise
2025-10-15 13:35:30 +02:00
parent 74df843077
commit a56f6910e4
2 changed files with 9 additions and 1 deletions
+7 -1
View File
@@ -70,9 +70,15 @@ const createTenantsStore = () => {
const body = await res.json();
const tenants = body.tenants ?? ([] as TTenant[]);
const newCurrentTenantId = auth.getTenant();
store.update((state) => {
return { ...state, tenants, isLoading: false };
return {
...state,
tenants,
isLoading: false,
currentTenant: tenants.find((t: TTenant) => t.id === newCurrentTenantId) || null,
};
});
} catch (error) {
store.update((state) => {
@@ -15,6 +15,7 @@
import { superForm } from "sveltekit-superforms";
import { zodClient } from "sveltekit-superforms/adapters";
import { formSchema } from "./schema";
import { tenants } from "$lib/stores/tenants";
let { entity }: { entity: TTenantSettings } = $props();
@@ -55,6 +56,7 @@
validators: zodClient(formSchema),
onResult: async (event) => {
if (event.result.type === "success") {
tenants.reload();
toast.success(m["tenants.edit.success"]());
} else if (event.result.type === "failure") {
toast.error(m["tenants.edit.error"]());