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 #172 from s0lvang/feature/completed
Browse files Browse the repository at this point in the history
Ferdige oppdrag
  • Loading branch information
kharann authored Mar 20, 2020
2 parents 436d7a1 + e6060c1 commit 5ea8064
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/components/AllRequestsMap.vue
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export default {
}
#all-requests-map {
margin: 1em auto 2em;
margin: 0 auto 2em;
position: relative;
height: 65vh;
z-index: 199;
Expand Down
10 changes: 10 additions & 0 deletions src/services/firebase.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,3 +130,13 @@ export const deleteUser = (userId, callback = () => { }) => {

callback();
};

export const getDelivered = async (callback = () => { }) => {
const resp = await fb
.firestore()
.collectionGroup("requests")
.where("delivered", "==", true)
.get();

callback(resp.docs.length);
};
22 changes: 20 additions & 2 deletions src/views/AllRequests.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
{{ mapEnabled ? "Skjul" : "Vis" }} kart
</button>
</div>
<small
>{{ delivered === null ? "Laster antall" : delivered }} fullførte
oppdrag{{ delivered === null ? "..." : "" }}</small
>
<section v-if="getRequests.length && this.mapEnabled">
<AllRequestsMap
:requests="getRequests"
Expand Down Expand Up @@ -38,17 +42,19 @@ 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";
export default {
name: "MyRequests",
name: "AllRequests",
components: {
Request,
AllRequestsMap,
Icon
},
data() {
return {
mapEnabled: false
mapEnabled: false,
delivered: null
};
},
computed: {
Expand Down Expand Up @@ -87,6 +93,11 @@ export default {
)
);
}
},
mounted() {
getDelivered(count => {
this.delivered = count;
});
}
};
</script>
Expand All @@ -98,6 +109,13 @@ export default {
align-items: flex-start;
}
small {
margin-top: -0.7rem;
margin-bottom: 1rem;
display: block;
color: gray;
}
button.toggle-map {
--blue: #{$color-primary};
--light-blue: #{lighten($color-primary, 10%)};
Expand Down

0 comments on commit 5ea8064

Please sign in to comment.