Author SHA1 Message Date
dandanalaa 24cca03a10 Added Jenkinsfile 2022-12-10 19:27:59 +00:00
dandanalaa 71871f21a6 Added Jenkinsfile 2022-12-10 19:27:03 +00:00
dandanalaa f843ee972c Added Jenkinsfile 2022-12-10 19:25:29 +00:00
dandanalaa b20c1327e2 Added Jenkinsfile 2022-12-10 19:17:37 +00:00
dandanalaa 69027e8436 Added Jenkinsfile 2022-12-10 19:12:30 +00:00
dandanalaa 7d490ac360 Added Jenkinsfile 2022-12-10 19:02:06 +00:00
dandanalaa 3270b44f1d Mise à jour de 'Jenkinsfile' 2022-12-10 19:00:13 +00:00
dandanalaa bc0df4bd35 Added Jenkinsfile 2022-12-10 18:53:56 +00:00
dandanalaa 38bb178f6d Added Jenkinsfile 2022-12-10 18:46:09 +00:00
dandanalaa 4a9afcc6a7 Added Jenkinsfile 2022-12-10 18:32:20 +00:00
dandanalaa f654da8a20 Added Jenkinsfile 2022-12-10 18:29:08 +00:00
dandanalaa 29f89e98d0 Added Jenkinsfile 2022-12-10 18:27:31 +00:00
dandanalaa 47662e3ada Added Jenkinsfile 2022-12-10 18:25:03 +00:00
dandanalaa 55494f6d99 build 2022-12-10 18:23:49 +00:00
dandanalaa c25ab4a0ab Added Jenkinsfile 2022-12-10 18:21:31 +00:00
dandanalaa 8d1c96939e reinit 2022-12-10 18:20:35 +00:00
dandanalaa a73c807689 Added Jenkinsfile 2022-12-10 18:19:28 +00:00
dandanalaa daa1589d82 Creation du build 2022-12-10 18:17:40 +00:00
dandanalaa 5440b0525b supp jenkis 2022-12-10 18:07:47 +00:00
cedric b71f368a85 change - nouveau jenkinsfile 2022-12-10 19:00:27 +01:00
cedric f9c05dce97 change - nouveau jenkinsfile 2022-12-10 18:58:05 +01:00
cedric 9173d0b44e change - nouveau jenkinsfile 2022-12-10 18:55:38 +01:00
cedric 57d1bac326 change - nouveau jenkinsfile 2022-12-10 18:54:38 +01:00
eric 1485bd0b52 ✏️ suppression test jenkins 2022-12-10 18:39:01 +01:00
eric 71cffa5499 💚 test pipeline 2022-12-10 18:36:02 +01:00
eric 4e50489d75 ✨ logo fb + .env modif 2022-12-10 18:28:02 +01:00
cedric 688f74d157 Merge branch 'develop' 2022-12-10 15:32:27 +01:00
cedric 1a5843ad73 add - liens reseaux sociaux dans le fotter 2022-12-10 15:31:52 +01:00
cedric 8871df3582 merge branch develop 2022-12-10 12:27:35 +01:00
dandanalaa 95a2de9c26 start2 2022-12-10 10:22:48 +00:00
dandanalaa 4158758606 start 2022-12-10 10:14:23 +00:00
eric 606e9be03d 💄 modification Jenkinsfile 2022-12-10 10:37:45 +01:00
dandanalaa e807356302 Added Jenkinsfile 2022-12-10 09:35:15 +00:00
eric f414bb32ea Merge branch 'develop' of https://git.dsp-archiwebo21-ad-ec-cb-mt.fr/cedric/The_Tip_Top into develop 2022-12-10 10:29:08 +01:00
eric 32ebd59467 🚀 test pour production 2022-12-10 10:26:56 +01:00
eric b19d1c2efe suppression fichier d'exemple 2022-12-10 09:30:07 +01:00
cedric 13c7f85110 add - test with playwright 2022-12-08 20:23:57 +01:00
eric e066b631e1 Merge branch 'feature/administration-buttuon' into develop 2022-12-08 13:19:44 +01:00
eric 0a50ebe952 🚧 boutton admin retrait 2022-12-08 12:52:03 +01:00
cedric 641df2cf51 add - background svg mais trop lourd 2022-12-08 12:36:28 +01:00
cedric 85ade3016b add - new oauth ids 2022-12-08 12:28:14 +01:00
cedric 108193f202 add - changement mail envoyé lors de la connexion rapide 2022-12-07 18:48:24 +01:00
cedric 4e404bcb9d Merge branch 'feature/page-admin' 2022-12-07 17:27:29 +01:00
cedric cf18d19aa6 fit - recuperaiton tout-savoir 2022-12-07 17:27:03 +01:00
cedric 3de3355a13 Merge branch 'master' of https://git.dsp-archiwebo21-ad-ec-cb-mt.fr/cedric/The_Tip_Top 2022-12-07 17:19:37 +01:00
eric 39e2ed4fce Merge branch 'master' of https://git.dsp-archiwebo21-ad-ec-cb-mt.fr/cedric/The_Tip_Top into feature/page-admin 2022-12-07 17:14:17 +01:00
eric ed9c87903e ✅ add - nouvelles imges 2022-12-07 15:53:52 +01:00
eric 27187c6c68 add - loading spinner, administration, navbar modfications 2022-12-07 15:11:50 +01:00
cedric 251454c403 fix - erreur description 2022-12-07 13:53:24 +01:00
eric 6a10740307 ✅ add - ajout page mon compte 2022-12-04 11:51:02 +01:00
eric a73958e500 Merge branch 'develop' into feature/mon-compte 2022-12-03 16:24:04 +01:00
cedric a63e6de1f0 changements liens 2022-12-03 16:22:04 +01:00
eric 67a84d9819 fix - filedsnom et prenom 2022-12-03 16:06:16 +01:00
cedric 4e97b2b6db add - images to products 2022-12-03 16:01:47 +01:00
eric 426d4a5fc1 ✅ add : gitignore migration 2022-12-03 15:32:40 +01:00
cedric 3d8f792d7e fix - noms produits 2022-12-03 15:19:37 +01:00
cedric cce6fa777d Merge branch 'feature/cedric' of https://devops.dsp-archiwebo21-ad-ec-cb-mt.fr:8080/cedric/The_Tip_Top into develop 2022-12-03 15:06:22 +01:00
cedric e3ede7484e ajout modif du github 2022-12-03 14:52:45 +01:00
eric 0b9bbe44d6 add - page mon compte 2022-12-03 14:09:04 +01:00
eric f59662740f ✅ add - page mon compte 2022-12-03 14:08:49 +01:00
eric 9d41546603 💄 ajout de redirection sur la page mon compte 2022-12-02 04:12:00 +01:00
eric cb95d93831 🐛 correction bug affichage déconnexion 2022-12-02 04:11:16 +01:00
eric 65efdcac94 ✅ ajout de page mon compte - en cours 2022-12-02 03:27:55 +01:00
cedric 5927d8e937 first commit 2022-11-28 23:06:53 +01:00
eric 7827aa119f add : page tout savoir récupération des produits 2022-11-28 19:30:12 +01:00
eric 99ac2e0b79 Merge branch 'feature/cedric' of https://github.com/Eric-ciccotti/rest-nextjs-api-routes-auth into feature/eric 2022-11-28 18:36:28 +01:00
eric fec63499c6 ✅add : correction ajout de gain et api test code 2022-11-28 18:26:24 +01:00
cedric ed18731eb4 add - page tout savoir 2022-11-28 18:16:41 +01:00
C ef7fbf4636 add - 404 2022-11-16 16:41:03 +01:00
C 1e8b08fa11 fix - lg to md 2022-11-16 15:11:51 +01:00
C 8224592c0e fix - style des pages, notamment index 2022-11-16 14:42:56 +01:00
C 04423aa6c7 fix - fixer le background sur le body 2022-11-15 15:06:42 +01:00
C 7a73849f99 Merge branch 'master' of https://github.com/Eric-ciccotti/rest-nextjs-api-routes-auth into feature/cedric 2022-11-15 14:50:47 +01:00
C b4cb8dbe8b add - page CGU 2022-11-15 14:47:04 +01:00
eric 769d441270 add - nettoayge & refacto du layout 2022-11-15 14:44:51 +01:00
C 7d7d583ad9 Merge branch 'master' of https://github.com/Eric-ciccotti/rest-nextjs-api-routes-auth into feature/cedric 2022-11-15 14:05:57 +01:00
eric 811c6d362b 📝 add - next config 2022-11-15 14:05:41 +01:00
C d480a3f8b2 Merge branch 'master' of https://github.com/Eric-ciccotti/rest-nextjs-api-routes-auth into feature/cedric 2022-11-15 13:55:02 +01:00
C 585781a9c7 add - page mentions légales 2022-11-15 13:54:52 +01:00
eric e6a7428158 Merge branch 'feature/cedric' of https://github.com/Eric-ciccotti/rest-nextjs-api-routes-auth 2022-11-15 12:30:11 +01:00
eric f1d1aa30d7 ✨ add - nouvelles pages et modification du css 2022-11-15 12:29:52 +01:00
eric 50d64b513b ✨ add - new pages et corrections 2022-11-15 12:23:30 +01:00
C 1a917e2347 add - meta sur page accueil, changements images png en webp 2022-11-15 11:32:44 +01:00
eric 374d35b449 Merge branch 'master' of https://github.com/Eric-ciccotti/rest-nextjs-api-routes-auth 2022-11-14 16:37:13 +01:00
eric c84194b7b9 add : connexion et deconnection en cours 2022-11-14 16:32:00 +01:00
C e5f3ae3e82 fix - probleme ports, changement readme 2022-11-14 15:46:28 +01:00
eric cb847b8ed9 ✨ 2022-11-14 00:00:43 +01:00
eric 8f9ff8fc74 🔧 en cours - affichage des messages d'erreurs 2022-11-14 00:00:14 +01:00
eric 77db425b0e 💄 add - amélioration de la page principale et du component Content 2022-11-13 17:13:53 +01:00
eric 9e959f5ac6 🚸 add - grosse refonte du site 2022-11-13 13:28:19 +01:00
eric dfa67f86d5 📝 modification rapide du readme 2022-11-12 20:43:06 +01:00
eric e85117b2c7 ⚡️ add - api generationGain , api superadmin , readme , fichier de seed 2022-11-12 20:23:15 +01:00
eric 141d9e53e8 ✅ add -bootstrap 2022-11-10 16:42:20 +01:00
eric fd4dc77603 ✅ add - bootstrap 2022-11-10 16:41:52 +01:00
eric 38159b90c1 ⚡️ ⚡️ add - ajout d'une page mon compte connecter a la bdd + API + routes 2022-11-10 15:40:00 +01:00
eric ae437a097b 🎨 project base 2022-11-09 22:56:02 +01:00
eric 6857e301fa first commit 2022-11-09 21:28:20 +01:00
58 changed files with 50528 additions and 734 deletions

No files matched your search

