mirror of
https://github.com/open-reception/appointment-booking-software.git
synced 2026-09-06 17:37:37 +02:00
Update tenant store on changing settings
This commit is contained in:
@@ -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) => {
|
||||
|
||||
+2
@@ -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"]());
|
||||
|
||||
Reference in New Issue
Block a user