assemble/ui/general/posts.store.js

26 lines
538 B
JavaScript
Raw Normal View History

2024-01-28 21:17:45 +03:00
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