Skip to content
Merged
Show file tree
Hide file tree
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
15 changes: 9 additions & 6 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
branches-ignore: [ main, develop ]

pull_request:
branches: [ develop ]
branches: [ main, develop ]


jobs:
Expand Down Expand Up @@ -132,7 +132,7 @@ jobs:

deploy-staging:
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/develop'
if: github.event_name == 'pull_request' && github.base_ref == 'develop'
steps:
- name: Deploy to Staging
uses: appleboy/ssh-action@v1.0.0
Expand All @@ -145,9 +145,11 @@ jobs:
git pull origin develop
docker-compose --env-file .env.staging -f docker-compose.staging.yml down
docker-compose --env-file .env.staging -f docker-compose.staging.yml up -d --build
docker compose -f docker-compose.staging.yml restart nginx

deploy-production:
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
steps:
- name: Deploy to Production
uses: appleboy/ssh-action@v1.0.0
Expand All @@ -161,6 +163,7 @@ jobs:
script: |
cd /var/www/EcoNum
git pull origin main
docker compose -f docker-compose.prod.yml down
docker compose -f docker-compose.prod.yml build
docker compose -f docker-compose.prod.yml up -d
docker compose -f docker-compose.prod.yml --env-file .env.prod down
docker compose -f docker-compose.prod.yml --env-file .env.prod build
docker compose -f docker-compose.prod.yml --env-file .env.prod up -d
docker compose -f docker-compose.prod.yml restart nginx
146 changes: 80 additions & 66 deletions frontend/app/calculator/page.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
"use client";

import { Metadata } from "next";

Check warning on line 3 in frontend/app/calculator/page.tsx

View workflow job for this annotation

GitHub Actions / ci-frontend

'Metadata' is defined but never used
import { useState, useEffect } from "react";
import { useRouter } from "next/navigation";

import {
Card,
CardBody,
Expand All @@ -10,11 +13,10 @@
Radio,
Spinner,
} from "@heroui/react";
import { useRouter } from "next/navigation";
import { getToken } from "@/lib/auth";

import { getToken } from "@/lib/auth";
import { calculateScore } from '@/lib/utils/scoreCalculator'

import Head from "next/head";

interface Reponse {
id: number;
Expand Down Expand Up @@ -145,75 +147,87 @@

if (result) {
return (
<div className="container mx-auto p-4 max-w-2xl">
<>
<Head>
<title>Questionnaire - ConsoNum</title>
<meta name="description" content="Évaluez votre empreinte numérique" />
</Head>
<div className="container mx-auto p-4 max-w-2xl">
<Card>
<CardHeader>
<h1 className="text-3xl font-bold text-center w-full">
Votre Résultat
</h1>
</CardHeader>
<CardBody className="text-center space-y-4">
<p className="text-6xl font-bold">{result.score}/30</p>
<p className="text-2xl font-semibold">{result.profil}</p>
<p className="text-lg text-default-600">{result.message}</p>
<div className="flex gap-4 justify-center mt-6">
<Button color="primary" onPress={() => router.push("/history")}>
Voir mon historique
</Button>
<Button variant="flat" onPress={() => window.location.reload()}>
Refaire le test
</Button>
</div>
</CardBody>
</Card>
</div>
</>
);
}

return (
<>
<Head>
<title>Questionnaire - ConsoNum</title>
<meta name="description" content="Évaluez votre empreinte numérique" />
</Head>
<div className="container mx-auto p-4 max-w-3xl">
<Card>
<CardHeader>
<h1 className="text-3xl font-bold text-center w-full">
Votre Résultat
<h1 className="text-2xl font-bold">
Calculateur d&apos;Empreinte Numérique
</h1>
</CardHeader>
<CardBody className="text-center space-y-4">
<p className="text-6xl font-bold">{result.score}/30</p>
<p className="text-2xl font-semibold">{result.profil}</p>
<p className="text-lg text-default-600">{result.message}</p>
<div className="flex gap-4 justify-center mt-6">
<Button color="primary" onPress={() => router.push("/history")}>
Voir mon historique
</Button>
<Button variant="flat" onPress={() => window.location.reload()}>
Refaire le test
</Button>
</div>
<CardBody className="space-y-6">
{questions.map((question) => (
<Card key={question.id} shadow="sm">
<CardBody>
<p className="font-semibold mb-2 text-small text-default-500">
{question.categorie}
</p>
<p className="font-medium mb-4">{question.texte}</p>
<RadioGroup
value={answers[question.id]?.toString()}
onValueChange={(val) =>
handleAnswerChange(question.id, parseInt(val))
}
>
{question.reponses.map((reponse) => (
<Radio key={reponse.id} value={reponse.valeur.toString()} data-testid={`reponse-${reponse.id}`}>
{reponse.texte}
</Radio>
))}
</RadioGroup>
</CardBody>
</Card>
))}

<Button
color="primary"
size="lg"
className="w-full"
onPress={handleSubmit}
isLoading={submitting}
isDisabled={Object.keys(answers).length < questions.length}
>
Calculer mon score
</Button>
</CardBody>
</Card>
</div>
);
}

