unistore wip
This commit is contained in:
1 parent
a43d4f32e4
commit
cf01670ee6
17 files changed
+253
-79
No files matched your search
+26
-6
@@ -1,9 +1,29 @@
|
||||
import createStore from 'unistore'
|
||||
import { route } from 'preact-router';
|
||||
import unistore from 'unistore'
|
||||
|
||||
export default function mcratesStore() {
|
||||
return createStore({
|
||||
bundles: [],
|
||||
offers: []
|
||||
});
|
||||
import http from './http';
|
||||
|
||||
export function createStore() {
|
||||
return unistore({
|
||||
bundles: [],
|
||||
offers: [],
|
||||
user: null,
|
||||
});
|
||||
}
|
||||
|
||||
export const actions = store => ({
|
||||
setUser: async function setUser(state, user, dest) {
|
||||
route(dest);
|
||||
return { user };
|
||||
},
|
||||
|
||||
setOffers: async function setOffers(state, offers) {
|
||||
return { offers };
|
||||
},
|
||||
|
||||
logout: async function logout(store, e) {
|
||||
await http.postLogout();
|
||||
route('/login');
|
||||
return { user: null };
|
||||
},
|
||||
});
|
||||
Reference in new issue
Block a user