assemble/ui/general/posts.store.js

26 lines
538 B
JavaScript

import { createSlice } from '@reduxjs/toolkit'
import moment from 'moment';
export const postsSlice = createSlice({
name: 'counter',
initialState: {
posts: []
},
reducers: {
addPost: (state,{payload}) => {
let uuid = window.crypto.randomUUID();
state.posts.push({
id: uuid,
date: moment().toJSON(),
context: payload
})
}
}
})
// Action creators are generated for each case reducer function
export const {
addPost
} = postsSlice.actions
export default postsSlice.reducer