Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Number of Visits Count #549

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions components/common/Footer.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,37 @@ import {
import { faFacebookSquare } from 'node_modules/@fortawesome/free-brands-svg-icons/index';
import { faTwitterSquare } from 'node_modules/@fortawesome/free-brands-svg-icons/index';
import { faLinkedin } from 'node_modules/@fortawesome/free-brands-svg-icons/index';
import React, { useState, useEffect } from 'react';

const Footer = () => {
const year = new Date().getFullYear();

const [visitCount, setVisitCount] = useState(0);

// Function to increment the visit count
const incrementVisitCount = () => {
setVisitCount(prevCount => prevCount + 1);
};

// Fetch the visit count from your backend API or any other source
// For demonstration purposes, we'll use a dummy API call here.
const fetchVisitCount = () => {
// Replace the below URL with your actual backend API endpoint
fetch('https://api.example.com/visitCount')
.then(response => response.json())
.then(data => {
setVisitCount(data.count);
})
.catch(error => {
console.error('Error fetching visit count:', error);
});
};

// Fetch the visit count on component mount
useEffect(() => {
fetchVisitCount();
}, []);

return (
<>
<footer id='footer'>
Expand Down Expand Up @@ -86,6 +114,10 @@ const Footer = () => {
/>
</a>
</div>

<p>Number of visits: {visitCount}</p>
<button onClick={incrementVisitCount}></button>

<p>&copy; {year} Amupedia.com. All rights reserved.</p>
</div>
</footer>
Expand Down
Loading