Sha256: a7f5feedf8e3cdc49fc4afd7ed68a23216331bfc5c8c437c36f6dfda96670145

Contents?: true

Size: 643 Bytes

Versions: 5

Compression:

Stored size: 643 Bytes

Contents

import { create } from "zustand";

export 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

5 entries across 5 versions & 1 rubygems

Version Path
pages_core-3.14.0 app/javascript/stores/useToastStore.ts
pages_core-3.13.0 app/javascript/stores/useToastStore.ts
pages_core-3.12.7 app/javascript/stores/useToastStore.ts
pages_core-3.12.6 app/javascript/stores/useToastStore.ts
pages_core-3.12.5 app/javascript/stores/useToastStore.ts