return (
<div className="container mx-auto p-4 max-w-3xl">
<Card>
<CardHeader>
<h1 className="text-2xl font-bold">
Calculateur d&apos;Empreinte Numérique
</h1>
</CardHeader>
<CardBody className="space-y-6">
{questions.map((question) => (
<Card key={question.id} shadow="sm">
<CardBody>
<p className="font-semibold mb-2 text-small text-default-500">
{question.categorie}
</p>
<p className="font-medium mb-4">{question.texte}</p>
<RadioGroup
value={answers[question.id]?.toString()}
onValueChange={(val) =>
handleAnswerChange(question.id, parseInt(val))
}
>
{question.reponses.map((reponse) => (
<Radio key={reponse.id} value={reponse.valeur.toString()} data-testid={`reponse-${reponse.id}`}>
{reponse.texte}
</Radio>
))}
</RadioGroup>
</CardBody>
</Card>
))}

<Button
color="primary"
size="lg"
className="w-full"
onPress={handleSubmit}
isLoading={submitting}
isDisabled={Object.keys(answers).length < questions.length}
>
Calculer mon score
</Button>
</CardBody>
</Card>
</div>
</>
);
}
13 changes: 11 additions & 2 deletions frontend/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,17 @@ import CookieBanner from "@/components/ui/CookieBanner";
const inter = Inter({ subsets: ["latin"] });

export const metadata: Metadata = {
title: "ConsoNum",
description: "Calculateur d'empreinte numérique",
title: "ConsoNum - Mesurez votre empreinte numérique",
description: "Découvrez l'impact environnemental de vos habitudes digitales en 5 minutes. Conseils personnalisés pour un numérique plus responsable et écoresponsable.",
keywords: ["empreinte numérique", "sobriété numérique", "impact environnemental", "digital responsable"],
openGraph: {
title: "ConsoNum - Mesurez votre empreinte numérique",
description: "Découvrez l'impact de vos habitudes digitales",
url: "https://consonum.fr",
siteName: "ConsoNum",
images: ['/images/og-home.jpg'],
type: 'website',
},
};

export default function RootLayout({
Expand Down
29 changes: 29 additions & 0 deletions frontend/public/robots.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
User-agent: *

# Allowed public pages
Allow: /
Allow: /privacy-policy

# Private pages
Disallow: /dashboard
Disallow: /profile
Disallow: /history
Disallow: /login
Disallow: /register
Disallow: /verify

# API and backend
Disallow: /api/

# Payment
Disallow: /payment

# Calculator
Disallow: /calculator

# Tech files
Disallow: /_next/
Disallow: /static/

# Sitemap
Sitemap: https://consonum.fr/sitemap.xml
Loading