Работают счётчики

This commit is contained in:
FEARmeR 2023-05-17 20:46:01 +01:00
parent 76cbd44b21
commit 107c7a85a9

View File

@ -2,6 +2,36 @@
import DefaultCounterCard from "../../../examples/cards/counterCards/DefaultCounterCard.vue"; import DefaultCounterCard from "../../../examples/cards/counterCards/DefaultCounterCard.vue";
</script> </script>
<script>
import axios from 'axios';
export default {
data() {
return {
projectsCount: 0, // This data property will hold the count of projects
usersCount: 0, // This data property will hold the count of users
};
},
async created() {
try {
// Fetch the projects data from the server
const projectsResponse = await axios.get('http://somebodyhire.me/api/projects/');
// Set the projectsCount to the number of projects received from the server
this.projectsCount = projectsResponse.data.length;
// Fetch the users data from the server
const usersResponse = await axios.get('http://somebodyhire.me/api/profiles/');
// Set the usersCount to the number of users received from the server
this.usersCount = usersResponse.data.length;
} catch (error) {
// Log any errors that occur during the fetch to the console
console.error(error);
}
},
};
</script>
<template> <template>
<section class="pt-3 pb-4" id="count-stats"> <section class="pt-3 pb-4" id="count-stats">
<div class="container"> <div class="container">
@ -11,11 +41,9 @@ import DefaultCounterCard from "../../../examples/cards/counterCards/DefaultCoun
<div class="col-md-4 position-relative"> <div class="col-md-4 position-relative">
<DefaultCounterCard <DefaultCounterCard
color="success" color="success"
title="Coded Elements" title="Проектов"
description="From buttons, to inputs, navbars, alerts or cards, you are description="Представлено на нашем сайте"
covered" :count="projectsCount"
:count="70"
suffix="+"
:duration="3000" :duration="3000"
divider="vertical" divider="vertical"
/> />
@ -23,11 +51,9 @@ import DefaultCounterCard from "../../../examples/cards/counterCards/DefaultCoun
<div class="col-md-4 position-relative"> <div class="col-md-4 position-relative">
<DefaultCounterCard <DefaultCounterCard
color="success" color="success"
title="Design Blocks" title="Пользователей"
description="Mix the sections, change the colors and unleash your description="Зарегистрированно с момента запуска проекта"
creativity" :count="usersCount"
:count="15"
suffix="+"
:duration="3000" :duration="3000"
divider="vertical" divider="vertical"
/> />
@ -35,10 +61,10 @@ import DefaultCounterCard from "../../../examples/cards/counterCards/DefaultCoun
<div class="col-md-4"> <div class="col-md-4">
<DefaultCounterCard <DefaultCounterCard
color="success" color="success"
title="Pages" title="Раз"
description="Save 3-4 weeks of work when you use our pre-made pages for description="Мы прокляли день, когда сели за баранку этого пылесоса"
your website" :count="9000"
:count="4" suffix="+"
:duration="3000" :duration="3000"
/> />
</div> </div>