modif all

This commit is contained in:
ExostFlash 2025-08-29 10:33:03 +02:00
parent b04045ca8e
commit fbd10c6fd5
6 changed files with 87 additions and 45 deletions

Binary file not shown.

View file

@ -22,25 +22,4 @@ function initDb(dbPath = './database.sqlite') {
});
}
function initDb (dbPath = './database.sqlite') {
return new Promise((resolve, reject) => {
const db = new sqlite3.Database(dbPath, (err) => {
if (err) {
reject(err);
} else {
db.run(`
CREATE TABLE IF NOT EXISTS restaurants (
id INTEGER PRIMARY KEY,
nom TEXT NOT NULL,
description TEXT,
adresse TEXT NOT NULL,
menu TEXT
);
`);
}
db.close();
resolve();
});
});
};
module.exports = initDb;

View file

@ -1,13 +1,14 @@
const axios = require("axios");
const { getUserByDId } = require('../users/getUsers');
const { getUserByGId } = require('../users/getUsers');
const { postUser } = require('../users/postUsers');
const CLIEN_ID = "71229835507-9413gbpdamv2qbcb2ov8oda2oqgcsk8q.apps.googleusercontent.com";
const GOOGLE_SECRET = "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";
const REDIRECT_URI = "http://localhost:3000/auth/google/callback";
const GOOGLE_REDIRECT_URI = "http://localhost:3000/auth/google/callback";
exports.handleGoogleAuth = async (code, res) => {
exports.handleGoogleAuth = async (req, res) => {
const code = req.query.code;
if (!code) return res.status(400).json({ error: "Code de validation manquant" });
try {
const params = new URLSearchParams();

View file

@ -49,8 +49,8 @@ main {
}
.chart-placeholder {
width: 150px;
height: 150px;
width: 200px;
height: 200px;
background: #eee;
display: flex;
align-items: center;

View file

@ -22,6 +22,17 @@ router.get('/auth/discord', (req, res) => {
router.get('/auth/discord/callback', require('./modules/auth/discord').handleDiscordAuth);
// Auth Google
router.get('/auth/google', (req, res) => {
const clientId = '71229835507-9413gbpdamv2qbcb2ov8oda2oqgcsk8q.apps.googleusercontent.com';
const redirectUri = 'http://localhost:3000/auth/google/callback';
const scope = 'https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile';
const googleAuthUrl = `https://accounts.google.com/o/oauth2/auth?client_id=${clientId}&redirect_uri=${encodeURIComponent(redirectUri)}&response_type=code&scope=${encodeURIComponent(scope)}`;
res.redirect(googleAuthUrl);
});
router.get('/auth/google/callback', require('./modules/auth/google').handleGoogleAuth);
// Déconnexion
router.get('/logout', (req, res) => {
req.session.destroy((err) => {
@ -33,22 +44,4 @@ router.get('/logout', (req, res) => {
});
});
// Infos resto
router.get('/restaurants/:id', async (req, res) => {
const id = req.params.id;
try {
const restaurant = await db.get(`SELECT * FROM restaurants WHERE id = ?`, [id]);
if (!restaurant) {
res.status(404).send('Restaurant non trouvé');
} else {
res.render('restaurant', { restaurant });
}
} catch (err) {
console.error(err);
res.status(500).send('Erreur lors de la récupération des informations du restaurant');
}
});
module.exports = router;

View file

@ -21,7 +21,9 @@
</div>
</div>
<div class="chart">
<div class="chart-placeholder">Graph radar</div>
<div class="chart-placeholder">
<canvas id="radarChart"></canvas>
</div>
</div>
</div>
@ -95,3 +97,70 @@
</div>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<script>
document.addEventListener('DOMContentLoaded', function() {
const ctx = document.getElementById('radarChart').getContext('2d');
const radarChart = new Chart(ctx, {
type: 'radar',
data: {
labels: ['Qualité des plats', 'Ambiance', 'Accessibilité', 'Service', 'Tradition'],
datasets: [
{
label: 'Moyenne des notes',
data: [4.7, 4.6, 4.4, 4.3, 4.8],
fill: true,
backgroundColor: 'rgba(255,215, 0, 0.2)',
borderColor: 'rgb(255,215, 0, 1)',
pointBackgroundColor: 'rgb(255,215, 0)',
pointBorderColor: '#fff',
pointHoverBackgroundColor: '#fff',
pointHoverBorderColor: 'rgb(255,215, 0)',
pointStyle: 'circle',
pointRadius: 5,
pointRotation: 0,
},
]
},
options: {
plugins: {
legend: {
display: false
},
tooltip: {
callbacks: {
label: function(context) {
let label = context.dataset.label || '';
if (label) {
label += ': ';
}
label += context.formattedValue;
return label;
}
}
}
},
scales: {
r: {
max: 5,
min: 0,
ticks: {
stepSize: 1,
display: false,
callback: function(value, index, values) {
return value.toFixed(1);
}
}
}
},
elements: {
line: {
borderWidth: 3
}
}
}
});
});
</script>