Skip to content
Snippets Groups Projects
Commit a243b898 authored by fibasile's avatar fibasile
Browse files

projects store

parent e0fa1b8a
No related branches found
No related tags found
No related merge requests found
import Vue from "vue";
import Vuex from "vuex";
Vue.use(Vuex);
// import example from './module-example'
import { vuexfireMutations } from "vuexfire";
Vue.use(Vuex);
import auth from "./auth";
import categories from "./categories";
import projects from "./projects";
......
......@@ -2,10 +2,27 @@
export function someAction (context) {
}
*/
import "firebase/app";
import firebase from "firebase/app";
import "firebase/auth";
import "firebase/database";
export function setProjectsRef({ commit }, ref) {}
export function setCategoryRef({ commit }, ref) {}
import { firebaseAction } from "vuexfire";
export const setProjectsRef = firebaseAction(
({ bindFirebaseRef, commit }, ref) => {
return bindFirebaseRef("projects", ref);
}
);
export const setCategoryRef = firebaseAction(
({ bindFirebaseRef, commit }, ref) => {
return bindFirebaseRef("category", ref);
}
);
export const setLatestProjectsRef = firebaseAction(
({ bindFirebaseRef, commit }, ref) => {
return bindFirebaseRef("latestProjects", ref);
}
);
export function loadAllProjects({ state, dispatch }) {
const db = firebase.database();
......@@ -32,3 +49,22 @@ export function loadCategory({ state, dispatch }, category_id) {
dispatch("setProjectsRef", projects_ref);
dispatch("setCategoryRef", cat_ref);
}
export const loadLatestProjects = firebaseAction(({ bindFirebaseRef }) => {
const db = firebase.database();
const ref = db
.ref("library/projects")
.orderByKey()
.limitToFirst(6);
return bindFirebaseRef("latestProjects", ref);
});
export const loadFeaturedProjects = firebaseAction(({ bindFirebaseRef }) => {
const db = firebase.database();
const ref = db
.ref("library/projects")
.orderByKey()
.limitToFirst(6);
return bindFirebaseRef("featuredProjects", ref);
// dispatch("setFeaturedProjectsRef", ref);
});
......@@ -2,3 +2,8 @@
export function someGetter (state) {
}
*/
export const featuredProjects = state => state.featuredProjects;
export const latestProjects = state => state.latestProjects;
export const projects = state => state.projects;
export const category = state => state.category;
export default {
//
limit: 50,
projects: []
projects: [],
category: null,
latestProjects: [],
featuredProjects: []
};
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment