From 4d784b530a85145927a03bc07c47a5bdad4ee641 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Mon, 30 Dec 2024 13:27:58 +0100 Subject: [PATCH] Types notification --- .../src/components/grid/stores/index.ts | 4 ++-- .../src/components/grid/stores/notifications.ts | 13 +++++++++++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/packages/frontend-core/src/components/grid/stores/index.ts b/packages/frontend-core/src/components/grid/stores/index.ts index 753266f893..d55002186f 100644 --- a/packages/frontend-core/src/components/grid/stores/index.ts +++ b/packages/frontend-core/src/components/grid/stores/index.ts @@ -98,7 +98,6 @@ export type Store = BaseStore & sort: Writable subscribe: any dispatch: (event: string, data: any) => any - notifications: Writable width: Writable bounds: Readable height: Readable @@ -108,7 +107,8 @@ export type Store = BaseStore & Config.Store & Conditions.Store & Cache.Store & - Viewport.Store + Viewport.Store & + Notifications.Store export const attachStores = (context: Store): Store => { // Atomic store creation diff --git a/packages/frontend-core/src/components/grid/stores/notifications.ts b/packages/frontend-core/src/components/grid/stores/notifications.ts index 05c8039704..429760ed50 100644 --- a/packages/frontend-core/src/components/grid/stores/notifications.ts +++ b/packages/frontend-core/src/components/grid/stores/notifications.ts @@ -1,8 +1,17 @@ import { notifications as BBUINotifications } from "@budibase/bbui" -import { derived } from "svelte/store" +import { derived, Readable } from "svelte/store" import { Store as StoreContext } from "." -export const createStores = (context: StoreContext) => { +interface NotificationStore { + notifications: Readable<{ + success: (message: string) => void + error: (message: string) => void + }> +} + +export type Store = NotificationStore + +export const createStores = (context: StoreContext): NotificationStore => { const { notifySuccess, notifyError } = context // Normally we would not derive a store in "createStores" as it should be