UNPKG

@open-tender/cloud

Version:

A library of hooks, reducers, utility functions, and types for use with Open Tender applications that utilize our cloud-based Order API.

28 lines (27 loc) 1.13 kB
"use strict"; var _a; Object.defineProperty(exports, "__esModule", { value: true }); exports.notificationsReducer = exports.selectNotifications = exports.hideNotification = exports.showNotification = void 0; const toolkit_1 = require("@reduxjs/toolkit"); const types_1 = require("./types"); const utils_1 = require("@open-tender/utils"); const initialState = []; const notificationsSlice = (0, toolkit_1.createSlice)({ name: types_1.ReducerType.Notifications, initialState, reducers: { showNotification: (state, action) => { return [ ...state, { message: action.payload, id: (0, utils_1.makeRandomNumberString)() } ]; }, hideNotification: (state, action) => { return state.filter(i => i.id !== action.payload); } } }); _a = notificationsSlice.actions, exports.showNotification = _a.showNotification, exports.hideNotification = _a.hideNotification; const selectNotifications = (state) => state.notifications; exports.selectNotifications = selectNotifications; exports.notificationsReducer = notificationsSlice.reducer;