Xeovalyte
6fb439a754
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
39 lines
918 B
JavaScript
39 lines
918 B
JavaScript
import { getDocs, collection, getFirestore } from 'firebase/firestore'
|
|
|
|
export const useUsersStore = defineStore('users', () => {
|
|
const ledenlijst = ref([])
|
|
const users = ref([])
|
|
|
|
const db = getFirestore()
|
|
|
|
const getLedenlijst = async () => {
|
|
if (ledenlijst[0]) return;
|
|
|
|
try {
|
|
const querySnapshot = await getDocs(collection(db, "ledenlijst"));
|
|
querySnapshot.forEach((doc) => {
|
|
ledenlijst.value.push(doc.data())
|
|
});
|
|
} catch (e) {
|
|
console.log(e)
|
|
}
|
|
|
|
ledenlijst.value.sort((a, b) => a.fullName.localeCompare(b.fullName))
|
|
}
|
|
|
|
const getUsers = async () => {
|
|
if (users[0]) return
|
|
|
|
try {
|
|
const querySnapshot = await getDocs(collection(db, "users"));
|
|
querySnapshot.forEach((doc) => {
|
|
users.value.push(doc.data())
|
|
});
|
|
} catch (e) {
|
|
console.log(e)
|
|
}
|
|
}
|
|
|
|
return { ledenlijst, users, getLedenlijst, getUsers }
|
|
});
|