Skip to content
This repository has been archived by the owner on Apr 6, 2021. It is now read-only.

Commit

Permalink
Merge pull request #176 from s0lvang/feature/ongoing_missions
Browse files Browse the repository at this point in the history
Legg til en visning av antall pågående oppdrag
  • Loading branch information
kharann authored Mar 21, 2020
2 parents 1cb7ac1 + a8c2e88 commit aadf030
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
10 changes: 10 additions & 0 deletions src/services/firebase.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,3 +143,13 @@ export const getDelivered = async (callback = () => {}) => {

callback(resp.docs.length);
};

export const getOngoingCount = async (callback = () => {}) => {
const resp = await fb
.firestore()
.collectionGroup("requests")
.orderBy("connectedUser")
.startAfter(null)
.get();
callback(resp.docs.length);
};
13 changes: 11 additions & 2 deletions src/views/AllRequests.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@
>{{ delivered === null ? "Laster antall" : delivered }} fullførte
oppdrag{{ delivered === null ? "..." : "" }}</small
>
<small
>{{ ongoing === null ? "Laster antall" : ongoing }} pågående oppdrag{{
ongoing === null ? "..." : ""
}}</small
>
<section v-if="getRequests.length && this.mapEnabled">
<AllRequestsMap
:requests="getRequests"
Expand Down Expand Up @@ -42,7 +47,7 @@ import Request from "@/components/Request.vue";
import AllRequestsMap from "@/components/AllRequestsMap.vue";
import coordinateDistance from "@/helpers/coord";
import Icon from "@/components/shared/Icon.vue";
import { getDelivered } from "@/services/firebase";
import { getDelivered, getOngoingCount } from "@/services/firebase";
export default {
name: "AllRequests",
Expand All @@ -54,7 +59,8 @@ export default {
data() {
return {
mapEnabled: false,
delivered: null
delivered: null,
ongoing: null
};
},
computed: {
Expand Down Expand Up @@ -98,6 +104,9 @@ export default {
getDelivered(count => {
this.delivered = count;
});
getOngoingCount(count => {
this.ongoing = count;
});
}
};
</script>
Expand Down

0 comments on commit aadf030

Please sign in to comment.