+8 -8
View File
@@ -6,19 +6,19 @@ GITHUB_ID=YOUR_GITHUB_CLIENT_ID
GITHUB_SECRET=YOUR_GITHUB_CLIENT_SECRET
# Google Auth Provider
GOOGLE_CLIENT_ID=5572607706-p6dftn0ss3m2qnvqbhk4khqte8lk7kt3.apps.googleusercontent.com
GOOGLE_CLIENT_SECRET=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
GOOGLE_CLIENT_ID=965228443747-049kq59pm43bd23aplfu9ja2333dpo5s.apps.googleusercontent.com
GOOGLE_CLIENT_SECRET=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
DATABASE_URL="postgres://postgres:postgrespwd@localhost:5432/thetiptop"
# Email (magic link)
EMAIL_SERVER_USER=2bfdbee5372880
EMAIL_SERVER_PASSWORD=af828174d7f2ad
EMAIL_SERVER_HOST=smtp.mailtrap.io
EMAIL_SERVER_PORT=2525
EMAIL_FROM=thetiptop@test.com
EMAIL_SERVER_USER=contact@dsp-archiwebo21-ad-ec-cb-mt.fr
EMAIL_SERVER_PASSWORD=Acem@2022a
EMAIL_SERVER_HOST=mail50.lwspanel.com
EMAIL_SERVER_PORT=587
EMAIL_FROM=contact@dsp-archiwebo21-ad-ec-cb-mt.fr
DATABASE_URL="postgres://postgres:postgrespwd@127.0.0.1:5454/thetiptop"
# DATABASE_URL="postgres://postgres:postgrespwd@127.0.0.1:5454/thetiptop"
API_KEY=1234
+5
View File
@@ -1,2 +1,7 @@
{
"workbench.colorCustomizations": {
"activityBar.background": "#4C1F25",
"titleBar.activeBackground": "#6A2C34",
"titleBar.activeForeground": "#FEFCFC"
}
}
+12
View File
@@ -0,0 +1,12 @@
FROM node:alpine
#copy source
COPY . /app
# Install deps
RUN cd /app && npm install
# Build
RUN npm run build
ENTRYPOINT [ "npm", "run", "start" ]
Vendored
+49
View File
@@ -0,0 +1,49 @@
pipeline {
agent any
stages {
stage('Env reinit') {
steps {
sh '''echo "
NEXTAUTH_URL=\'https://devops.dsp-archiwebo21-ad-ec-cb-mt.fr\'
DATABASE_URL="postgres://postgres:dandanalaa@212.227.206.140:5454/thetiptop"
GITHUB_ID=YOUR_GITHUB_CLIENT_ID
GITHUB_SECRET=YOUR_GITHUB_CLIENT_SECRET
GOOGLE_CLIENT_ID=965228443747-049kq59pm43bd23aplfu9ja2333dpo5s.apps.googleusercontent.com
GOOGLE_CLIENT_SECRET=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
EMAIL_SERVER_USER=contact@dsp-archiwebo21-ad-ec-cb-mt.fr
EMAIL_SERVER_PASSWORD=Acem@2022a
EMAIL_SERVER_HOST=mail50.lwspanel.com
EMAIL_SERVER_PORT=587
EMAIL_FROM=contact@dsp-archiwebo21-ad-ec-cb-mt.fr
SECRET=thetiptop123
API_KEY=1234
" > ./.env
cat ./.env'''
}
}
stage('build') {
steps {
sh 'ls -l'
}
}
stage('build2') {
steps {
sh '''npm install
npm run build
npm start & sleep 1'''
}
}
}
tools {
nodejs 'Node 16.18'
}
}
+3
View File
@@ -32,6 +32,9 @@ pour upgrade votre compte en superadmin (vous devez être connecté)
http://localhost:3000/api/gain
pour générer un gain (vous devez être connecté en tant que superadmin ou admin)
**npm run test**
tests faits avec Playwright
***********************************
+10 -8
View File
@@ -23,11 +23,9 @@ const Footer = () => {
</Link>
</div>
<div className="col-sm-6 col-md-3">
<ul className="nav flex-column justify-content-md-around align-content-center">
<li className="nav-item px-2">
<p>18 rue Léon Frot, 75 011 Paris</p>
</li>
<li className="nav-item px-2">
<p>01.65.38.94.23</p>
@@ -41,32 +39,36 @@ const Footer = () => {
<ul className="nav flex-md-column">
<li className="nav-item py-2 px-2">
<Link href="https://www.instagram.com/the_tip_top_acem/?hl=fr" legacyBehavior><a className={style.link} >
<Image src={logoInstagram} alt="lien instagram" width="40"
height="40" />
</a></Link>
</li>
<li className="nav-item py-2 px-2">
<Image src={logoLinkedin} alt="lien linkedin" width="40"
<Link href="https://www.facebook.com/profile.php?id=100088390638593" legacyBehavior><a className={style.link} >
<Image src={logoLinkedin} alt="lien facebook" width="40"
height="40" />
</a></Link>
</li>
</ul>
</div>
<div className="col-sm-6 col-md-3">
<ul className="nav flex-column justify-content-md-around justify-content-sm-center mx-5">
<ul className="nav flex-column justify-content-md-around justify-content-sm-center mx-3">
<li className="nav-item">
<Link href="/cgu" legacyBehavior >
<a className='px-2'>CGU</a>
<a className=''>CGU</a>
</Link>
</li>
<li className="nav-item">
<Link href="/mentions-legales" legacyBehavior >
<a className='px-2'>Mentions légales</a>
<a className=''>Mentions légales</a>
</Link>
</li>
</ul>
</div>
</div>
<p className="text-center">Thé Tip Top © 2022 - projet fictif pour lequel aucun réel
achat ou aucune réservation ne pourrait être effectué.</p>
<p className="text-center mx-3">Thé Tip Top © 2022 - projet fictif pour lequel aucun réel
achat ou aucune réservation ne pourrait être effectué.</p>
</div>
</div>
</footer>
+15
View File
@@ -0,0 +1,15 @@
import styles from '../styles/Loader.module.css'
import { MoonLoader } from 'react-spinners'
const Loader = () => {
return (
<div className={styles.wrapper}>
<MoonLoader
color="#eeeeee"
size={80}
/>
</div>
);
}
export default Loader;
+24 -28
View File
@@ -1,4 +1,4 @@
import React, { useRef } from "react";
import React, { useEffect, useRef, useState } from "react";
import logo from '../public/images/thetiptop_logo.webp';
import Link from "next/link";
import { useRouter } from "next/router";
@@ -7,12 +7,13 @@ import style from '../styles/NavBar.module.css';
import Image from 'next/image';
import { FiArrowRight } from 'react-icons/fi';
import { MdAdminPanelSettings } from 'react-icons/md';
import { BiExit } from 'react-icons/bi'
const NavBar = () => {
const navRef = useRef<HTMLInputElement>();
const router = useRouter();
const { data: session, status } = useSession();
console.log('role', session)
const [isAdmin, setIsAdmin] = useState<boolean>(false)
const { data: session } = useSession();
const closeNav = () => {
navRef.current.style.height = "0%";
@@ -26,9 +27,17 @@ const NavBar = () => {
signOut()
}
const checkRole = () => {
const isAdmin = ['SELLER', 'ADMIN', 'SUPERADMIN'].includes(session?.user['role']);
return isAdmin ? setIsAdmin(true) : setIsAdmin(false);
}
useEffect(() => {
checkRole();
}, [session?.user['role']])
let visitor = (
<nav className={`${style['navbar']}`}>
<div className="d-flex justify-content-center">
<Image
src={logo}
@@ -37,52 +46,39 @@ const NavBar = () => {
height={100}
/>
</div>
<div className={`justify-content-center text-center ${style['hidden-mobile']}`}>
<Link href="/" legacyBehavior><a className={style.link} >Accueil </a></Link><p>|</p>
<Link href="/" legacyBehavior><a className={style.link} >Accueil</a></Link><p>|</p>
<Link href="/tout-savoir" legacyBehavior><a className={style.link} >Tout savoir</a></Link><p>|</p>
<Link href="/contact" legacyBehavior><a className={style.link} >Contactez-nous</a></Link><p>|</p>
{!session && <><Link href="/connexion" legacyBehavior><a className={style.link} >Connexion</a></Link></>}
{session && <><Link href="/mon-compte" legacyBehavior><a className={style.link} >Mon compte</a></Link><p>|</p></>}
{session && <><Link href="#" legacyBehavior><a onClick={() => logout()} className={style.link} >Se déconnecter</a></Link></>}
{isAdmin && <><Link href="/admin" legacyBehavior><a className={style.link} >Administration <MdAdminPanelSettings /></a></Link><p>|</p></>}
{session && <><Link href="#" legacyBehavior><a onClick={() => logout()} className={style.link} >Se déconnecter <BiExit /></a></Link></>}
{session && <span className={`${style.connexion} badge rounded-pill bg-light text-dark`}>Vous-êtes connecté <FiArrowRight /> {session.user.email}</span>}
</div>
<div className={`justify-content-center text-center ${style['show-mobile']}`}>
<span className={`${style.burgerButton}`} onClick={openNav}>&#9776;</span>
</div>
<div className="d-flex justify-content-center">
</div>
<div ref={navRef} className={style.overlay} onClick={closeNav}>
<a className={style.closebtn} onClick={closeNav}>&times;</a>
<div className="overlay-content">
<Link href="/contact" legacyBehavior><a className={style.link} >Accueil</a></Link> |
<div className={style['overlay-content']}>
<Link href="/" legacyBehavior><a className={style.link} >Accueil</a></Link> |
<Link href="/tout-savoir" legacyBehavior><a className={style.link} >Tout savoir</a></Link> |
<Link href="/contact" legacyBehavior><a className={style.link} >Contactez-nous</a></Link> |
{!session && <Link href="/connexion" legacyBehavior><a className={style.link} >Connexion</a></Link>} |
{session && <Link href="/mon-compte" legacyBehavior><a className={style.link} >Mon compte</a></Link>} |
{session && <Link href="#" legacyBehavior><a onClick={() => logout()} className={style.link} >Se déconnecter</a></Link>}
<Link href="/" legacyBehavior><a className={style.link} >Contactez-nous</a></Link> |
<Link href="/connexion" legacyBehavior><a className={style.link} >Connexion</a></Link>
{session && <span className={`${style.connexion} badge rounded-pill bg-light text-dark`}><FiArrowRight />{session.user.email}</span>}
{/* {session && <span className={`${style.connexion} badge rounded-pill bg-light text-dark`}><FiArrowRight />{session.user.email}</span>} */}
</div>
</div>
</nav>
)
return (<>
{visitor}
</>)
};
export default NavBar;
+37
View File
@@ -0,0 +1,37 @@
import { createContext, ReactNode, useContext, useState } from "react";
export type IGlobalContextProps = {
role: string;
setRole: (role: string) => void;
};
export const globalContextDefaultValues: IGlobalContextProps = {
role: null,
setRole: () => { },
}
export const GlobalContext = createContext<IGlobalContextProps>(globalContextDefaultValues);
type Props = {
children: ReactNode;
};
export const GlobalContextProvider = (props: Props) => {
const [role, setCurrentRole] = useState(null)
return (
<GlobalContext.Provider
value={{
role: role,
setRole: setCurrentRole,
}}
>
{props.children}
</GlobalContext.Provider>
);
};
// import { useGlobalContext } from 'context';
// const { user } = useGlobalContext();
// Pour utiliser le context n'importe ou
+5
View File
@@ -0,0 +1,5 @@
import { useContext } from 'react';
import { GlobalContext } from './globalContext';
export const useGlobalContext = () => useContext(GlobalContext);
+1
View File
@@ -1,5 +1,6 @@
export enum Role {
USER = 'USER',
ADMIN = 'ADMIN',
SELLER = 'SELLER',
SUPERADMIN = 'SUPERADMIN'
}
+89
View File
@@ -16,6 +16,8 @@
"bootstrap": "^5.2.2",
"chance": "^1.1.9",
"crypto-random-string": "^3.0.0",
"date-format": "^4.0.14",
"dateformat": "^5.0.3",
"js-confetti": "^0.11.0",
"next": "13.0.2",
"next-auth": "4.16.4",
@@ -25,11 +27,13 @@
"react-hook-form": "^7.39.2",
"react-icons": "^4.6.0",
"react-markdown": "8.0.3",
"react-spinners": "^0.13.7",
"react-toastify": "^9.1.1",
"yup": "^0.32.11",
"yup-phone": "^1.3.2"
},
"devDependencies": {
"@playwright/test": "^1.28.1",
"@types/chance": "^1.1.3",
"@types/next-auth": "3.13.0",
"@types/node": "18.11.9",
@@ -321,6 +325,22 @@
"url": "https://github.com/sponsors/panva"
}
},
"node_modules/@playwright/test": {
"version": "1.28.1",
"resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.28.1.tgz",
"integrity": "sha512-xN6spdqrNlwSn9KabIhqfZR7IWjPpFK1835tFNgjrlysaSezuX8PYUwaz38V/yI8TJLG9PkAMEXoHRXYXlpTPQ==",
"dev": true,
"dependencies": {
"@types/node": "*",
"playwright-core": "1.28.1"
},
"bin": {
"playwright": "cli.js"
},
"engines": {
"node": ">=14"
}
},
"node_modules/@popperjs/core": {
"version": "2.11.6",
"resolved": "https://registry.npmjs.org/@popperjs/core/-/core-2.11.6.tgz",
@@ -899,6 +919,22 @@
"resolved": "https://registry.npmjs.org/csstype/-/csstype-3.1.1.tgz",
"integrity": "sha512-DJR/VvkAvSZW9bTouZue2sSxDwdTN92uHjqeKVm+0dAqdfNykRzQ95tay8aXMBAAPpUiq4Qcug2L7neoRh2Egw=="
},
"node_modules/date-format": {
"version": "4.0.14",
"resolved": "https://registry.npmjs.org/date-format/-/date-format-4.0.14.tgz",
"integrity": "sha512-39BOQLs9ZjKh0/patS9nrT8wc3ioX3/eA/zgbKNopnF2wCqJEoxywwwElATYvRsXdnOxA/OQeQoFZ3rFjVajhg==",
"engines": {
"node": ">=4.0"
}
},
"node_modules/dateformat": {
"version": "5.0.3",
"resolved": "https://registry.npmjs.org/dateformat/-/dateformat-5.0.3.tgz",
"integrity": "sha512-Kvr6HmPXUMerlLcLF+Pwq3K7apHpYmGDVqrxcDasBg86UcKeTSNWbEzU8bwdXnxnR44FtMhJAxI4Bov6Y/KUfA==",
"engines": {
"node": ">=12.20"
}
},
"node_modules/debug": {
"version": "4.3.4",
"resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz",
@@ -2599,6 +2635,18 @@
"node": ">=4"
}
},
"node_modules/playwright-core": {
"version": "1.28.1",
"resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.28.1.tgz",
"integrity": "sha512-3PixLnGPno0E8rSBJjtwqTwJe3Yw72QwBBBxNoukIj3lEeBNXwbNiKrNuB1oyQgTBw5QHUhNO3SteEtHaMK6ag==",
"dev": true,
"bin": {
"playwright": "cli.js"
},
"engines": {
"node": ">=14"
}
},
"node_modules/postcss": {
"version": "8.4.14",
"resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.14.tgz",
@@ -2774,6 +2822,15 @@
"react": ">=16"
}
},
"node_modules/react-spinners": {
"version": "0.13.7",
"resolved": "https://registry.npmjs.org/react-spinners/-/react-spinners-0.13.7.tgz",
"integrity": "sha512-mRamn56bfxWbGcacif5RT3UbeJaXi2AttjtPwSmomuv2IcxjpbfETCzdTvaQpNDk0E33ENJsStsQeKAZFuJcpA==",
"peerDependencies": {
"react": "^16.0.0 || ^17.0.0 || ^18.0.0",
"react-dom": "^16.0.0 || ^17.0.0 || ^18.0.0"
}
},
"node_modules/react-toastify": {
"version": "9.1.1",
"resolved": "https://registry.npmjs.org/react-toastify/-/react-toastify-9.1.1.tgz",
@@ -3898,6 +3955,16 @@
"resolved": "https://registry.npmjs.org/@panva/hkdf/-/hkdf-1.0.2.tgz",
"integrity": "sha512-MSAs9t3Go7GUkMhpKC44T58DJ5KGk2vBo+h1cqQeqlMfdGkxaVB78ZWpv9gYi/g2fa4sopag9gJsNvS8XGgWJA=="
},
"@playwright/test": {
"version": "1.28.1",
"resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.28.1.tgz",
"integrity": "sha512-xN6spdqrNlwSn9KabIhqfZR7IWjPpFK1835tFNgjrlysaSezuX8PYUwaz38V/yI8TJLG9PkAMEXoHRXYXlpTPQ==",
"dev": true,
"requires": {
"@types/node": "*",
"playwright-core": "1.28.1"
}
},
"@popperjs/core": {
"version": "2.11.6",
"resolved": "https://registry.npmjs.org/@popperjs/core/-/core-2.11.6.tgz",
@@ -4329,6 +4396,16 @@
"resolved": "https://registry.npmjs.org/csstype/-/csstype-3.1.1.tgz",
"integrity": "sha512-DJR/VvkAvSZW9bTouZue2sSxDwdTN92uHjqeKVm+0dAqdfNykRzQ95tay8aXMBAAPpUiq4Qcug2L7neoRh2Egw=="
},
"date-format": {
"version": "4.0.14",
"resolved": "https://registry.npmjs.org/date-format/-/date-format-4.0.14.tgz",
"integrity": "sha512-39BOQLs9ZjKh0/patS9nrT8wc3ioX3/eA/zgbKNopnF2wCqJEoxywwwElATYvRsXdnOxA/OQeQoFZ3rFjVajhg=="
},
"dateformat": {
"version": "5.0.3",
"resolved": "https://registry.npmjs.org/dateformat/-/dateformat-5.0.3.tgz",
"integrity": "sha512-Kvr6HmPXUMerlLcLF+Pwq3K7apHpYmGDVqrxcDasBg86UcKeTSNWbEzU8bwdXnxnR44FtMhJAxI4Bov6Y/KUfA=="
},
"debug": {
"version": "4.3.4",
"resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz",
@@ -5431,6 +5508,12 @@
"resolved": "https://registry.npmjs.org/pify/-/pify-3.0.0.tgz",
"integrity": "sha512-C3FsVNH1udSEX48gGX1xfvwTWfsYWj5U+8/uK15BGzIGrKoUpghX8hWZwa/OFnakBiiVNmBvemTJR5mcy7iPcg=="
},
"playwright-core": {
"version": "1.28.1",
"resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.28.1.tgz",
"integrity": "sha512-3PixLnGPno0E8rSBJjtwqTwJe3Yw72QwBBBxNoukIj3lEeBNXwbNiKrNuB1oyQgTBw5QHUhNO3SteEtHaMK6ag==",
"dev": true
},
"postcss": {
"version": "8.4.14",
"resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.14.tgz",
@@ -5551,6 +5634,12 @@
"vfile": "^5.0.0"
}
},
"react-spinners": {
"version": "0.13.7",
"resolved": "https://registry.npmjs.org/react-spinners/-/react-spinners-0.13.7.tgz",
"integrity": "sha512-mRamn56bfxWbGcacif5RT3UbeJaXi2AttjtPwSmomuv2IcxjpbfETCzdTvaQpNDk0E33ENJsStsQeKAZFuJcpA==",
"requires": {}
},
"react-toastify": {
"version": "9.1.1",
"resolved": "https://registry.npmjs.org/react-toastify/-/react-toastify-9.1.1.tgz",
+6 -1
View File
@@ -9,7 +9,8 @@
"dev": "next",
"build": "next build",
"start": "next start",
"db": "npx prisma migrate reset --force"
"db": "npx prisma migrate reset --force",
"test": "playwright test"
},
"dependencies": {
"@hookform/resolvers": "^2.9.10",
@@ -19,6 +20,8 @@
"bootstrap": "^5.2.2",
"chance": "^1.1.9",
"crypto-random-string": "^3.0.0",
"date-format": "^4.0.14",
"dateformat": "^5.0.3",
"js-confetti": "^0.11.0",
"next": "13.0.2",
"next-auth": "4.16.4",
@@ -28,11 +31,13 @@
"react-hook-form": "^7.39.2",
"react-icons": "^4.6.0",
"react-markdown": "8.0.3",
"react-spinners": "^0.13.7",
"react-toastify": "^9.1.1",
"yup": "^0.32.11",
"yup-phone": "^1.3.2"
},
"devDependencies": {
"@playwright/test": "^1.28.1",
"@types/chance": "^1.1.3",
"@types/next-auth": "3.13.0",
"@types/node": "18.11.9",
+3 -1
View File
@@ -1,5 +1,6 @@
import React from "react";
import Head from "next/head";
import style from '../styles/404.module.css'
const NotFound = () => {
@@ -17,7 +18,8 @@ const NotFound = () => {
<link rel="preconnect" href="https://fonts.gstatic.com" crossOrigin="" />
</Head>
{/* backgroundImagePath={'/images/ugh.png'} */}
<div className="body-content position-relative">
<div className="body-content position-relative">
<div className={`${style['footer-separator']}`}></div>
<div className="position-absolute top-50 start-50 translate-middle">
<h1 className="">Page introuvable</h1>
<h4 className="fw-light">La page recherchée n&apos;existe pas.</h4>
+31 -9
View File
@@ -1,6 +1,8 @@
import { SessionProvider } from "next-auth/react";
import { AppProps } from "next/app";
import { useEffect } from "react";
import { useEffect, useState } from "react";
import Router from 'next/router'
import Loader from '../components/Loader';
import 'bootstrap/dist/css/bootstrap.css'
import "../styles/globals.css";
@@ -8,19 +10,39 @@ import 'react-toastify/dist/ReactToastify.css';
import { ToastContainer } from 'react-toastify';
import Layout from "../components/Layout";
import { GlobalContextProvider } from '../context/globalContext';
const App = ({ Component, pageProps }: AppProps) => {
const [isLoading, setIsLoading] = useState(false);
useEffect(() => {
import("bootstrap/dist/js/bootstrap");
}, []);
Router.events.on("routeChangeStart", (url) => {
setIsLoading(true)
});
Router.events.on("routeChangeComplete", (url) => {
setIsLoading(false)
});
Router.events.on("routeChangeError", (url) => {
setIsLoading(false)
});
}, [Router]);
return (
<SessionProvider session={pageProps.session}>
<Layout>
<Component {...pageProps} />
</Layout>
<ToastContainer />
</SessionProvider>
<>
{isLoading && <Loader />}
<SessionProvider session={pageProps.session}>
<GlobalContextProvider>
<Layout>
<Component {...pageProps} />
</Layout>
<ToastContainer />
</GlobalContextProvider>
</SessionProvider>
</>
);
};
-26
View File
@@ -1,26 +0,0 @@
import type { NextApiRequest, NextApiResponse } from 'next'
import { getSession } from 'next-auth/react';
import prisma from '../../../../lib/prisma'
// DELETE /api/post/:id
export default async function handle(req: NextApiRequest, res: NextApiResponse) {
const postId = req.query.id;
const session = await getSession({ req })
if (req.method === "DELETE") {
if (session) {
const post = await prisma.post.delete({
where: { id: Number(postId) },
});
res.json(post);
} else {
res.status(401).send({ message: 'Unauthorized' })
}
} else {
throw new Error(
`The HTTP ${req.method} method is not supported at this route.`
);
}
}
-25
View File
@@ -1,25 +0,0 @@
import type { NextApiRequest, NextApiResponse } from 'next'
import prisma from '../../../../lib/prisma'
import { getSession } from 'next-auth/react'
// POST /api/post
// Required fields in body: title
// Optional fields in body: content
export default async function handle(req: NextApiRequest, res: NextApiResponse) {
const { title, content } = req.body;
const session = await getSession({ req });
if (session) {
const result = await prisma.post.create({
data: {
title: title,
content: content,
author: { connect: { email: session?.user?.email } },
},
});
res.json(result);
} else {
res.status(401).send({ message: 'Unauthorized' })
}
}
@@ -1,34 +0,0 @@
import type { NextApiRequest, NextApiResponse } from 'next'
import prisma from '../../../../lib/prisma'
import { getSession } from 'next-auth/react'
// UPDATE /api/profile
// Required fields in body: title
export default async function handle(req: NextApiRequest, res: NextApiResponse) {
const { bioValue } = req.body;
console.log('server biovalue:', bioValue)
const session = await getSession({ req });
if (req.method === "PUT") {
if (session) {
const updateUserProfil = await prisma.user.update({
where: { email: session.user.email },
data: {
profile: {
update: {
bio: bioValue,
},
},
}
})
res.status(200).send({ result: updateUserProfil, message: 'Profiled updated !' });
} else {
res.status(401).send({ message: 'Unauthorized' })
}
} else {
throw new Error(
`The HTTP ${req.method} method is not supported at this route.`
);
}
}
@@ -1,19 +0,0 @@
import type { NextApiRequest, NextApiResponse } from 'next'
import { getSession } from 'next-auth/react';
import prisma from '../../../../lib/prisma'
// PUT /api/publish/:id
export default async function handle(req: NextApiRequest, res: NextApiResponse) {
const postId = req.query.id;
const session = await getSession({ req })
if (session) {
const post = await prisma.post.update({
where: { id: Number(postId) },
data: { published: true },
});
res.json(post);
} else {
res.status(401).send({ message: 'Unauthorized' })
}
}
-81
View File
@@ -1,81 +0,0 @@
import React, { useState } from "react";
import Layout from "../../components/Layout";
import Router from "next/router";
const Draft = () => {
const [title, setTitle] = useState("");
const [content, setContent] = useState("");
const submitData = async (e: React.SyntheticEvent) => {
e.preventDefault();
try {
const body = { title, content };
await fetch(`/api/post`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(body),
});
await Router.push("/drafts");
} catch (error) {
console.error(error);
}
};
return (
<Layout>
<div>
<form onSubmit={submitData}>
<h1>New Draft</h1>
<input
autoFocus
onChange={(e) => setTitle(e.target.value)}
placeholder="Title"
type="text"
value={title}
/>
<textarea
cols={50}
onChange={(e) => setContent(e.target.value)}
placeholder="Content"
rows={8}
value={content}
/>
<input disabled={!content || !title} type="submit" value="Create" />
<a className="back" href="#" onClick={() => Router.push("/")}>
or Cancel
</a>
</form>
</div>
<style jsx>{`
.page {
background: white;
padding: 3rem;
display: flex;
justify-content: center;
align-items: center;
}
input[type="text"],
textarea {
width: 100%;
padding: 0.5rem;
margin: 0.5rem 0;
border-radius: 0.25rem;
border: 0.125rem solid rgba(0, 0, 0, 0.2);
}
input[type="submit"] {
background: #ececec;
border: 0;
padding: 1rem 2rem;
}
.back {
margin-left: 1rem;
}
`}</style>
</Layout>
);
};
export default Draft;
-78
View File
@@ -1,78 +0,0 @@
import React from "react";
import { GetServerSideProps } from "next";
import Layout from "../../components/Layout";
import Post, { PostProps } from "../../components/Post";
import { useSession, getSession } from "next-auth/react";
import prisma from '../../lib/prisma'
export const getServerSideProps: GetServerSideProps = async ({ req, res }) => {
const session = await getSession({ req });
if (!session) {
res.statusCode = 403;
return { props: { drafts: [] } };
}
const drafts = await prisma.post.findMany({
where: {
author: { email: session.user.email },
published: false,
},
include: {
author: {
select: { name: true },
},
},
});
return {
props: { drafts },
};
};
type Props = {
drafts: PostProps[];
};
const Drafts = (props: Props) => {
const { data: session } = useSession();
if (!session) {
return (
<Layout>
<h1>My Drafts</h1>
<div>You need to be authenticated to view this page.</div>
</Layout>
);
}
return (
<Layout>
<div className="page">
<h1>My Drafts</h1>
<main>
{props.drafts.map((post) => (
<div key={post.id} className="post">
<Post post={post} />
</div>
))}
</main>
</div>
<style jsx>{`
.post {
background: white;
transition: box-shadow 0.1s ease-in;
}
.post:hover {
box-shadow: 1px 1px 3px #aaa;
}
.post + .post {
margin-top: 2rem;
}
`}</style>
</Layout>
);
};
export default Drafts;
-91
View File
@@ -1,91 +0,0 @@
import React from "react";
import { GetServerSideProps } from "next";
import ReactMarkdown from "react-markdown";
import Layout from "../../../components/Layout";
import Router from "next/router";
import { PostProps } from "../../../components/Post";
import prisma from '../../../lib/prisma'
import { useSession } from "next-auth/react";
export const getServerSideProps: GetServerSideProps = async ({ params }) => {
const post = await prisma.post.findUnique({
where: {
id: Number(params?.id) || -1,
},
include: {
author: {
select: { name: true, email: true },
},
},
});
return {
props: post,
};
};
async function publishPost(id: number): Promise<void> {
await fetch(`/api/publish/${id}`, {
method: "PUT",
});
await Router.push("/")
}
async function deletePost(id: number): Promise<void> {
await fetch(`/api/post/${id}`, {
method: "DELETE",
});
await Router.push("/")
}
const Post = (props: PostProps) => {
const { data: session, status } = useSession();
if (status === 'loading') {
return <div>Authenticating ...</div>;
}
const userHasValidSession = Boolean(session);
const postBelongsToUser = session?.user?.email === props.author?.email;
let title = props.title;
if (!props.published) {
title = `${title} (Draft)`;
}
return (
<Layout>
<div>
<h2>{title}</h2>
<p>By {props?.author?.name || "Unknown author"}</p>
<ReactMarkdown children={props.content} />
{!props.published && userHasValidSession && postBelongsToUser && (
<button onClick={() => publishPost(props.id)}>Publish</button>
)}
{userHasValidSession && postBelongsToUser && (
<button onClick={() => deletePost(props.id)}>Delete</button>
)}
</div>
<style jsx>{`
.page {
background: white;
padding: 2rem;
}
.actions {
margin-top: 2rem;
}
button {
background: #ececec;
border: 0;
border-radius: 0.125rem;
padding: 1rem 2rem;
}
button + button {
margin-left: 1rem;
}
`}</style>
</Layout>
);
};
export default Post;
-171
View File
@@ -1,171 +0,0 @@
import React, { useState } from "react";
import { GetServerSideProps } from "next";
import Layout from "../../components/Layout";
import { useSession, getSession } from "next-auth/react";
import prisma from '../../lib/prisma'
import Router from "next/router";
import { ProfileProps } from "../../types/profile";
import { Resolver, SubmitHandler } from "react-hook-form";
//https://www.bezkoder.com/react-hook-form-typescript/
import { useForm } from 'react-hook-form';
import { yupResolver } from '@hookform/resolvers/yup';
import * as Yup from 'yup';
type UserSubmitForm = {
bio: string;
};
type Profil = {
isUserProfile: any;
}
interface ResponseData {
result: string;
message: string
}
export const getServerSideProps: GetServerSideProps = async ({ req, res }) => {
const session = await getSession({ req });
//pas de session ? on ne retourne un code erreur
//voir pour rediriger vers la page de connection
//ou afficher pop up "vous n'est pas connecter"
if (!session) {
res.statusCode = 403;
return { props: { profile: null } };
}
// si session ? on récupére le profil de l'utilisateur si il existe
if (session) {
const isUserProfile = await prisma.profile.findMany({
where: {
user: { email: session.user.email },
}
})
console.log('profil utilisateur ?', isUserProfile);
// il n'existe pas ? on le crée
if (isUserProfile.length <= 0) {
const newProfil = await prisma.profile.create({
data: {
bio: "",
user: {
connect: { email: session.user.email },
},
},
});
console.log('newProfil', newProfil);
}
// on renvoi le profil
return { props: { isUserProfile } };
}
};
const Profil = ({ isUserProfile }: Profil) => {
const validationSchema = Yup.object().shape({
bio: Yup.string().trim().required("ce champ ne peux etre vide..."),
});
const {
register,
handleSubmit,
reset,
formState: { errors }
} = useForm<UserSubmitForm>({
resolver: yupResolver(validationSchema)
});
const [response, setResponse] = useState<ResponseData | undefined>();
const { data: session } = useSession();
React.useEffect(() => {
console.log('user profil props', isUserProfile)
}, [])
const onSubmit = async (data: UserSubmitForm) => {
console.log(data);
try {
const body = { bioValue: data.bio };
await fetch(`/api/profile`, {
method: "PUT",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(body),
})
.then((res) => res.json())
.then((data) => {
setResponse(data);
console.log('response', data);
})
await Router.push("/profile");
} catch (error) {
console.error(error);
}
};
if (!session) {
return (
<Layout>
<h1>Mon Compte</h1>
<div>Vous devez être authentifié pour voir cette page.</div>
</Layout>
);
}
return (
<Layout>
<div className="page">
<h1>Mon compte</h1>
<main>
<div className="register-form">
<p>Ma bio : {isUserProfile[0]?.bio}</p>
<form onSubmit={handleSubmit(onSubmit)}>
<div className="form-group">
<label>Ma bio :</label>
<input
placeholder="Ma bio..."
defaultValue={isUserProfile[0]?.bio}
type="text"
{...register('bio')}
className={`form-control ${errors.bio ? 'is-invalid' : ''}`}
/>
<div className="invalid-feedback">{errors.bio?.message}</div>
</div>
<div className="form-group">
<button type="submit" className="btn btn-primary">
Valider les changements
</button>
<button
type="button"
onClick={() => reset()}
className="btn btn-warning float-right"
>
Reset
</button>
</div>
</form>
</div>
<p>Email : {session.user.email}</p>
{response && <p>{response.message}</p>}
</main>
</div>
</Layout>
);
};
export default Profil;
+384
View File
@@ -0,0 +1,384 @@
import React, { useEffect, useState, useSyncExternalStore } from "react";
import prisma from '../lib/prisma'
import dateFormat, { masks } from "dateformat";
import Image from 'next/image';
import * as Yup from 'yup';
import Head from "next/head";
import { getCsrfToken, getSession, signIn, useSession } from "next-auth/react";
import { yupResolver } from "@hookform/resolvers/yup";
import "yup-phone";
import { SubmitHandler, useForm } from "react-hook-form";
import { AiOutlineCheck } from 'react-icons/ai'
import Router from "next/router";
import { useRouter } from 'next/navigation';
import style from '../styles/Connexion.module.css';
import imageConnexion from '../public/images/connexion_image.png'
import Link from "next/link";
import { TfiInfoAlt } from 'react-icons/tfi'
import { TfiGift } from 'react-icons/tfi'
import { toast } from "react-toastify";
import { Token } from "nodemailer/lib/xoauth2";
import { isGeneratorFunction } from "util/types";
import { UserProps } from "../types/user";
import { UserGainProps } from "../types/userGain";
import { Gain, Produit, Role, User } from "@prisma/client";
type FormData = {
email: string;
name: string;
surname: string;
address: string;
zipCode: number;
phoneNumber: number;
};
export async function getServerSideProps(context) {
const session = await getSession(context)
const isAdmin = ['SELLER', 'ADMIN', 'SUPERADMIN'].includes(session?.user['role']);
if (!session || !isAdmin) {
return {
redirect: {
destination: '/',
permanent: false
}
}
}
const users = await prisma.user.findMany({
include: {
gains: true
}
});
const user = await prisma.user.findUnique({
where: {
email: session?.user.email
}
});
const produits = await prisma.produit.findMany({})
return {
props: {
user: JSON.parse(JSON.stringify(user)),
produits: JSON.parse(JSON.stringify(produits)),
users: JSON.parse(JSON.stringify(users))
},
}
}
type Props = {
user: User;
produits: Produit[];
users: User[]
}
const Admin = (props: Props) => {
const { data: session, status } = useSession();
const [response, setResponse] = useState(null)
const [currentUser, setCurrentUser] = useState(null)
const [users, setUsers] = useState(props.users)
const [currentUserGain, setCurrentUserGain] = useState(null)
const router = useRouter()
const { register, setValue, handleSubmit, formState: { errors } } = useForm<FormData>({
});
const fetcher = async (url, method, body = {}, callback?: any) => {
try {
await fetch(url, {
method,
headers: { "Content-Type": "application/json" },
body: JSON.stringify(body),
})
.then((res) => res.json())
.then(async (data) => {
setResponse(data);
callback;
if (data.err) {
toast.error(data.err, {
position: "top-center",
autoClose: 2000,
hideProgressBar: false,
closeOnClick: true,
pauseOnHover: true,
draggable: true,
progress: undefined,
theme: "light",
});
return;
}
toast.success(data.message, {
position: "top-center",
autoClose: 5000,
hideProgressBar: false,
closeOnClick: true,
pauseOnHover: true,
draggable: true,
progress: undefined,
theme: "light",
});
})
}
catch (error) {
console.error('ERROR :', error);
}
}
const onSubmit = async ({
email,
name,
surname,
address,
zipCode,
phoneNumber }: FormData) => {
const body = {
selectedUserEmail: email,
selectedUserName: name,
selectedUserSurname: surname,
selectedUserAddress: address,
selectedUserZipCode: Number(zipCode),
selectedUserPhoneNumber: Number(phoneNumber),
};
fetcher('/api/user/update', 'POST', body)
};
const onChangeRole = async (e: React.ChangeEvent<HTMLSelectElement>, user: User) => {
const body = { selectedUserEmail: user.email, selectedUserRole: e.target.value }
fetcher('/api/user/update', 'PUT', body)
};
const onDeleteUser = async (userEmail: string) => {
const body = { selectedUserEmail: userEmail }
if (props.user.email === userEmail) {
toast.error('Vous devez être déconnecté pour supprimer votre compte', {
position: "top-center",
autoClose: 2000,
hideProgressBar: false,
closeOnClick: true,
pauseOnHover: true,
draggable: true,
progress: undefined,
theme: "light",
});
return;
}
fetcher('/api/user/delete', 'DELETE', body)
};
const selectUser = (user: any) => {
console.log('d', user.gains)
setCurrentUser(user);
setCurrentUserGain(user.gains)
setValue("name", user.name)
setValue("email", user.email)
setValue("surname", user.surname)
setValue("address", user.address)
setValue("zipCode", user.zipCode)
setValue("phoneNumber", user.phoneNumber)
}
const changeGiftStatus = async (gain: Gain) => {
const body = { gain }
fetcher('/api/user/update-gift', 'PUT', body)
console.log('g', gain);
setCurrentUserGain(gain)
// router.refresh();
};
return (
<>
<Head>
<title>Administration</title>
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossOrigin="" />
</Head>
<div className={`${style['masthead']} d-flex justify-content-center align-items-center text-center`}>
<div className="container align-items-center d-flex flex-column">
<div className={`${style['bloc-content']} col-12 col-md-12`}>
<div className="row">
<div className="col-md-12 col-sm-12">
<hr />
<h1 className="fw-light">Utilisateurs <TfiInfoAlt size={40} /></h1>
<hr />
{users.length <= 0 && <p>Pas encore d'utilisateur</p>}
{users.length >= 1 &&
<table className={`table table-hover`}>
<thead>
<tr>
<th scope="col">#</th>
<th scope="col">Nom</th>
<th scope="col">Prénom</th>
<th scope="col">Email</th>
<th scope="col">Types</th>
</tr>
</thead>
<tbody>
{users.map((info: User, index: number) => {
return <tr key={index} className={`${style.cursor}`} onClick={() => selectUser(info)}>
<th scope="row">{++index}</th>
<td>{info.surname}</td>
<td>{info.name}</td>
<td>{info.email}</td>
<td>
<select className="custom-select" defaultValue={info.role} onChange={(e) => onChangeRole(e, info)}>
<option value="USER">Client</option>
<option value="SELLER">Vendeur</option>
<option value="ADMIN">Administrateur</option>
</select>
</td>
<td><button className="btn btn-primary" onClick={() => onDeleteUser(info.email)}>Supprimer</button></td>
</tr>
})}
</tbody>
</table>
}
</div>
</div>
<div className="row">
<div className="col-md-6 col-sm-12">
<hr />
<h1 className="fw-light">{currentUser?.email || 'utilisateur'} <TfiInfoAlt size={40} /></h1>
<hr />
{currentUser && <form onSubmit={handleSubmit(onSubmit)}>
<div className="form-group">
<div className="form-group row">
<label htmlFor="staticEmail" className="col-sm-3 col-form-label">Email :</label>
<div className="col-sm-9">
<input type="text" readOnly className="form-control-plaintext text-sm-center" id="staticEmail" value={currentUser?.email || ''} />
</div>
</div>
<div className="form-group row">
<label htmlFor="inputName" className="col-sm-3 col-form-label">Nom :</label>
<div className="col-sm-9">
<input {...register("name")} className={`form-control ${errors.name ? 'is-invalid' : ''}`} defaultValue={currentUser?.name || ''} id="inputName" placeholder="John..." />
<div className="invalid-feedback alert alert-danger mt-2">{errors.name?.message}</div>
</div>
</div>
<div className="form-group row">
<label htmlFor="surname" className="col-sm-3 col-form-label">Prenom :</label>
<div className="col-sm-9">
<input {...register("surname")} className={`form-control ${errors.surname ? 'is-invalid' : ''}`} defaultValue={currentUser?.surname || ''} id="surname" placeholder="Doe..." />
<div className="invalid-feedback alert alert-danger mt-2">{errors.surname?.message}</div>
</div>
</div>
<div className="form-group row">
<label htmlFor="address" className="col-sm-3 col-form-label">Adresse :</label>
<div className="col-sm-9">
<input {...register("address")} className={`form-control ${errors.address ? 'is-invalid' : ''}`} defaultValue={currentUser?.address || ''} id="address" placeholder="1 rue de la paix..." />
<div className="invalid-feedback alert alert-danger mt-2">{errors.address?.message}</div>
</div>
</div>
<div className="form-group row">
<label htmlFor="zipCode" className="col-sm-3 col-form-label">Code postale :</label>
<div className="col-sm-9">
<input {...register("zipCode")} className={`form-control ${errors.zipCode ? 'is-invalid' : ''}`} defaultValue={currentUser?.zipCode || ''} id="zipCode" placeholder="95000..." />
<div className="invalid-feedback alert alert-danger mt-2">{errors.zipCode?.message}</div>
</div>
</div>
<div className="form-group row">
<label htmlFor="phoneNumber" className="col-sm-3 col-form-label">Téléphone :</label>
<div className="col-sm-9">
<input {...register("phoneNumber")} className={`form-control ${errors.phoneNumber ? 'is-invalid' : ''}`} defaultValue={currentUser?.phoneNumber || ''} id="phoneNumber" placeholder="0123456789..." />
<div className="invalid-feedback alert alert-danger mt-2">{errors.phoneNumber?.message}</div>
</div>
</div>
<div className="form-group">
<button
type="submit"
className="btn btn-primary mt-2"
>
Sauvegarder mes changements
</button>
</div>
</div>
</form>}
{!currentUser && <p>Séléctionner un utilisateur</p>}
</div>
<div className="col-md-6 col-sm-12">
<hr />
<h1 className="fw-light">Cadeaux de {currentUser?.email || "l'utilisateur"} <TfiGift size={40} /></h1>
<hr />
{currentUser?.gains?.length <= 0 && <p>Pas encore de cadeaux gagné</p>}
{currentUser?.gains?.length >= 1 &&
<table className="table">
<thead>
<tr>
<th scope="col">#</th>
<th scope="col">Codes joués</th>
<th scope="col">Cadeaux</th>
<th scope="col">Retiré en magasin</th>
<th scope="col">Date Retrait</th>
</tr>
</thead>
<tbody>
{currentUserGain.map((gain: Gain, index: number) => {
return <tr key={index}>
<th scope="row">{++index}</th>
<td>{gain?.codeCadeau}</td>
<td>{props.produits[gain.produitId - 1].nomProduit}</td>
<td>{gain?.retrait ? '❌ déja récupéré' : '✔️ disponible'}</td>
<td>{gain?.dateRetrait ? dateFormat(gain?.dateRetrait, "dd/mm/yyyy") : ''}</td>
<td>
<button className="btn btn-primary" disabled={gain?.retrait} onClick={() => changeGiftStatus(gain)}>OUI</button>
</td>
</tr>
})}
</tbody>
</table>
}
</div>
</div>
</div>
</div >
</div>
</>)
};
export default Admin;
+11 -4
View File
@@ -5,7 +5,8 @@ import { PrismaAdapter } from '@next-auth/prisma-adapter'
import GoogleProvider from "next-auth/providers/google";
import EmailProvider from 'next-auth/providers/email'
import prisma from '../../../lib/prisma'
import { Session } from "@prisma/client";
import { CustomsendVerificationRequest } from "./signinemail"
const authHandler: NextApiHandler = (req, res) => NextAuth(req, res, options);
export default authHandler;
@@ -26,20 +27,26 @@ const options = {
pass: process.env.EMAIL_SERVER_PASSWORD
}
},
from: process.env.EMAIL_FROM
from: process.env.EMAIL_FROM,
sendVerificationRequest({ identifier, url, provider }) {
CustomsendVerificationRequest({ identifier, url, provider })
}
}),
],
adapter: PrismaAdapter(prisma),
secret: process.env.SECRET,
callbacks: {
async session({ session, user }) {
async session({ session, user }: {
session: any,
user: any
}) {
const getCurrentUser = await prisma.user.findMany({
where: { email: session.user.email },
})
//récupération du role
const { role } = getCurrentUser[0];
session.user.role = role
return session
return session;
}
},
pages: {
+243
View File
@@ -0,0 +1,243 @@
// https://craftingemails.com/blog/nextauth-signin-custom-email
import { Theme } from "next-auth"
import { createTransport } from "nodemailer"
export async function CustomsendVerificationRequest(params) {
const { identifier, url, provider, theme } = params
const { host } = new URL(url)
// NOTE: You are not required to use `nodemailer`, use whatever you want.
const transport = createTransport(provider.server)
const result = await transport.sendMail({
to: identifier,
from: provider.from,
subject: `Sign in to ${host}`,
text: text({ url, host }),
html: html({ url, host, theme }),
})
const failed = result.rejected.concat(result.pending).filter(Boolean)
if (failed.length) {
throw new Error(`Email(s) (${failed.join(", ")}) could not be sent`)
}
}
function html(params: { url: string; host: string; theme: Theme }) {
const { url, host, theme } = params
const escapedHost = host.replace(/\./g, "&#8203;.")
return `<!DOCTYPE html>
<html lang="fr" xmlns:v="urn:schemas-microsoft-com:vml">
<head>
<meta charset="utf-8">
<meta name="x-apple-disable-message-reformatting">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="format-detection" content="telephone=no, date=no, address=no, email=no">
<meta name="color-scheme" content="light dark">
<meta name="supported-color-schemes" content="light dark">
<!--[if mso]>
<noscript>
<xml>
<o:OfficeDocumentSettings xmlns:o="urn:schemas-microsoft-com:office:office">
<o:PixelsPerInch>96</o:PixelsPerInch>
</o:OfficeDocumentSettings>
</xml>
</noscript>
<style>
td,th,div,p,a,h1,h2,h3,h4,h5,h6 {font-family: "Segoe UI", sans-serif; mso-line-height-rule: exactly;}
</style>
<![endif]-->
<title>Connection à Thé Tip Top</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin="">
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;700&display=swap" rel="stylesheet" media="screen">
<style>
img {
max-width: 100%;
vertical-align: middle;
line-height: 100%;
border: 0
}
.hover-bg-slate-100:hover {
background-color: #F7F8FA !important
}
.hover-bg-primary-600:hover {
background-color: #006600e6 !important
}
.hover-text-slate-600:hover {
color: #585E83 !important
}
.hover-text-primary-600:hover {
color: #003CDF !important
}
@media (prefers-color-scheme: dark) {
.dark-bg-gray-800 {
background-color: #1E1E1E !important
}
.dark-bg-gray-900 {
background-color: #121212 !important
}
.dark-bg-gray-50 {
background-color: #f9fafb !important
}
.dark-bg-gray-600 {
background-color: #272727 !important
}
.dark-text-gray-200 {
color: #ABABAB !important
}
.dark-text-gray-50 {
color: #f9fafb !important
}
.dark-text-gray-800 {
color: #1E1E1E !important
}
.dark-text-gray-900 {
color: #121212 !important
}
.dark-text-primary-500 {
color: #006600e6 !important
}
.dark-text-primary-200 {
color: #94B5FF !important
}
.dark-hover-bg-gray-50:hover {
background-color: #f9fafb !important
}
.dark-hover-text-gray-100:hover {
color: #D5D5D5 !important
}
.dark-hover-text-primary-100:hover {
color: #C6D9FF !important
}
}
@media (max-width: 648px) {
.sm-mt-0 {
margin-top: 0 !important
}
.sm-block {
display: block !important
}
.sm-hidden {
display: none !important
}
.sm-h-px {
height: 1px !important
}
.sm-w-full {
width: 100% !important
}
.sm-py-3 {
padding-top: 12px !important;
padding-bottom: 12px !important
}
.sm-px-0 {
padding-left: 0 !important;
padding-right: 0 !important
}
.sm-px-6 {
padding-left: 24px !important;
padding-right: 24px !important
}
.sm-leading-10 {
line-height: 40px !important
}
}
</style>
</head>
<body class="dark-bg-gray-900" style="margin: 0; width: 100%; padding: 0; word-break: break-word; -webkit-font-smoothing: antialiased; background-color: #F7F8FA">
<div style="display: none">
Connexion à Thé Tip Top
&#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847;
</div>
<div role="article" aria-roledescription="email" aria-label="Connexion à Thé Tip Top" lang="fr" style="font-size: 16px; font-size: 1rem; font-size: max(16px, 1rem)">
<table style="width: 100%; font-family: 'Inter', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif" cellpadding="0" cellspacing="0" role="presentation">
<tr>
<td align="center">
<!--[if mso]>
<v:rect xmlns:v="urn:schemas-microsoft-com:vml" fill="true" stroke="false" style="height:300px; mso-width-percent: 1000; position: absolute; left: -10px; top: -20px; z-index: -1;">
<v:fill type="tile" color="#dee2e9" />
<v:textbox inset="0,0,0,0">
<![endif]-->
<div style="max-height: 40px">
<div class="dark-bg-gray-900" style="height: 100vh; background-color: #DEE2E9"></div>
</div>
<!--[if mso]>
</v:textbox>
</v:rect>
<![endif]-->
<table class="sm-w-full" style="position: relative; max-height: 0; width: 568px; opacity: 0.999" cellpadding="0" cellspacing="0" role="presentation">
<tr>
<td style="vertical-align: top" valign="top">
<div class="sm-px-6">
<div role="separator" style="line-height: 40px">&zwnj;</div>
<table class="dark-bg-gray-600" style="width: 100%; border-radius: 8px; background-color: #fff; box-shadow: 0px 10px 10px -5px rgba(0, 0, 0, 0.04), 0px 20px 25px -5px rgba(0, 0, 0, 0.1)" cellpadding="0" cellspacing="0" role="presentation">
<tr>
<td class="sm-px-6" style="padding: 40px">
<table style="width: 100%" cellpadding="0" cellspacing="0" role="presentation">
<tr>
<td>
<h1 class="dark-text-gray-50" style="margin: 0; font-size: 36px; font-weight: 700; line-height: 1; letter-spacing: -0.025em; color: #191847">
Connexion à Thé Tip Top
</h1>
<div role="separator" style="line-height: 24px">
&zwnj;
</div>
<p class="dark-text-gray-50" style="margin: 0; font-size: 16px; line-height: 26px; color: #191847">
Bonjour,
<br>
<br>
Connectez vous en cliquant sur le bouton ci-dessous.
</p>
</td>
</tr>
<tr role="separator">
<td style="line-height: 24px">&zwnj;</td>
</tr>
<tr>
<td align="center">
<a href="${url}" class="sm-block dark-text-primary-500 hover-bg-primary-600 dark-bg-gray-50 dark-hover-bg-gray-50" style="text-decoration: none; display: inline-block; border-radius: 8px; background-color: #006600e6; padding: 14px 24px; text-align: center; font-size: 16px; font-weight: 700; color: #f9fafb; box-shadow: 0px 2px 4px -1px rgba(0, 0, 0, 0.06), 0px 4px 6px -1px rgba(0, 0, 0, 0.1)">
<!--[if mso
]><i
style="
letter-spacing: 24px;
mso-font-width: -100%;
mso-text-raise: 30px;
"
>&nbsp;</i><!
[endif]-->
<span style="mso-text-raise: 15px">Se connecter</span>
<!--[if mso
]><i
style="
letter-spacing: 24px;
mso-font-width: -100%;
"
>&nbsp;</i><!
[endif]-->
</a>
</td>
</tr>
</table>
</td>
</tr>
</table>
<div role="separator" style="line-height: 24px">
&zwnj;
</div>
</div>
</td>
</tr>
</table>
</td>
</tr>
</table>
</div>
</body>
</html>`
}
// Email Text body (fallback for email clients that don't render HTML)
function text({ url, host }: { url: string; host: string }) {
return `Connectez vous à ${host}\n${url}\n\n`
}
+36
View File
@@ -0,0 +1,36 @@
import { NextApiRequest, NextApiResponse } from 'next';
import { getSession } from 'next-auth/react';
import { Role } from '../../../enum/role.enum';
import prisma from '../../../lib/prisma';
//api qui va rendre un utilisateur admin (pour les developpeurs)
//--> http://localhost:3000/api/superadmin/make-admin?pass=1234 (a effacer)
export default async function makeMeAdmin(req: NextApiRequest, res: NextApiResponse) {
const { pass } = req.query;
const session = await getSession({ req })
const goodPassword = pass === '1234';
//si utilisateur connecté et que le parametre 'pass' est '1234'
if (session && goodPassword) {
//MAJ de l'utilisateur en superadmin
await prisma.user.update({
where: { email: session.user.email },
data: {
role: Role.SUPERADMIN,
},
})
return res.status(200).send({ message: 'Profiled updated welcome ADMIN !' });
} else {
res.status(401).send({ message: 'Unauthorized' })
}
}
+36
View File
@@ -0,0 +1,36 @@
import { NextApiRequest, NextApiResponse } from 'next';
import { getSession } from 'next-auth/react';
import { Role } from '../../../enum/role.enum';
import prisma from '../../../lib/prisma';
//api qui va rendre un utilisateur super admin (pour les developpeurs)
//--> http://localhost:3000/api/super/superadmin?pass=1234 (a effacer)
export default async function makeMeSuper(req: NextApiRequest, res: NextApiResponse) {
const { pass } = req.query;
const session = await getSession({ req })
const goodPassword = pass === '1234';
//si utilisateur connecté et que le parametre 'pass' est '1234'
if (session && goodPassword) {
//MAJ de l'utilisateur en superadmin
await prisma.user.update({
where: { email: session.user.email },
data: {
role: Role.SUPERADMIN,
},
})
return res.status(200).send({ message: 'Profiled updated welcome SUPERADMIN !' });
} else {
res.status(401).send({ message: 'Unauthorized' })
}
}
+2 -5
View File
@@ -38,7 +38,7 @@ export default async function testCode(req: NextApiRequest, res: NextApiResponse
})
//check si le code a déja été utilisé
if (!codeCadeauInfo.actif) {
if (!codeCadeauInfo.codeActif) {
res.status(401).json({ err: 'Ce code a déja été utilisé' });
return;
}
@@ -57,9 +57,6 @@ export default async function testCode(req: NextApiRequest, res: NextApiResponse
}
})
//mise à jour de la date ou le ticket est utilisé
//retire un ticket du total de ticket restant
const ticketUpdate = await prisma.ticketsRestants.update({
where: {
@@ -78,7 +75,7 @@ export default async function testCode(req: NextApiRequest, res: NextApiResponse
id: codeCadeauInfo.id
},
data: {
actif: false,
codeActif: false,
}
})
+74
View File
@@ -0,0 +1,74 @@
import prisma from '../../../lib/prisma';
import chance from 'chance'
import cryptoRandomString from 'crypto-random-string';
import { NextApiRequest, NextApiResponse } from 'next';
import { getSession } from 'next-auth/react';
import { Cadeaux } from '../../../enum/cadeaux.enum';
import { Role } from '../../../enum/role.enum';
//API gain qui va generer un code cadeau qui sera sur la facture du client
//On part du principe qu'une 'API caisse'(qu'on ne gere pas) déclenche l'appel à l'API gain
export default async function deleteUser(req: NextApiRequest, res: NextApiResponse) {
const session = await getSession({ req })
const { selectedUserEmail } = req.body;
// est-ce la méthode est DELETE ?
if (req.method !== ("DELETE")) {
throw new Error(
`The HTTP ${req.method} method is not supported at this route.`
);
}
// est-ce que utilisateur est connecté ?
if (!session) {
res.status(401).json({ err: "Vous devez être connecté" });
return;
}
//supprime l'utilisateur connecté
const user = await prisma.user.delete({
where: { email: selectedUserEmail },
})
// est-ce que utilisateur est un client classique ? Donc interdit pour lui de faire des updates
// A ACTIVER EN PRODUCTION
// if (user.role === 'USER') {
// res.status(401).json({ err: "Vous n'avez pas l'autorisation" });
// return;
// }
////////////////////////////////////////////////
//renvoi la liste des users mis à jour
const users = await prisma.user.findMany({})
res.status(200).send({ message: `L'utilisateur ${user.name} a été supprimé !`, res: users });
}
+102
View File
@@ -0,0 +1,102 @@
import prisma from '../../../lib/prisma';
import chance from 'chance'
import cryptoRandomString from 'crypto-random-string';
import { NextApiRequest, NextApiResponse } from 'next';
import { getSession } from 'next-auth/react';
import { Cadeaux } from '../../../enum/cadeaux.enum';
import { Role } from '../../../enum/role.enum';
//API gain qui va generer un code cadeau qui sera sur la facture du client
//On part du principe qu'une 'API caisse'(qu'on ne gere pas) déclenche l'appel à l'API gain
export default async function getCurrent(req: NextApiRequest, res: NextApiResponse) {
const session = await getSession({ req })
const { selectedUserRole, selectedUserEmail, selectedUserName,
selectedUserSurname,
selectedUserAddress,
selectedUserZipCode,
selectedUserPhoneNumber, } = req.body;
// est-ce la méthode est un POST ou PUT?
if (req.method !== ("POST" || "PUT")) {
throw new Error(
`The HTTP ${req.method} method is not supported at this route.`
);
}
// est-ce que utilisateur est connecté ?
if (!session) {
res.status(401).json({ err: "Vous devez être connecté" });
return;
}
//récupération des informations de l'utilisateur connecté
const user = await prisma.user.findFirst({
where: { email: session.user.email },
})
// est-ce que utilisateur est un client classique ? Donc interdit pour lui de faire des updates
// A ACTIVER EN PRODUCTION
// if (user.role === 'USER') {
// res.status(401).json({ err: "Vous n'avez pas l'autorisation" });
// return;
// }
////////////////////////////////////////////////
//récupération des informations de l'utilisateur selectionné
const selectedUser = await prisma.user.findFirst({
where: { email: selectedUserEmail },
})
console.log('selectedUser', selectedUser);
//mise a jour des données pour l'utilisateur
const updatedUser = await prisma.user.update({
where: {
email: selectedUserEmail,
},
data: {
name: selectedUserName || undefined,
surname: selectedUserSurname || undefined,
address: selectedUserAddress || undefined,
zipCode: selectedUserZipCode || undefined,
phoneNumber: selectedUserPhoneNumber || undefined,
email: selectedUserEmail || undefined,
role: selectedUserRole || undefined
},
})
res.status(200).send({ message: `Les informations de ${selectedUserName} ont été mise à jours !`, res: updatedUser });
}
+84
View File
@@ -0,0 +1,84 @@
import prisma from '../../../lib/prisma';
import chance from 'chance'
import cryptoRandomString from 'crypto-random-string';
import { NextApiRequest, NextApiResponse } from 'next';
import { getSession } from 'next-auth/react';
import { Cadeaux } from '../../../enum/cadeaux.enum';
import { Role } from '../../../enum/role.enum';
import { Gain } from '.prisma/client';
//API gain qui va generer un code cadeau qui sera sur la facture du client
//On part du principe qu'une 'API caisse'(qu'on ne gere pas) déclenche l'appel à l'API gain
export default async function updtateGift(req: NextApiRequest, res: NextApiResponse) {
const session = await getSession({ req })
const { gain } = req.body;
// est-ce la méthode est un POST ou PUT?
// if (req.method !== ("POST" || 'PUT')) {
// throw new Error(
// `The HTTP ${req.method} method is not supported at this route.`
// );
// }
// est-ce que utilisateur est connecté ?
if (!session) {
res.status(401).json({ err: "Vous devez être connecté" });
return;
}
//récupération des gain de l'utilisateur et mise à jour
const updatedGain: Gain = await prisma.gain.update({
where: { id: gain.id },
data: {
retrait: true,
dateRetrait: new Date()
},
})
const updatedCurrentUser = await prisma.user.findFirst({
where: { id: updatedGain.userId },
include: { gains: true }
})
// est-ce que utilisateur est un client classique ? Donc interdit pour lui de faire des updates
// A ACTIVER EN PRODUCTION
// if (user.role === 'USER') {
// res.status(401).json({ err: "Vous n'avez pas l'autorisation" });
// return;
// }
////////////////////////////////////////////////
res.status(200).send({ message: `Le gain a ont été mis à jour !`, res: updatedCurrentUser });
}
+96
View File
@@ -0,0 +1,96 @@
import prisma from '../../../lib/prisma';
import chance from 'chance'
import cryptoRandomString from 'crypto-random-string';
import { NextApiRequest, NextApiResponse } from 'next';
import { getSession } from 'next-auth/react';
import { Cadeaux } from '../../../enum/cadeaux.enum';
import { Role } from '../../../enum/role.enum';
//API gain qui va generer un code cadeau qui sera sur la facture du client
//On part du principe qu'une 'API caisse'(qu'on ne gere pas) déclenche l'appel à l'API gain
export default async function updateUser(req: NextApiRequest, res: NextApiResponse) {
const session = await getSession({ req })
const { selectedUserRole, selectedUserEmail, selectedUserName,
selectedUserSurname,
selectedUserAddress,
selectedUserZipCode,
selectedUserPhoneNumber } = req.body;
// est-ce la méthode est un POST ou PUT?
// if (req.method !== ("POST" || 'PUT')) {
// throw new Error(
// `The HTTP ${req.method} method is not supported at this route.`
// );
// }
// est-ce que utilisateur est connecté ?
if (!session) {
res.status(401).json({ err: "Vous devez être connecté" });
return;
}
//récupération des informations de l'utilisateur connecté
const user = await prisma.user.findFirst({
where: { email: session.user.email },
})
// est-ce que utilisateur est un client classique ? Donc interdit pour lui de faire des updates
// A ACTIVER EN PRODUCTION
// if (user.role === 'USER') {
// res.status(401).json({ err: "Vous n'avez pas l'autorisation" });
// return;
// }
////////////////////////////////////////////////
//mise a jour des données de l'utilisateur séléctionné
const updatedUser = await prisma.user.update({
where: {
email: selectedUserEmail,
},
data: {
name: selectedUserName || undefined,
surname: selectedUserSurname || undefined,
address: selectedUserAddress || undefined,
zipCode: selectedUserZipCode || undefined,
phoneNumber: selectedUserPhoneNumber || undefined,
role: Role[selectedUserRole] || Role.USER
},
})
//renvoi la liste des users mis à jour
const users = await prisma.user.findMany({})
console.log(updatedUser);
res.status(200).send({ message: `Les informations de ${selectedUserEmail} ont été mise à jours !`, res: users });
}
+1 -1
View File
@@ -76,7 +76,7 @@ const MainPage = ({ csrfToken }: Props) => {
const onMailSubmit = async (data: LoginSubmitForm) => {
if (onCheckTerms()) {
signIn("email", { email: data.email, callbackUrl: `${window.location.origin}/create` })
signIn("email", { email: data.email, callbackUrl: `${window.location.origin}/mon-compte` })
}
await trigger("acceptTerms");
await trigger("email");
+3 -3
View File
@@ -13,8 +13,8 @@ import Router from "next/router";
import style from '../styles/Index.module.css';
import rotatingLeftImage from '../public/images/coffret-degustation.webp';
import rotatingRightImage from '../public/images/coffret-degustation2.webp';
import rotatingLeftImage from '../public/images/coffret-degustation-mousselines-individuelles-n3-PhotoRoom.webp';
import rotatingRightImage from '../public/images/coffret-the-PhotoRoom.webp';
import Link from "next/link";
import testerCodeCadeau from '../public/images/svg/testerlecode.svg'
@@ -217,7 +217,7 @@ const MainPage = () => {
<div className={`${style['cadeau-bloc-content']} col-12 col-md-6`} onClick={() => setWinAnimation(false)}
>
<div className={`${style['cadeau-bloc']}`}>
<h1>Vous avez gagnez : un {response.winProduct.nomProduit} !</h1>
<h1>Vous avez gagnez : un {response.winProduct.nomProduit.toLowerCase()} !</h1>
</div>
</div>
+9 -32
View File
@@ -26,8 +26,6 @@ import Link from "next/link";
import { TfiInfoAlt } from 'react-icons/tfi'
import { TfiGift } from 'react-icons/tfi'
import { toast } from "react-toastify";
import { Token } from "nodemailer/lib/xoauth2";
import { isGeneratorFunction } from "util/types";
@@ -35,7 +33,6 @@ import { UserProps } from "../types/user";
import { UserGainProps } from "../types/userGain";
import { Gain, Produit, User } from "@prisma/client";
type FormData = {
email: string;
name: string;
@@ -82,7 +79,7 @@ export async function getServerSideProps(context) {
type Props = {
user: User;
userGains: any;
userGains: Gain[];
}
const MonCompte = (props: Props) => {
@@ -172,12 +169,9 @@ const MonCompte = (props: Props) => {
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossOrigin="" />
</Head>
<div className={`${style['masthead']} d-flex justify-content-center align-items-center text-center`}>
<div className="container align-items-center d-flex flex-column">
<div className={`${style['bloc-content']} col-12 col-md-12`}>
<div className="row">
<div className="col-md-6 col-sm-12">
<hr />
@@ -185,30 +179,26 @@ const MonCompte = (props: Props) => {
<hr />
<form onSubmit={handleSubmit(onSubmit)}>
<div className="form-group">
<div className="form-group row">
<label htmlFor="staticEmail" className="col-sm-3 col-form-label">Email :</label>
<div className="col-sm-9">
<input type="text" readOnly className="form-control-plaintext text-sm-center" id="staticEmail" value={session?.user.email || ''} />
</div>
</div>
<div className="form-group row">
<label htmlFor="inputName" className="col-sm-3 col-form-label">Nom :</label>
<div className="col-sm-9">
<input {...register("name")} className={`form-control ${errors.name ? 'is-invalid' : ''}`} defaultValue={props.user.name} id="inputName" placeholder="John..." />
<input {...register("name")} className={`form-control ${errors.name ? 'is-invalid' : ''}`} defaultValue={props.user?.name || ''} id="inputName" placeholder="John..." />
<div className="invalid-feedback alert alert-danger mt-2">{errors.name?.message}</div>
</div>
</div>
<div className="form-group row">
<label htmlFor="surname" className="col-sm-3 col-form-label">Prenom :</label>
<div className="col-sm-9">
<input {...register("surname")} className={`form-control ${errors.surname ? 'is-invalid' : ''}`} defaultValue={props.user.surname} id="surname" placeholder="Doe..." />
<input {...register("surname")} className={`form-control ${errors.surname ? 'is-invalid' : ''}`} defaultValue={props.user.surname || ''} id="surname" placeholder="Doe..." />
<div className="invalid-feedback alert alert-danger mt-2">{errors.surname?.message}</div>
</div>
</div>
<div className="form-group row">
<label htmlFor="address" className="col-sm-3 col-form-label">Adresse :</label>
<div className="col-sm-9">
@@ -216,7 +206,6 @@ const MonCompte = (props: Props) => {
<div className="invalid-feedback alert alert-danger mt-2">{errors.address?.message}</div>
</div>
</div>
<div className="form-group row">
<label htmlFor="zipCode" className="col-sm-3 col-form-label">Code postale :</label>
<div className="col-sm-9">
@@ -224,7 +213,6 @@ const MonCompte = (props: Props) => {
<div className="invalid-feedback alert alert-danger mt-2">{errors.zipCode?.message}</div>
</div>
</div>
<div className="form-group row">
<label htmlFor="phoneNumber" className="col-sm-3 col-form-label">Téléphone :</label>
<div className="col-sm-9">
@@ -232,17 +220,15 @@ const MonCompte = (props: Props) => {
<div className="invalid-feedback alert alert-danger mt-2">{errors.phoneNumber?.message}</div>
</div>
</div>
<div className="form-group row">
<div className="form-group">
<button
type="submit"
className="btn btn-primary mt-2"
>
Sauvegarder les changements
Sauvegarder mes changements
</button>
</div>
</div>
</form>
</div>
<div className="col-md-6 col-sm-12">
@@ -257,33 +243,24 @@ const MonCompte = (props: Props) => {
<th scope="col">#</th>
<th scope="col">Mes codes joué</th>
<th scope="col">Mes cadeaux</th>
<th scope="col">Statut</th>
</tr>
</thead>
<tbody>
{props.userGains.map((info: any) => {
{props.userGains.map((info: any, index: number) => {
return <tr>
<th scope="row"></th>
<th scope="row">{++index}</th>
<td>{info.codeCadeau}</td>
<td>{info.produit.nomProduit}</td>
<td>{info.produit.retrait ? '❌ déja récupéré' : '✔️ venir me chercher !'}</td>
</tr>
})}
</tbody>
</table>
}
</div>
</div>
</div >
</div>
</div >
</>)
+1
View File
@@ -28,6 +28,7 @@ type Produit = {
nomProduit: string;
prixTtc: number;
image: string;
description: string;
}
const ToutSavoir = ({ produits }: Props) => {
@@ -0,0 +1,117 @@
-- CreateEnum
CREATE TYPE "Role" AS ENUM ('USER', 'ADMIN', 'SUPERADMIN');
-- CreateTable
CREATE TABLE "accounts" (
"id" SERIAL NOT NULL,
"user_id" INTEGER NOT NULL,
"type" TEXT NOT NULL,
"provider" TEXT NOT NULL,
"provider_account_id" TEXT NOT NULL,
"refresh_token" TEXT,
"access_token" TEXT,
"expires_at" INTEGER,
"token_type" TEXT,
"scope" TEXT,
"id_token" TEXT,
"session_state" TEXT,
"oauth_token_secret" TEXT,
"oauth_token" TEXT,
CONSTRAINT "accounts_pkey" PRIMARY KEY ("id")
);
-- CreateTable
CREATE TABLE "sessions" (
"id" SERIAL NOT NULL,
"session_token" TEXT NOT NULL,
"user_id" INTEGER NOT NULL,
"expires" TIMESTAMP(3) NOT NULL,
CONSTRAINT "sessions_pkey" PRIMARY KEY ("id")
);
-- CreateTable
CREATE TABLE "users" (
"id" SERIAL NOT NULL,
"name" TEXT,
"surname" TEXT,
"address" TEXT,
"zipCode" INTEGER,
"phoneNumber" INTEGER,
"email" TEXT,
"email_verified" TIMESTAMP(3),
"image" TEXT,
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updated_at" TIMESTAMP(3) NOT NULL,
"role" "Role" NOT NULL DEFAULT 'USER',
CONSTRAINT "users_pkey" PRIMARY KEY ("id")
);
-- CreateTable
CREATE TABLE "TicketsRestants" (
"id" SERIAL NOT NULL,
"total" INTEGER NOT NULL,
CONSTRAINT "TicketsRestants_pkey" PRIMARY KEY ("id")
);
-- CreateTable
CREATE TABLE "Gain" (
"id" SERIAL NOT NULL,
"codeCadeau" TEXT NOT NULL,
"dateRetrait" TIMESTAMP(3),
"produitId" INTEGER,
"userId" INTEGER,
"actif" BOOLEAN NOT NULL DEFAULT true,
CONSTRAINT "Gain_pkey" PRIMARY KEY ("id")
);
-- CreateTable
CREATE TABLE "Produit" (
"id" SERIAL NOT NULL,
"actif" BOOLEAN,
"nomProduit" TEXT,
"prixTtc" INTEGER,
CONSTRAINT "Produit_pkey" PRIMARY KEY ("id")
);
-- CreateTable
CREATE TABLE "verificationtokens" (
"identifier" TEXT NOT NULL,
"token" TEXT NOT NULL,
"expires" TIMESTAMP(3) NOT NULL
);
-- CreateIndex
CREATE UNIQUE INDEX "accounts_provider_provider_account_id_key" ON "accounts"("provider", "provider_account_id");
-- CreateIndex
CREATE UNIQUE INDEX "sessions_session_token_key" ON "sessions"("session_token");
-- CreateIndex
CREATE UNIQUE INDEX "users_email_key" ON "users"("email");
-- CreateIndex
CREATE UNIQUE INDEX "Gain_codeCadeau_key" ON "Gain"("codeCadeau");
-- CreateIndex
CREATE UNIQUE INDEX "verificationtokens_token_key" ON "verificationtokens"("token");
-- CreateIndex
CREATE UNIQUE INDEX "verificationtokens_identifier_token_key" ON "verificationtokens"("identifier", "token");
-- AddForeignKey
ALTER TABLE "accounts" ADD CONSTRAINT "accounts_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "sessions" ADD CONSTRAINT "sessions_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "Gain" ADD CONSTRAINT "Gain_produitId_fkey" FOREIGN KEY ("produitId") REFERENCES "Produit"("id") ON DELETE SET NULL ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "Gain" ADD CONSTRAINT "Gain_userId_fkey" FOREIGN KEY ("userId") REFERENCES "users"("id") ON DELETE SET NULL ON UPDATE CASCADE;
+3
View File
@@ -0,0 +1,3 @@
# Please do not edit this file manually
# It should be added in your version-control system (i.e. Git)
provider = "postgresql"
+9 -8
View File
@@ -53,7 +53,7 @@ model User {
updatedAt DateTime @updatedAt @map(name: "updated_at")
accounts Account[]
sessions Session[]
gain Gain[]
gains Gain[]
role Role @default(USER)
@@map(name: "users")
@@ -72,21 +72,22 @@ model Gain {
produitId Int?
user User? @relation(fields: [userId], references: [id])
userId Int?
actif Boolean @default(true)
codeActif Boolean @default(true)
retrait Boolean @default(false)
}
model Produit {
id Int @id @default(autoincrement())
actif Boolean?
nomProduit String?
prixTtc Int?
image String?
id Int @id @default(autoincrement())
nomProduit String?
prixTtc Int?
image String?
description String?
refGain Gain[]
refGain Gain[]
}
enum Role {
USER
SELLER
ADMIN
SUPERADMIN
}
+10 -10
View File
@@ -3,7 +3,7 @@ import { PrismaClient } from '@prisma/client';
import { generateGains } from './seed/gains'
import { produitsData } from './seed/produits'
// import { userData } from './seed/user'
import { userData } from './seed/user'
const prisma = new PrismaClient();
@@ -29,16 +29,16 @@ async function main() {
/////////////////////////////////////////////////////
//création des utilisateurs
// for (const u of userData) {
// const user = await prisma.user.create({
// data: u,
// })
// console.log(`Created user with id: ${user.id}`)
// }
// création des utilisateurs
for (const u of userData) {
const user = await prisma.user.create({
data: u,
})
console.log(`Created user with id: ${user.id}`)
}
//création de 5 gains
for (let i = 1; i <= 5; i++) {
//création de gains
for (let i = 1; i <= (50); i++) {
await generateGains();
}
+2
View File
@@ -13,6 +13,8 @@ export const generateGains = async () => {
const gainCreated = await prisma.gain.create({
data: {
codeCadeau: randomNoGain,
codeActif: true,
retrait: false
}
})
+30 -30
View File
@@ -1,33 +1,33 @@
import { Prisma } from "@prisma/client";
export const produitsData: Prisma.ProduitCreateInput[] = [
{
nomProduit: 'Grand coffret découverte',
prixTtc: 69,
image: '/images/coffret-degustation.webp',
description: "Une version XXL de notre fameux coffret découverte. Faites découvrir à vos invités leur saveur de thé préféré !"
},
{
nomProduit: 'Coffret découverte',
prixTtc: 39,
image: '/images/coffret-degustation2.webp',
description: "Ce coffret élégant vous permettra de découvrir les différentes saveurs de la gamme de Thé Tip Top. Offrez à votre palais de nouveaux horizons de saveurs. Découvrez avec ce coffret votre parfum préféré !"
},
{
nomProduit: 'Thé signature',
prixTtc: 10,
image: '/images/the-signature.webp',
description: "Le grand incontournable de notre gamme, le thé signature représente ce que Thé Tip Top souhaite vous transmettre : plus qu'un goût subtil et savoureux, c'est une expérience de saveur qui s'ouvre à vous !"
},
{
nomProduit: 'Thé détox',
prixTtc: 6,
image: '/images/the-detox.webp',
description: "Notre thé détox soutient l’élimination des déchets et purifie le corps des toxines accumulées. Il lutte contre la rétention d’eau. Pour chasser les toxines, il n’y a pas mieux !"
},
{
nomProduit: 'Infuseur à thé',
prixTtc: 3,
image: '/images/infuseur.webp',
description: "Préparer un bon thé chaud ou glacé de façon rapide et ludique. Profiter d'une infusion parfaite : L’infuseur permet aux feuilles de thé de se déployer librement, pleinement et de libérer ainsi toutes les molécules aromatiques au contact de l’eau. "
}]
{
nomProduit: 'Grand coffret découverte',
prixTtc: 69,
image: '/images/coffret-degustation.webp',
description: "Une version XXL de notre fameux coffret découverte. Faites découvrir à vos invités leur saveur de thé préféré !"
},
{
nomProduit: 'Coffret découverte',
prixTtc: 39,
image: '/images/coffret-degustation2.webp',
description: "Ce coffret élégant vous permettra de découvrir les différentes saveurs de la gamme de Thé Tip Top. Offrez à votre palais de nouveaux horizons de saveurs. Découvrez avec ce coffret votre parfum préféré !"
},
{
nomProduit: 'Thé signature',
prixTtc: 10,
image: '/images/the-signature.webp',
description: "Le grand incontournable de notre gamme, le thé signature représente ce que Thé Tip Top souhaite vous transmettre : plus qu'un goût subtil et savoureux, c'est une expérience de saveur qui s'ouvre à vous !"
},
{
nomProduit: 'Thé détox',
prixTtc: 6,
image: '/images/the-detox.webp',
description: "Notre thé détox soutient l’élimination des déchets et purifie le corps des toxines accumulées. Il lutte contre la rétention d’eau. Pour chasser les toxines, il n’y a pas mieux !"
},
{
nomProduit: 'Infuseur à thé',
prixTtc: 3,
image: '/images/infuseur.webp',
description: "Préparer un bon thé chaud ou glacé de façon rapide et ludique. Profiter d'une infusion parfaite : L’infuseur permet aux feuilles de thé de se déployer librement, pleinement et de libérer ainsi toutes les molécules aromatiques au contact de l’eau. "
}]
+10 -35
View File
@@ -4,44 +4,19 @@ export const userData: Prisma.UserCreateInput[] = [
{
name: 'Alice',
email: 'alice@prisma.io',
posts: {
create: [
{
title: 'Join the Prisma Slack',
content: 'https://slack.prisma.io',
published: true,
},
],
},
createdAt: new Date(),
role: 'USER'
},
{
name: 'Nilu',
email: 'nilu@prisma.io',
posts: {
create: [
{
title: 'Follow Prisma on Twitter',
content: 'https://www.twitter.com/prisma',
published: true,
},
],
},
name: 'John',
email: 'john@prisma.io',
createdAt: new Date(),
role: 'SELLER'
},
{
name: 'Mahmoud',
email: 'mahmoud@prisma.io',
posts: {
create: [
{
title: 'Ask a question about Prisma on GitHub',
content: 'https://www.github.com/prisma/prisma/discussions',
published: true,
},
{
title: 'Prisma on YouTube',
content: 'https://pris.ly/youtube',
},
],
},
name: 'Mosse',
email: 'mosse@prisma.io',
createdAt: new Date(),
role: 'USER'
},
]
Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 61 KiB

+3
View File
@@ -0,0 +1,3 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="48" height="48" viewBox="0 0 48 48">
<image id="Calque_3" data-name="Calque 3" x="-12" y="-10" width="68" height="68" xlink:href="data:img/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEQAAABECAYAAAA4E5OyAAAHMklEQVR4nO2ba3ATVRTH//dustm0TSEgbSkolrdaWnwBHR84ltcwoNZiGAHFQR0VHR8joqhov4hURlERXzMKlqqAAkZHOooI4gOEsQo6gA9AxLaAtU1baLNJdtfZijy2SbN396bUIb+ZfNmcc+7Zf+7j3LsbAmAugAlIotPgADAYwLCkHK00UwChTpBIZ6GFnukKGEkKYiApiIGkIAaSghhICmLAcboTIE7AkU5AXeT4NaVZg9KkQVM6Ph9mQWavTiUmzGKy6nl50LkjHbsz+1J4uxKk6KJoba01AhzVgLp6DQd/UbFvQ7jX5Eekajtt6zxz/dEorZ2gQ3rIWw+3SHlTxVn9hwgjiu93Cce/aCc1XaQ0AGlegnOGCxg2XFhYryD881Zl04gC4fVE5ZpQQZY81OIcdqdr3s3PuHOJhnE2w/m8AjCiQHCGKcb8tF359sIhwgJOqR4nYYJ8uT4yY9qz7slOFWPa6wkW8DlV4MIhghKkeP/LVeE3Rxc51/IKnhBBqhq1t68odHSDLkbi8EkqMLrIqew5qBb2y6IP8miJ67K7ckEwp5mgolc66QbYHiJm8fXLor0DCsqXPRpMsRuMmyAfvREqmDRbejnl37mio8T4D19XAVNvmC+VrSgNnm0nEBdBVi+ScyfeKj5B7U+ctpBUFBfNkRaWPxFMtxrHtiD6kjrhPtezp6FXREVUUTyxRHrNqr9tQcaWSGViYidPZrpQ0D2H1IVWfG0JsmWzcl+Wm3i43AVffP0yafa6NeHxrFEtL7vlJcFu00okrhOop+dgDO4xCmen5sFNo08DG2peQfXeL8yE840sdgpQwVSjWBbkspliKS8xSFoabsh7CT2lgcjukteu7Zba5abjiiqUHbvUR/POo/PM+lgaMsufCmbnZNDeVnyNaJKIuy75EBdnToorho6qRVjC+3LPp/lLZ5k/O7YkSP5UcRav3jEq93H08SbuKQjV4Mu9UbzHtL2VRvr3pRdY8TNCPB7kpo/iEapdBl0kFJi1ZRak4u1woVOFyiPRrLOGmhomJ+OgEnM7HgK66gV5oKn4rMEHFgqfMWcUg96e/Ha//zPwPXY2bUAgVANFjYAQipqGHVaa8uVc5fgWwHPxDJkFycjktx/sIfWN+d3aP+Zj4/Z5IBEunRE9+9PzzNgx3R2hQArH/bFI3VGvHwhUYuNPpdzE0OnuIV4zdky35+xBIHA87Ik1FVW17ASRw/waOlaTlD0WTItnxySIyHG4tEdj5K9EhPW5u5OmeEZMd+joauvA3TRqgp4/SF3i58/2k3PWQ4tRdapgqkbNYyJ/tlXGgiDEk46U1IxTrmnQIBAnuorZUX0yXH2RmjWgVZpojQaD9VACf7MnYwImQdQj7DNqXp9JmDLgRSafSzJ9rZ9YLN19O3YF3mXOJdQUP3+mIRM6zC6IrBxh9onHgcB3Vtz8LfVat3hGbILU8KsL7NB89DCzd4SCTiuR6uPZMQmihoHmjlloYlLdsANKS9zVsw0NMprN2DEXFnUBvo/hWDks7wUJsy/LB/erv5qxYxZkzxa2ZJwxynOrHAyaui8j/v2bI+vMGDJv7n7/PCyNHOso0ys/M/Y7fnsHcw74T7mmL7uUOuC74AUMzbiujc/mmmX4cOecY68HnDpGFbmZefWXKej4m8RNZmyZBZle6pb/bNACvU1UfTr6nkSVA22u6/3sSCR6LVEfroba2NYHFmvDffvUnwf3MTcYLG1OKt8L6w+CVlrxPRlCov8eFEIsFyv4vy8PxT0HOdG2Ba65TaysDWkyz6wTxf467dCNj0k1CRVE56slrarb7iUJxv/1YnkuSxOWBbnuDtcPv1ar+zuxKP7K7crmKXMlpirO1gHHgGw6u+U0F2qx0N9HuyhfKGX1s33iU7FILulsvUQh8FfMC95txde2INff49q1aV1kTScSxV+xNLSAdaj8B5czwStHO5Zv26Zs6gSi+D//KFI2Ybr4tdUA3A5JL71UWPzFp5FVp0sUlcD/cVlowdUTHavtxOH6FuLIMY6VH7wm/zLuLpcgqa3FqKny3ib+Jg3K2vnBeyc/IlXZDcb9GF1fjiUVk/Yd1qo7oLf4d/2u7vYQFPMQA4l8cTcngzywdlno8oIpYtgrwMm5t/gPBdH8zZvy00UzXT9yjJvYV7vH3yR+pRe1n6wIFw691tmSKcF9sjACib5noSRmx/VXNWp1le+HX504Q9xaNNPFPecOefl/7GTnegDry0uC3gHjnOv75NPh3lTaRVO0K/VHvEZ7cmJP6w8SoK5Rq9uzTdm499PIiunzJbnXDDFhueotLwFwi1kHu38POZmKJ3O8ostV5/AQCJ5jYTUgpXstDjVV4e/flB7TnpRqebWH+H8PaT2PWHLsJOaM/wCoTf7FzEBSEANJQQwkBTGQFMRAUhADSUEM6IIkruz7/+HWS/fdALae6Uq0AjT8A7T9bClX8xf2AAAAAElFTkSuQmCC"/>
</svg>

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 497 KiB

File diff suppressed because it is too large. Load diff

After

Width:  |  Height:  |  Size: 3.6 MiB

+9
View File
@@ -0,0 +1,9 @@
.footer-separator{
height:100px;
}
@media (min-width: 992px) {
.footer-separator{
height:50vh;
}
}
+4
View File
@@ -9,6 +9,10 @@
z-index: 8888
}
.cursor:hover {
cursor: pointer;
}
.imageWrapper {
display: block;
}
+3 -2
View File
@@ -91,6 +91,7 @@
}
@keyframes blinking {
0%,
50%,
100% {
@@ -113,7 +114,7 @@
.aButton {
position: relative;
z-index: 9992;
z-index: 9000;
}
.aButton:after {
@@ -276,4 +277,4 @@
50% {
right: 0;
}
} */
} */
+34
View File
@@ -0,0 +1,34 @@
.wrapper {
width: 100%;
height: 100vh;
position: absolute;
top: 0;
left: 0;
background-color: rgb(0, 0, 0, 0.3);
backdrop-filter: blur(10px);
display: flex;
justify-content: center;
align-items: center;
z-index: 9999;
}
/*code for custom loading icon*/
.loader {
border: 10px solid #f3f3f3;
border-radius: 50%;
border-top: 10px solid #505050;
width: 60px;
height: 60px;
animation: spin 2s linear infinite;
}
@keyframes spin {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
+3 -4
View File
@@ -17,7 +17,6 @@
/**************************/
.overlay {
height: 0;
width: 100%;
bottom: 100%;
position: fixed;
@@ -36,14 +35,14 @@
.overlay-content {
position: relative;
top: 25%;
height: 90%;
top: 10px;
width: 100%;
text-align: center;
margin-top: 30px;
margin-top: 5px;
display: flex;
flex-direction: column;
align-items: center;
margin-top: 20vh;
}
.overlay a {
+15 -10
View File
@@ -1,26 +1,31 @@
.aCard {
/* width:200px; */
max-width:300px;
max-width: 300px;
}
.aCard img {
width:fit-content;
width: fit-content;
block-size: -moz-fit-content;
max-width: 100%;
}
.aCard img, .grosLot img {
height:fit-content;
}
.aCard img,
.grosLot img {
border-radius:0.375rem;
height: fit-content;
}
@media (min-width: 992px){
.explicationContainer{
--padding-x:15%;
.grosLot img {
border-radius: 0.375rem;
}
@media (min-width: 992px) {
.explicationContainer {
--padding-x: 15%;
padding-left: var(--padding-x);
padding-right: var(--padding-x);
}
.aCard div {
.aCard div {
min-height: 205px;
}
}
+10 -9
View File
@@ -8,7 +8,7 @@ body {
font-size: small;
}
body{
body {
background-image: url(/images/pageprincipale.webp);
background-size: cover;
background-position: 50% 50%;
@@ -16,21 +16,22 @@ body{
background-attachment: fixed;
}
@media (min-width: 992px){
@media (min-width: 992px) {
html,
body{
body {
font-size: medium;
}
}
.layout-container{
display : table;
.layout-container {
display: table;
width: 100%;
position:relative;
min-height:100vh;
position: relative;
min-height: 100vh;
}
.body-content{
.body-content {
display: table-row-group;
}
@@ -64,6 +65,6 @@ a:hover {
--bs-btn-disabled-border-color: var(--color2);
}
.link {
.link {
text-decoration: underline;
}
+14
View File
@@ -0,0 +1,14 @@
// e2e/example.spec.ts
import { test, expect } from '@playwright/test'
test('navigate to /contact and check if h1 contains "Contactez nous"', async ({ page }) => {
// Start from the index page (the baseURL is set via the webServer in the playwright.config.ts)
await page.goto('http://localhost:3000/')
// Find an element with the text 'About Page' and click on it
await page.click('text=Contactez-nous')
// The new URL should be "/about" (baseURL is used there)
await expect(page).toHaveURL('http://localhost:3000/contact')
// The new page should contain an h1 with "About Page"
await expect(page.locator('h1')).toContainText('Contactez nous')
})
+2 -1
View File
@@ -5,5 +5,6 @@ export type UserGainProps = {
dateRetrait: Date;
produit: Produit;
produitId: number;
actif: Boolean;
codeActif: true,
retrait: false
}