Added submission count to gym search results.

This commit is contained in:
Andrew Lalis 2023-02-16 18:15:46 +01:00
parent 654623ce4e
commit cb7761bca4
2 changed files with 10 additions and 2 deletions

View File

@ -9,6 +9,7 @@ export interface GymSearchResult {
streetAddress: string; streetAddress: string;
latitude: number; latitude: number;
longitude: number; longitude: number;
submissionCount: number;
} }
export interface UserSearchResult { export interface UserSearchResult {

View File

@ -6,7 +6,7 @@
<q-item-label caption lines="1">{{ gym.countryName }}</q-item-label> <q-item-label caption lines="1">{{ gym.countryName }}</q-item-label>
</q-item-section> </q-item-section>
<q-item-section side top> <q-item-section side top>
<q-badge color="primary" label="10k" /> <q-badge color="primary" :label="submissionCountLabel" />
</q-item-section> </q-item-section>
</q-item> </q-item>
</template> </template>
@ -14,11 +14,18 @@
<script setup lang="ts"> <script setup lang="ts">
import { getGymRoute } from 'src/router/gym-routing'; import { getGymRoute } from 'src/router/gym-routing';
import { GymSearchResult } from 'src/api/search/models'; import { GymSearchResult } from 'src/api/search/models';
import {computed} from 'vue';
interface Props { interface Props {
gym: GymSearchResult; gym: GymSearchResult;
} }
defineProps<Props>(); const props = defineProps<Props>();
const submissionCountLabel = computed(() => {
const c = props.gym.submissionCount;
if (c < 1000) return '' + c;
if (c < 1000000) return Math.floor(c / 1000) + 'k';
return Math.floor(c / 1000000) + 'm';
});
</script> </script>
<style scoped></style> <style scoped></style>