Sha256: 7b1811dab88cfe3c69b6495bba8b0a3720f1b76d41ece8f8d6e7c3fd8707eeb8

Contents?: true

Size: 636 Bytes

Versions: 4

Compression:

Stored size: 636 Bytes

Contents

import { create } from "zustand";

interface Toast {
  type: string;
  message: string;
}

interface ToastState {
  toasts: Toast[];
  error: (msg: string) => void;
  notice: (msg: string) => void;
  next: () => void;
}

const useToastStore = create<ToastState>((set) => ({
  toasts: [],
  error: (msg: string) =>
    set((state) => ({
      toasts: [...state.toasts, { message: msg, type: "error" }]
    })),
  notice: (msg: string) =>
    set((state) => ({
      toasts: [...state.toasts, { message: msg, type: "notice" }]
    })),
  next: () => set((state) => ({ toasts: state.toasts.slice(1) }))
}));

export default useToastStore;

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
pages_core-3.15.4 app/javascript/stores/useToastStore.ts
pages_core-3.15.3 app/javascript/stores/useToastStore.ts
pages_core-3.15.2 app/javascript/stores/useToastStore.ts
pages_core-3.15.1 app/javascript/stores/useToastStore.ts