Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
401935d703 | ||
|
|
eda530cce6 | ||
|
|
60d701ac07 | ||
|
|
34700a46d9 | ||
|
|
87490d6263 | ||
|
|
10e415e53e | ||
|
|
deb3cc922b | ||
|
|
98dc6c4f64 | ||
|
|
9ed7de368f | ||
|
|
ffc2cb37a2 | ||
|
|
1d6abb05c1 | ||
|
|
a52be8bcad | ||
|
|
79e056ac08 | ||
|
|
fc1e689469 | ||
|
|
b94d908339 | ||
|
|
d892c502d1 | ||
|
|
77ddf98216 | ||
|
|
d0c86bfb19 | ||
|
|
9f890c8da2 | ||
|
|
ab65fae880 | ||
|
|
d9c1de36a9 | ||
|
|
caffe2c1b8 | ||
|
|
a3b0c85678 | ||
|
|
8d0d846e6c | ||
|
|
3ea56473aa | ||
|
|
000a32187b | ||
|
|
1b3f5328b0 | ||
|
|
9e70d7b16f | ||
|
|
a1388c6962 | ||
|
|
230e758598 | ||
|
|
f1a9f5e2f4 | ||
|
|
29b2409643 | ||
|
|
e73c965078 | ||
|
|
fa394760ac | ||
|
|
8f4bda3b2e | ||
|
|
c8c515e8e0 | ||
|
|
9fb00a7bbf | ||
|
|
5321b49948 | ||
|
|
2a0515d7cc | ||
|
|
d46dbc1b5a | ||
|
|
0b7987c325 | ||
|
|
665813c5ce | ||
|
|
c0754c4800 | ||
|
|
3150580fb5 | ||
|
|
f16bf70477 | ||
|
|
0b1a2bd670 | ||
|
|
5b0a6c1d65 | ||
|
|
4fd2e6a12b | ||
|
|
6ba0a247c9 | ||
|
|
9b07b1e950 | ||
|
|
964663ea5a | ||
|
|
df86536e9e | ||
|
|
31a31cc7ef | ||
|
|
a04a6d013e | ||
|
|
90633e6f0e | ||
|
|
b59924c83e | ||
|
|
3bb58dda42 | ||
|
|
fbcc5b56be | ||
|
|
9d0579a662 | ||
|
|
3874be66b0 | ||
|
|
ebb7557763 | ||
|
|
9ff3e5de60 | ||
|
|
5d0cfb2d20 | ||
|
|
755aed38d6 | ||
|
|
24cca03a10 | ||
|
|
71871f21a6 | ||
|
|
f843ee972c | ||
|
|
b20c1327e2 | ||
|
|
69027e8436 | ||
|
|
7d490ac360 | ||
|
|
3270b44f1d | ||
|
|
bc0df4bd35 | ||
|
|
38bb178f6d | ||
|
|
4a9afcc6a7 | ||
|
|
f654da8a20 | ||
|
|
29f89e98d0 | ||
|
|
47662e3ada | ||
|
|
55494f6d99 | ||
|
|
c25ab4a0ab | ||
|
|
8d1c96939e | ||
|
|
a73c807689 | ||
|
|
daa1589d82 | ||
|
|
5440b0525b | ||
|
|
b71f368a85 | ||
|
|
f9c05dce97 | ||
|
|
9173d0b44e | ||
|
|
57d1bac326 | ||
|
|
1485bd0b52 | ||
|
|
71cffa5499 | ||
|
|
4e50489d75 | ||
|
|
688f74d157 | ||
|
|
1a5843ad73 | ||
|
|
8871df3582 | ||
|
|
95a2de9c26 | ||
|
|
4158758606 | ||
|
|
606e9be03d | ||
|
|
e807356302 | ||
|
|
f414bb32ea | ||
|
|
32ebd59467 | ||
|
|
b19d1c2efe | ||
|
|
13c7f85110 | ||
|
|
e066b631e1 | ||
|
|
0a50ebe952 | ||
|
|
641df2cf51 | ||
|
|
85ade3016b | ||
|
|
108193f202 | ||
|
|
4e404bcb9d | ||
|
|
cf18d19aa6 | ||
|
|
3de3355a13 | ||
|
|
39e2ed4fce | ||
|
|
ed9c87903e | ||
|
|
27187c6c68 | ||
|
|
251454c403 | ||
|
|
6a10740307 | ||
|
|
a73958e500 | ||
|
|
a63e6de1f0 | ||
|
|
67a84d9819 | ||
|
|
4e97b2b6db | ||
|
|
426d4a5fc1 | ||
|
|
3d8f792d7e | ||
|
|
cce6fa777d | ||
|
|
e3ede7484e | ||
|
|
0b9bbe44d6 | ||
|
|
f59662740f | ||
|
|
9d41546603 | ||
|
|
cb95d93831 | ||
|
|
65efdcac94 | ||
|
|
5927d8e937 | ||
|
|
7827aa119f | ||
|
|
99ac2e0b79 | ||
|
|
fec63499c6 | ||
|
|
ed18731eb4 | ||
|
|
ef7fbf4636 | ||
|
|
1e8b08fa11 | ||
|
|
8224592c0e | ||
|
|
04423aa6c7 | ||
|
|
7a73849f99 | ||
|
|
b4cb8dbe8b | ||
|
|
769d441270 | ||
|
|
7d7d583ad9 | ||
|
|
811c6d362b | ||
|
|
d480a3f8b2 | ||
|
|
585781a9c7 | ||
|
|
e6a7428158 | ||
|
|
f1d1aa30d7 | ||
|
|
50d64b513b | ||
|
|
1a917e2347 | ||
|
|
374d35b449 | ||
|
|
c84194b7b9 | ||
|
|
e5f3ae3e82 | ||
|
|
cb847b8ed9 | ||
|
|
8f9ff8fc74 | ||
|
|
77db425b0e | ||
|
|
9e959f5ac6 | ||
|
|
dfa67f86d5 | ||
|
|
e85117b2c7 | ||
|
|
141d9e53e8 | ||
|
|
fd4dc77603 | ||
|
|
38159b90c1 | ||
|
|
ae437a097b | ||
|
|
6857e301fa |
No files matched your search
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"env": {
|
||||
"development": {
|
||||
"presets": ["next/babel"]
|
||||
},
|
||||
"production": {
|
||||
"presets": ["next/babel"]
|
||||
},
|
||||
"test": {
|
||||
"presets": ["@babel/env", "@babel/react"]
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,20 +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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
|
||||
|
||||
DATABASE_URL="postgres://postgres:postgrespwd@localhost:5432/thetiptop"
|
||||
GOOGLE_CLIENT_ID=965228443747-049kq59pm43bd23aplfu9ja2333dpo5s.apps.googleusercontent.com
|
||||
GOOGLE_CLIENT_SECRET=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
|
||||
|
||||
# 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"
|
||||
|
||||
API_KEY=1234
|
||||
ACTIVATION_API=true
|
||||
|
||||
|
||||
|
||||
@@ -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" ]
|
||||
@@ -0,0 +1,55 @@
|
||||
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
|
||||
|
||||
" > ./.env
|
||||
cat ./.env'''
|
||||
}
|
||||
}
|
||||
|
||||
stage('Build') {
|
||||
steps {
|
||||
sh '''npm install
|
||||
npm run build
|
||||
npm start & sleep 1'''
|
||||
}
|
||||
}
|
||||
|
||||
stage('Test') {
|
||||
steps {
|
||||
sh 'npm test & sleep 1'
|
||||
}
|
||||
}
|
||||
|
||||
stage('Deliver') {
|
||||
steps {
|
||||
sh '''chmod +x ./scripts/deliver.sh
|
||||
./scripts/deliver.sh'''
|
||||
input 'Finished using the web site? (Click "Proceed")'
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
tools {
|
||||
nodejs 'Node 16.18'
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
|
||||
***********************************
|
||||
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import Image from 'next/image'
|
||||
import logo from '../public/images/logo.webp';
|
||||
import logoInstagram from '../public/images/logo instagram.webp';
|
||||
import logoLinkedin from '../public/images/logo linkedin.webp';
|
||||
import logoFacebook from '../public/images/png/logo_facebook.png';
|
||||
import style from '../styles/Footer.module.css'
|
||||
|
||||
import Link from 'next/link';
|
||||
@@ -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">
|
||||
<Image src={logoInstagram} alt="lien instagram" width="40"
|
||||
height="40" />
|
||||
<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"
|
||||
height="40" />
|
||||
<Link href="https://www.facebook.com/profile.php?id=100088390638593" legacyBehavior><a className={style.link} >
|
||||
<Image src={logoFacebook} 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-lg-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>
|
||||
|
||||
@@ -2,6 +2,8 @@ import React, { ReactNode } from "react";
|
||||
import NavBar from "./NavBar";
|
||||
import Footer from "./Footer";
|
||||
|
||||
import CookieConsent from "react-cookie-consent";
|
||||
|
||||
type Props = {
|
||||
children?: React.ReactNode;
|
||||
};
|
||||
@@ -10,6 +12,11 @@ const Layout = ({ children }: Props) =>
|
||||
<div className="layout-container">
|
||||
<NavBar />
|
||||
{children}
|
||||
<CookieConsent
|
||||
buttonText="Je comprends"
|
||||
style={{ zIndex: "100000", justifyContent:"center" }}
|
||||
buttonStyle={{color:"white",background:"#76AE0D"}}>
|
||||
Ce site web utilise des cookies pour améliorer l'expérience de l'utilisateur.</CookieConsent>
|
||||
<Footer />
|
||||
</div>
|
||||
|
||||
|
||||
@@ -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;
|
||||
@@ -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,63 +27,62 @@ const NavBar = () => {
|
||||
signOut()
|
||||
}
|
||||
|
||||
const checkRole = () => {
|
||||
const isAdmin = ['SELLER', 'ADMIN', 'SUPERADMIN'].includes(session?.user['role']);
|
||||
console.log('isAdmin', isAdmin);
|
||||
console.log('role', 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">
|
||||
<Link href="/" legacyBehavior><a>
|
||||
<Image
|
||||
src={logo}
|
||||
alt="thetiptop navigation logo big"
|
||||
width={250}
|
||||
height={100}
|
||||
/>
|
||||
</a></Link>
|
||||
</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}>☰</span>
|
||||
</div>
|
||||
|
||||
<div className="d-flex justify-content-center">
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div ref={navRef} className={style.overlay} onClick={closeNav}>
|
||||
|
||||
<a className={style.closebtn} onClick={closeNav}>×</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="/" 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>}
|
||||
<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>}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</nav>
|
||||
|
||||
)
|
||||
|
||||
return (<>
|
||||
{visitor}
|
||||
</>)
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
export default NavBar;
|
||||
@@ -1,33 +0,0 @@
|
||||
import React from "react";
|
||||
import Router from "next/router";
|
||||
import ReactMarkdown from "react-markdown";
|
||||
|
||||
export type PostProps = {
|
||||
id: number;
|
||||
title: string;
|
||||
author: {
|
||||
name: string;
|
||||
email: string;
|
||||
} | null;
|
||||
content: string;
|
||||
published: boolean;
|
||||
};
|
||||
|
||||
const Post = ( {post} : {post : PostProps}) => {
|
||||
const authorName = post.author ? post.author.name : "Unknown author";
|
||||
return (
|
||||
<div onClick={() => Router.push("/p/[id]", `/p/${post.id}`)}>
|
||||
<h2>{post.title}</h2>
|
||||
<small>By {authorName}</small>
|
||||
<ReactMarkdown children={post.content} />
|
||||
<style jsx>{`
|
||||
div {
|
||||
color: inherit;
|
||||
padding: 2rem;
|
||||
}
|
||||
`}</style>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default Post;
|
||||
@@ -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
|
||||
@@ -0,0 +1,5 @@
|
||||
import { useContext } from 'react';
|
||||
|
||||
import { GlobalContext } from './globalContext';
|
||||
|
||||
export const useGlobalContext = () => useContext(GlobalContext);
|
||||
@@ -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')
|
||||
})
|
||||
@@ -1,5 +1,6 @@
|
||||
export enum Role {
|
||||
USER = 'USER',
|
||||
ADMIN = 'ADMIN',
|
||||
SELLER = 'SELLER',
|
||||
SUPERADMIN = 'SUPERADMIN'
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
const nextJest = require('next/jest')
|
||||
|
||||
const createJestConfig = nextJest({
|
||||
dir: './',
|
||||
})
|
||||
|
||||
const customJestConfig = {
|
||||
setupFilesAfterEnv: ['<rootDir>/jest.setup.js'],
|
||||
moduleDirectories: ['node_modules', '<rootDir>/'],
|
||||
testEnvironment: 'jest-environment-jsdom',
|
||||
testRegex: '(/__tests__/.*|(\\.|/)(test))\\.[jt]sx?$'
|
||||
}
|
||||
|
||||
module.exports = createJestConfig(customJestConfig)
|
||||
@@ -0,0 +1,6 @@
|
||||
// Optional: configure or set up a testing framework before each test.
|
||||
// If you delete this file, remove `setupFilesAfterEnv` from `jest.config.js`
|
||||
|
||||
// Used for __tests__/testing-library.js
|
||||
// Learn more: https://github.com/testing-library/jest-dom
|
||||
import '@testing-library/jest-dom/extend-expect'
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"name": "hello-next",
|
||||
"name": "thetiptop",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"keywords": [],
|
||||
@@ -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",
|
||||
@@ -18,28 +19,46 @@
|
||||
"@types/nodemailer": "^6.4.6",
|
||||
"bootstrap": "^5.2.2",
|
||||
"chance": "^1.1.9",
|
||||
"chart.js": "^4.0.1",
|
||||
"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",
|
||||
"nodemailer": "^6.8.0",
|
||||
"react": "18.2.0",
|
||||
"react-chartjs-2": "^5.0.1",
|
||||
"react-cookie-consent": "^8.0.1",
|
||||
"react-dom": "18.2.0",
|
||||
"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",
|
||||
"@testing-library/dom": "^8.19.0",
|
||||
"@testing-library/jest-dom": "^5.16.5",
|
||||
"@testing-library/react": "^13.4.0",
|
||||
"@testing-library/user-event": "^14.4.3",
|
||||
"@tomfreudenberg/next-auth-mock": "^0.5.5",
|
||||
"@types/chance": "^1.1.3",
|
||||
"@types/dateformat": "^5.0.0",
|
||||
"@types/jest": "^29.2.4",
|
||||
"@types/next-auth": "3.13.0",
|
||||
"@types/node": "18.11.9",
|
||||
"@types/react": "18.0.25",
|
||||
"@types/node": "^18.11.9",
|
||||
"@types/react": "^18.0.25",
|
||||
"babel-jest": "^29.3.1",
|
||||
"jest": "^29.3.1",
|
||||
"jest-environment-jsdom": "^29.3.1",
|
||||
"prisma": "^4.6.1",
|
||||
"supertest": "^6.3.3",
|
||||
"ts-node": "10.9.1",
|
||||
"typescript": "4.8.4"
|
||||
"typescript": "^4.8.4"
|
||||
},
|
||||
"prisma": {
|
||||
"seed": "ts-node prisma/seed.ts"
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
import React from "react";
|
||||
import Head from "next/head";
|
||||
import style from '../styles/404.module.css'
|
||||
import Script from "next/script";
|
||||
|
||||
const NotFound = () => {
|
||||
|
||||
return (
|
||||
<>
|
||||
<>
|
||||
<Head>
|
||||
<title>Page introuvable</title>
|
||||
<meta name="description" content="Page introuvable" />
|
||||
@@ -16,13 +17,30 @@ const NotFound = () => {
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossOrigin="" />
|
||||
</Head>
|
||||
{/* backgroundImagePath={'/images/ugh.png'} */}
|
||||
<div className="body-content position-relative">
|
||||
<div className="position-absolute top-50 start-50 translate-middle">
|
||||
<h1 className="">Page introuvable</h1>
|
||||
<h4 className="fw-light">La page recherchée n'existe pas.</h4>
|
||||
</div>
|
||||
<Script async src="https://www.googletagmanager.com/gtag/js?id=G-QNZD85D13X"></Script>
|
||||
<Script>
|
||||
{`
|
||||
window.dataLayer = window.dataLayer || [];
|
||||
function gtag(){dataLayer.push(arguments);}
|
||||
gtag('js', new Date());
|
||||
|
||||
gtag('config', 'G-QNZD85D13X');
|
||||
`}
|
||||
</Script>
|
||||
<Script>{`(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
|
||||
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
|
||||
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
|
||||
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
|
||||
})(window,document,'script','dataLayer','GTM-MMHM9HX');`}</Script>
|
||||
|
||||
{/* backgroundImagePath={'/images/ugh.png'} */}
|
||||
<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'existe pas.</h4>
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -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,35 @@ 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>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
@@ -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.`
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -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' })
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
@@ -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;
|
||||
@@ -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;
|
||||
@@ -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;
|
||||
@@ -0,0 +1,509 @@
|
||||
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";
|
||||
import { Doughnut } from "react-chartjs-2";
|
||||
import {
|
||||
Chart as ChartJS,
|
||||
CategoryScale,
|
||||
LinearScale,
|
||||
BarElement,
|
||||
Title,
|
||||
Tooltip,
|
||||
Legend,
|
||||
} from 'chart.js';
|
||||
import { Bar } from 'react-chartjs-2';
|
||||
|
||||
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 ticketRestants = await prisma.gain.count({
|
||||
where: {
|
||||
dateAchat: {
|
||||
not: null,
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
const ticketsSaisis = await prisma.gain.count({
|
||||
where: {
|
||||
codeActif: false,
|
||||
},
|
||||
})
|
||||
|
||||
const gainsRetires = await prisma.gain.count({
|
||||
where: {
|
||||
retrait: true
|
||||
},
|
||||
})
|
||||
|
||||
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)),
|
||||
ticketRestants: JSON.parse(JSON.stringify(ticketRestants)),
|
||||
ticketsSaisis: JSON.parse(JSON.stringify(ticketsSaisis)),
|
||||
gainsRetires: JSON.parse(JSON.stringify(gainsRetires)),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
type Props = {
|
||||
user: User;
|
||||
produits: Produit[];
|
||||
users: any,
|
||||
ticketRestants: number,
|
||||
ticketsSaisis: number,
|
||||
gainsRetires: number,
|
||||
}
|
||||
|
||||
|
||||
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 [query, setQuery] = useState("");
|
||||
const router = useRouter()
|
||||
|
||||
|
||||
const isAdmin = session?.user['role'] === Role.ADMIN
|
||||
const isSuperAdmin = session?.user['role'] === Role.SUPERADMIN
|
||||
const bigWinner = users?.find((user) => user?.isBigWinner)
|
||||
|
||||
ChartJS.register(
|
||||
CategoryScale,
|
||||
LinearScale,
|
||||
BarElement,
|
||||
Title,
|
||||
Tooltip,
|
||||
Legend
|
||||
);
|
||||
|
||||
const labels = ['Tickets générés', 'Codes saisis', 'Cadeaux récupérés'];
|
||||
|
||||
const data = {
|
||||
labels: labels,
|
||||
datasets: [{
|
||||
data: [props.ticketRestants, props.ticketsSaisis, props.gainsRetires],
|
||||
backgroundColor: [
|
||||
'rgba(255, 99, 132, 0.2)',
|
||||
'rgba(255, 159, 64, 0.2)',
|
||||
'rgba(255, 205, 86, 0.2)',
|
||||
],
|
||||
borderColor: [
|
||||
'rgb(255, 99, 132)',
|
||||
'rgb(255, 159, 64)',
|
||||
'rgb(255, 205, 86)',
|
||||
],
|
||||
borderWidth: 1
|
||||
}]
|
||||
};
|
||||
|
||||
const options = {
|
||||
responsive: true,
|
||||
plugins: {
|
||||
legend: {
|
||||
display: false
|
||||
},
|
||||
title: {
|
||||
display: false,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
const numberWithSpaces = (x: number): string => {
|
||||
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, " ");
|
||||
}
|
||||
|
||||
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) {
|
||||
toastError(data.err);
|
||||
return;
|
||||
}
|
||||
toastSuccess(data.message);
|
||||
})
|
||||
}
|
||||
catch (error) {
|
||||
console.error('ERROR :', error);
|
||||
}
|
||||
}
|
||||
|
||||
const toastError = (text: string) => {
|
||||
toast.error(text, {
|
||||
position: "top-center",
|
||||
autoClose: 2000,
|
||||
hideProgressBar: false,
|
||||
closeOnClick: true,
|
||||
pauseOnHover: true,
|
||||
draggable: true,
|
||||
progress: undefined,
|
||||
theme: "light",
|
||||
});
|
||||
}
|
||||
|
||||
const toastSuccess = (text: string) => {
|
||||
toast.success(text, {
|
||||
position: "top-center",
|
||||
autoClose: 5000,
|
||||
hideProgressBar: false,
|
||||
closeOnClick: true,
|
||||
pauseOnHover: true,
|
||||
draggable: true,
|
||||
progress: undefined,
|
||||
theme: "light",
|
||||
});
|
||||
}
|
||||
|
||||
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)
|
||||
setTimeout(() => {
|
||||
router.refresh();
|
||||
}, 2000)
|
||||
};
|
||||
|
||||
const onDeleteUser = async (userEmail: string) => {
|
||||
const body = { selectedUserEmail: userEmail }
|
||||
if (props.user.email === userEmail) {
|
||||
toastError('Vous devez être déconnecté pour supprimer votre compte')
|
||||
return;
|
||||
}
|
||||
fetcher('/api/user/delete', 'DELETE', body)
|
||||
setTimeout(() => {
|
||||
router.refresh();
|
||||
}, 2000)
|
||||
};
|
||||
|
||||
const selectUser = (user: any) => {
|
||||
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)
|
||||
setTimeout(() => {
|
||||
router.refresh();
|
||||
}, 2000)
|
||||
};
|
||||
|
||||
const selectWinUser = async () => {
|
||||
const customers = users.filter((user) => user.role === 'USER')
|
||||
|
||||
if (users.length <= 0) {
|
||||
toastError("Il n'y a pas encore d'utilisateur")
|
||||
return;
|
||||
}
|
||||
|
||||
const customersWithTicket = customers.filter((user) => user.gains.length >= 1)
|
||||
|
||||
if (customersWithTicket.length <= 0) {
|
||||
toastError("Il n'y a pas encore d'utilisateurs ayant joué");
|
||||
return;
|
||||
}
|
||||
|
||||
const winUser = customersWithTicket[Math.floor(Math.random() * customersWithTicket.length)]
|
||||
const body = { selectedUserEmail: winUser.email }
|
||||
fetcher('/api/user/bigwinner', 'PUT', body)
|
||||
setTimeout(() => {
|
||||
router.refresh();
|
||||
}, 2000)
|
||||
}
|
||||
|
||||
|
||||
const searchFilter = (array: any) => {
|
||||
return array.filter((el: User) => {
|
||||
if (query === "") return props.users
|
||||
return el.email?.toLowerCase().includes(query)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
const filtered = searchFilter(props.users)
|
||||
|
||||
const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||
setQuery(e.target.value);
|
||||
}
|
||||
|
||||
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">Dashboard Administration</h1>
|
||||
<hr />
|
||||
<div className="container" style={{ width: '30vw' }}>
|
||||
<div className="row">
|
||||
<div className="col-12 justify-content-center">
|
||||
<p>Total tirages restant 📈 {numberWithSpaces(props.ticketRestants).toString()}</p>
|
||||
<Bar options={options} data={data} />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
{(isAdmin ||
|
||||
isSuperAdmin) && <div>
|
||||
<p className="fw-light">Grand jeu concours : séléctionner l'utilisateur gagnant pour les 1 an de thé</p>
|
||||
<p className="fw-light">En cliquant sur le bouton</p>
|
||||
<p className="fw-light"> 👇</p>
|
||||
<button className="btn btn-primary" disabled={users?.some((user) => user?.isBigWinner)} onClick={selectWinUser}>Séléctionner</button>
|
||||
<hr />
|
||||
</div>}
|
||||
{bigWinner ? <p>Grand gagnant 📢</p> : <p>Pas encore de gagnant tiré au sort 🤫</p>}
|
||||
<p>{bigWinner && bigWinner.email}</p>
|
||||
{users.length <= 0 && <p>Pas encore d'utilisateur</p>}
|
||||
{users.length >= 1 && <>
|
||||
<div className="input-group mb-3">
|
||||
<span className="input-group-text" id="basic-addon1">🔎</span>
|
||||
<input type="text" className="form-control" onChange={handleChange} placeholder='Rechercher un utilisateur avec son email...' aria-label="search" />
|
||||
</div>
|
||||
<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>
|
||||
{session?.user['role'] !== Role.SELLER && <th scope="col">Types</th>}
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{filtered.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.isBigWinner && '🎁'}{info.email}</td>
|
||||
{session?.user['role'] !== Role.SELLER && <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>
|
||||
{isSuperAdmin && <option value="SUPERADMIN">SuperAdmin</option>}
|
||||
</select>
|
||||
</td>}
|
||||
{session?.user['role'] !== Role.SELLER && <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 text-truncate">{currentUser?.email || 'utilisateur'} <TfiInfoAlt size={40} /></h1>
|
||||
<hr />
|
||||
{currentUser && <form onSubmit={handleSubmit(onSubmit)}>
|
||||
<div className="form-group">
|
||||
|
||||
<div className="form-group row my-1">
|
||||
<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 my-1">
|
||||
<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 my-1">
|
||||
<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 my-1">
|
||||
<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 my-1">
|
||||
<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 my-1">
|
||||
<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 <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;
|
||||
|
||||
|
||||
@@ -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: {
|
||||
@@ -47,6 +54,5 @@ const options = {
|
||||
signOut: '/mon-compte',
|
||||
error: '/auth/error', // Error code passed in query string as ?error=
|
||||
verifyRequest: '/verify-request', // (used for check email message)
|
||||
// newUser: '/auth/new-user' // New users will be directed here on first sign in (leave the property out if not of interest)
|
||||
}
|
||||
}
|
||||
@@ -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, "​.")
|
||||
|
||||
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: #006600 !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: #006600 !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
|
||||
͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏
|
||||
</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">‌</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">
|
||||
‌
|
||||
</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">‌</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: #006600; 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;
|
||||
"
|
||||
> </i><!
|
||||
[endif]-->
|
||||
<span style="mso-text-raise: 15px">Se connecter</span>
|
||||
<!--[if mso
|
||||
]><i
|
||||
style="
|
||||
letter-spacing: 24px;
|
||||
mso-font-width: -100%;
|
||||
"
|
||||
> </i><!
|
||||
[endif]-->
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<div role="separator" style="line-height: 24px">
|
||||
‌
|
||||
</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`
|
||||
}
|
||||
@@ -1,105 +0,0 @@
|
||||
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 generationGain(req: NextApiRequest, res: NextApiResponse) {
|
||||
const session = await getSession({ req })
|
||||
|
||||
//récuperation des tickets disponible
|
||||
const getTickets = await prisma.ticketsRestants.findFirst({
|
||||
where: {
|
||||
id: 1
|
||||
},
|
||||
})
|
||||
|
||||
const { total } = getTickets;
|
||||
const isTicketsAvaible = total > 0;
|
||||
|
||||
//récupération des informations de l'utilisateur connecté
|
||||
const getCurrentUser = await prisma.user.findMany({
|
||||
where: { email: session.user.email },
|
||||
})
|
||||
|
||||
//récupération du role
|
||||
const { role } = getCurrentUser[0];
|
||||
const isAdmin = role === Role.ADMIN;
|
||||
const isSuperAdmin = Role.SUPERADMIN;
|
||||
|
||||
if (session && isTicketsAvaible) {
|
||||
if (isAdmin || isSuperAdmin) {
|
||||
|
||||
//creation d'un numéro de gain aléatoire
|
||||
const gainNumber = cryptoRandomString({ length: 10, type: 'distinguishable' });
|
||||
|
||||
|
||||
//création d'un id de produit de façon pondérée
|
||||
let weightedRandomGainId = chance().weighted([
|
||||
Cadeaux.GrandCoffretDecouverte,
|
||||
Cadeaux.CoffretDecouverte,
|
||||
Cadeaux.TheSignature,
|
||||
Cadeaux.TheDetox,
|
||||
Cadeaux.Infuseur],
|
||||
[4, 6, 10, 20, 60]);
|
||||
|
||||
//création d'un gain
|
||||
const gainCreated = await prisma.gain.create({
|
||||
data: {
|
||||
codeCadeau: gainNumber,
|
||||
}
|
||||
})
|
||||
|
||||
//mise à jour du gain avec l'id de produit pondéré
|
||||
const gainResult = await prisma.gain.update({
|
||||
where: { id: gainCreated.id },
|
||||
data: {
|
||||
produitId: weightedRandomGainId,
|
||||
}
|
||||
})
|
||||
|
||||
//on retire 1 ticket
|
||||
await prisma.ticketsRestants.update({
|
||||
where: {
|
||||
id: getTickets.id
|
||||
},
|
||||
data: {
|
||||
total: {
|
||||
decrement: 1
|
||||
}
|
||||
}
|
||||
})
|
||||
res.status(200).send({ message: 'Gain has been generated !', result: gainResult });
|
||||
}
|
||||
} else {
|
||||
res.status(401).send({ message: 'Unauthorized' })
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -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/setadmin/make-admin?pass=******** (a effacer)
|
||||
|
||||
export default async function makeMeAdmin(req: NextApiRequest, res: NextApiResponse) {
|
||||
const { pass } = req.query;
|
||||
const session = await getSession({ req })
|
||||
const goodPassword = pass === 'DPH58fa2mRvZAFSMN41ptwWn3CThjucEy9BxUJd7KQkzVerYqG';
|
||||
|
||||
//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' })
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -6,12 +6,12 @@ import prisma from '../../../lib/prisma';
|
||||
|
||||
|
||||
//api qui va rendre un utilisateur super admin (pour les developpeurs)
|
||||
//--> http://localhost:3000/api/superadmin?pass=1234 (a effacer)
|
||||
//--> http://localhost:3000/api/setadmin/make-super-admin?pass=DPH58fa2mRvZAFSMN41ptwWn3CThjucEy9BxUJd7KQkzVerYqG (a effacer)
|
||||
|
||||
export default async function makeMeSuper(req: NextApiRequest, res: NextApiResponse) {
|
||||
const { pass } = req.query;
|
||||
const session = await getSession({ req })
|
||||
const goodPassword = pass === '1234';
|
||||
const goodPassword = pass === 'DPH58fa2mRvZAFSMN41ptwWn3CThjucEy9BxUJd7KQkzVerYqG';
|
||||
|
||||
//si utilisateur connecté et que le parametre 'pass' est '1234'
|
||||
if (session && goodPassword) {
|
||||
@@ -1,11 +1,6 @@
|
||||
import prisma from '../../../lib/prisma';
|
||||
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 tester le code cadeau
|
||||
|
||||
export default async function testCode(req: NextApiRequest, res: NextApiResponse) {
|
||||
const session = await getSession({ req })
|
||||
@@ -28,7 +23,7 @@ export default async function testCode(req: NextApiRequest, res: NextApiResponse
|
||||
//est-ce que le code tapé par l'utilisateur est valide ?
|
||||
const isValidCodeCadeau = codeCadeau.match(regex);
|
||||
if (!isValidCodeCadeau) {
|
||||
res.status(401).json({ err: 'Ce code est invalide' });
|
||||
res.status(406).json({ err: 'Ce code est invalide' });
|
||||
return
|
||||
}
|
||||
|
||||
@@ -37,9 +32,15 @@ export default async function testCode(req: NextApiRequest, res: NextApiResponse
|
||||
where: { codeCadeau }
|
||||
})
|
||||
|
||||
//si l'API gain n'a pas instancié une date pour ce gain
|
||||
if (!codeCadeauInfo.dateAchat) {
|
||||
res.status(406).json({ err: 'Ce code est invalide' });
|
||||
return;
|
||||
}
|
||||
|
||||
//check si le code a déja été utilisé
|
||||
if (!codeCadeauInfo.actif) {
|
||||
res.status(401).json({ err: 'Ce code a déja été utilisé' });
|
||||
if (!codeCadeauInfo.codeActif) {
|
||||
res.status(406).json({ err: 'Ce code a déja été utilisé' });
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -50,7 +51,7 @@ export default async function testCode(req: NextApiRequest, res: NextApiResponse
|
||||
})
|
||||
|
||||
//ajout du gain au profil de l'utilisateur
|
||||
const joinGain = await prisma.gain.update({
|
||||
await prisma.gain.update({
|
||||
where: { codeCadeau: codeCadeauInfo.codeCadeau },
|
||||
data: {
|
||||
userId: getCurrentUser[0].id
|
||||
@@ -58,27 +59,13 @@ 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: {
|
||||
id: 1
|
||||
},
|
||||
data: {
|
||||
total: {
|
||||
decrement: 1
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
//passage du code en non-actif
|
||||
const codeUpdate = await prisma.gain.update({
|
||||
await prisma.gain.update({
|
||||
where: {
|
||||
id: codeCadeauInfo.id
|
||||
},
|
||||
data: {
|
||||
actif: false,
|
||||
codeActif: false,
|
||||
}
|
||||
})
|
||||
|
||||
@@ -88,8 +75,7 @@ export default async function testCode(req: NextApiRequest, res: NextApiResponse
|
||||
id: codeCadeauInfo.produitId
|
||||
}
|
||||
})
|
||||
|
||||
res.status(200).send({ success: 'Vous avez gagner un gain !', winProduct });
|
||||
return res.status(200).send({ success: 'Vous avez gagné un gain !', winProduct });
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
import prisma from '../../../lib/prisma';
|
||||
import { NextApiRequest, NextApiResponse } from 'next';
|
||||
import { getSession } from 'next-auth/react';
|
||||
import { Role } from '../../../enum/role.enum';
|
||||
|
||||
export default async function updateUser(req: NextApiRequest, res: NextApiResponse) {
|
||||
const session = await getSession({ req })
|
||||
const { selectedUserEmail } = req.body
|
||||
|
||||
|
||||
// est-ce la méthode est un POST ou PUT?
|
||||
if (!(['POST', 'PUT'].indexOf(req.method) > -1)) {
|
||||
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
|
||||
// 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: {
|
||||
isBigWinner: true
|
||||
},
|
||||
|
||||
})
|
||||
|
||||
//renvoi la liste des users mis à jour
|
||||
const users = await prisma.user.findMany({})
|
||||
|
||||
console.log(updatedUser);
|
||||
return res.status(200).send({ message: `${selectedUserEmail} est le grand gagnant !`, res: users });
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
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';
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
//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
|
||||
if (user.role === 'USER') {
|
||||
res.status(401).json({ err: "Vous n'avez pas l'autorisation" });
|
||||
return;
|
||||
}
|
||||
|
||||
//supprime l'utilisateur connecté
|
||||
const deletedUser = await prisma.user.delete({
|
||||
where: { email: selectedUserEmail },
|
||||
})
|
||||
|
||||
//renvoi la liste des users mis à jour
|
||||
const users = await prisma.user.findMany({})
|
||||
|
||||
res.status(200).send({ message: `L'utilisateur ${deletedUser.name} a été supprimé !`, res: users });
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,99 @@
|
||||
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 (!(['POST', 'PUT'].indexOf(req.method) > -1)) {
|
||||
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
|
||||
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 });
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,24 +1,13 @@
|
||||
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 updateOrCreate(req: NextApiRequest, res: NextApiResponse) {
|
||||
const session = await getSession({ req })
|
||||
const { address, name, phoneNumber, surname, zipCode } = req.body;
|
||||
|
||||
// est-ce la méthode est un POST ou PUT?
|
||||
if (req.method !== ("POST" || "PUT")) {
|
||||
if (!(['POST', 'PUT'].indexOf(req.method) > -1)) {
|
||||
throw new Error(
|
||||
`The HTTP ${req.method} method is not supported at this route.`
|
||||
);
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
import prisma from '../../../lib/prisma';
|
||||
import { NextApiRequest, NextApiResponse } from 'next';
|
||||
import { getSession } from 'next-auth/react';
|
||||
|
||||
export default async function updateOrCreate(req: NextApiRequest, res: NextApiResponse) {
|
||||
const session = await getSession({ req })
|
||||
const { targetUserMail } = req.body;
|
||||
|
||||
// est-ce la méthode est un POST ou PUT?
|
||||
if (!(['POST'].indexOf(req.method) > -1)) {
|
||||
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: targetUserMail },
|
||||
})
|
||||
|
||||
|
||||
res.status(200).send({ message: 'user :', res: user });
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
import prisma from '../../../lib/prisma';
|
||||
import { NextApiRequest, NextApiResponse } from 'next';
|
||||
import { getSession } from 'next-auth/react';
|
||||
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;
|
||||
|
||||
console.log(req.method);
|
||||
|
||||
|
||||
// est-ce la méthode est un POST ou PUT?
|
||||
if (!(['POST', 'PUT'].indexOf(req.method) > -1)) {
|
||||
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
|
||||
if (user.role === 'USER') {
|
||||
res.status(401).json({ err: "Vous n'avez pas l'autorisation" });
|
||||
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 }
|
||||
})
|
||||
|
||||
return res.status(200).send({ message: `Le gain a été mis à jour !`, res: updatedCurrentUser });
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,78 @@
|
||||
import prisma from '../../../lib/prisma';
|
||||
import { NextApiRequest, NextApiResponse } from 'next';
|
||||
import { getSession } from 'next-auth/react';
|
||||
import { Role } from '../../../enum/role.enum';
|
||||
|
||||
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 (!(['POST', 'PUT'].indexOf(req.method) > -1)) {
|
||||
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
|
||||
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,35 +1,10 @@
|
||||
import React, { useEffect } from "react";
|
||||
import prisma from '../lib/prisma'
|
||||
|
||||
|
||||
import Image from 'next/image';
|
||||
import * as Yup from 'yup';
|
||||
import Head from "next/head";
|
||||
import { getCsrfToken, signIn, useSession } from "next-auth/react";
|
||||
import { yupResolver } from "@hookform/resolvers/yup";
|
||||
import { useForm } from "react-hook-form";
|
||||
|
||||
import { AiOutlineCheck } from 'react-icons/ai'
|
||||
|
||||
import Router from "next/router";
|
||||
|
||||
|
||||
import style from '../styles/Connexion.module.css';
|
||||
|
||||
import imageConnexion from '../public/images/connexion_image.png'
|
||||
|
||||
|
||||
import Link from "next/link";
|
||||
|
||||
import { GrValidate } from 'react-icons/gr'
|
||||
import { toast } from "react-toastify";
|
||||
import { Token } from "nodemailer/lib/xoauth2";
|
||||
import { isGeneratorFunction } from "util/types";
|
||||
|
||||
|
||||
|
||||
const AuthError = () => {
|
||||
|
||||
//va rediriger après 3 seconde
|
||||
useEffect(() => {
|
||||
setTimeout(() => {
|
||||
@@ -44,11 +19,8 @@ const AuthError = () => {
|
||||
<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-lg-6`}>
|
||||
<h1 className="fw-light">Un email a été envoyé</h1>
|
||||
<GrValidate size={100} />
|
||||
|
||||
@@ -1,31 +1,47 @@
|
||||
import React from "react";
|
||||
import Head from "next/head";
|
||||
import Script from "next/script";
|
||||
|
||||
const Cgu = () => {
|
||||
return (
|
||||
<>
|
||||
<Head>
|
||||
<title>CGU</title>
|
||||
<meta name="description" content="Conditions générales" />
|
||||
<meta name="robots" content="index, follow" />
|
||||
<meta name="googlebot" content="index, follow" />
|
||||
<meta name="googlebot-news" content="index, follow" />
|
||||
<meta name="slurp" content="index, follow" />
|
||||
<meta name="msnbot" content="index, follow" />
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossOrigin="" />
|
||||
</Head>
|
||||
<div className="container py-2 py-md-3">
|
||||
<h1 className="text-center py-2 py-md-3">Conditions générales d’utilisation du site et des services proposés.</h1>
|
||||
<p>
|
||||
Le Site constitue une œuvre de l’esprit protégée par les dispositions du Code de la Propriété Intellectuelle et des Réglementations Internationales applicables. Le Client ne peut en aucune manière réutiliser, céder ou exploiter pour son propre compte tout ou partie des éléments ou travaux du Site.
|
||||
<br /><br />
|
||||
L’utilisation du site https://www.furiousducks.fr implique l’acceptation pleine et entière des conditions générales d’utilisation ci-après décrites. Ces conditions d’utilisation sont susceptibles d’être modifiées ou complétées à tout moment, les utilisateurs du site https://www.furiousducks.fr sont donc invités à les consulter de manière régulière.
|
||||
<br /><br />
|
||||
Ce site internet est normalement accessible à tout moment aux utilisateurs. Une interruption pour raison de maintenance technique peut être toutefois décidée par https://www.furiousducks.fr, qui s’efforcera alors de communiquer préalablement aux utilisateurs les dates et heures de l’intervention. Le site web https://www.furiousducks.fr est mis à jour régulièrement par https://www.furiousducks.fr responsable. De la même façon, les mentions légales peuvent être modifiées à tout moment : elles s’imposent néanmoins à l’utilisateur qui est invité à s’y référer le plus souvent possible afin d’en prendre connaissance.
|
||||
</p>
|
||||
</div>
|
||||
<>
|
||||
<Head>
|
||||
<title>CGU</title>
|
||||
<meta name="description" content="Conditions générales" />
|
||||
<meta name="robots" content="index, follow" />
|
||||
<meta name="googlebot" content="index, follow" />
|
||||
<meta name="googlebot-news" content="index, follow" />
|
||||
<meta name="slurp" content="index, follow" />
|
||||
<meta name="msnbot" content="index, follow" />
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossOrigin="" />
|
||||
</Head>
|
||||
<Script async src="https://www.googletagmanager.com/gtag/js?id=G-QNZD85D13X"></Script>
|
||||
<Script>
|
||||
{`
|
||||
window.dataLayer = window.dataLayer || [];
|
||||
function gtag(){dataLayer.push(arguments);}
|
||||
gtag('js', new Date());
|
||||
|
||||
gtag('config', 'G-QNZD85D13X');
|
||||
`}
|
||||
</Script>
|
||||
<Script>{`(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
|
||||
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
|
||||
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
|
||||
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
|
||||
})(window,document,'script','dataLayer','GTM-MMHM9HX');`}</Script>
|
||||
|
||||
<div className="container py-2 py-md-3">
|
||||
<h1 className="text-center py-2 py-md-3">Conditions générales d’utilisation du site et des services proposés.</h1>
|
||||
<p>
|
||||
Le Site constitue une œuvre de l’esprit protégée par les dispositions du Code de la Propriété Intellectuelle et des Réglementations Internationales applicables. Le Client ne peut en aucune manière réutiliser, céder ou exploiter pour son propre compte tout ou partie des éléments ou travaux du Site.
|
||||
<br /><br />
|
||||
L’utilisation du site https://www.furiousducks.fr implique l’acceptation pleine et entière des conditions générales d’utilisation ci-après décrites. Ces conditions d’utilisation sont susceptibles d’être modifiées ou complétées à tout moment, les utilisateurs du site https://www.furiousducks.fr sont donc invités à les consulter de manière régulière.
|
||||
<br /><br />
|
||||
Ce site internet est normalement accessible à tout moment aux utilisateurs. Une interruption pour raison de maintenance technique peut être toutefois décidée par https://www.furiousducks.fr, qui s’efforcera alors de communiquer préalablement aux utilisateurs les dates et heures de l’intervention. Le site web https://www.furiousducks.fr est mis à jour régulièrement par https://www.furiousducks.fr responsable. De la même façon, les mentions légales peuvent être modifiées à tout moment : elles s’imposent néanmoins à l’utilisateur qui est invité à s’y référer le plus souvent possible afin d’en prendre connaissance.
|
||||
</p>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -1,69 +1,26 @@
|
||||
import React from "react";
|
||||
import prisma from '../lib/prisma'
|
||||
|
||||
import Image from 'next/image';
|
||||
import * as Yup from 'yup';
|
||||
import Head from "next/head";
|
||||
import { getCsrfToken, signIn, useSession } from "next-auth/react";
|
||||
import { yupResolver } from "@hookform/resolvers/yup";
|
||||
import { signIn } from "next-auth/react";
|
||||
import { useForm } from "react-hook-form";
|
||||
|
||||
import { AiOutlineGoogle } from 'react-icons/ai'
|
||||
|
||||
import Router from "next/router";
|
||||
|
||||
|
||||
import style from '../styles/Connexion.module.css';
|
||||
|
||||
import imageConnexion from '../public/images/connexion_image.png'
|
||||
|
||||
|
||||
import Link from "next/link";
|
||||
|
||||
import { SiGnuprivacyguard } from 'react-icons/si'
|
||||
import { toast } from "react-toastify";
|
||||
import { Token } from "nodemailer/lib/xoauth2";
|
||||
import { isGeneratorFunction } from "util/types";
|
||||
|
||||
export async function getServerSideProps(context) {
|
||||
const csrfToken = await getCsrfToken(context)
|
||||
return {
|
||||
props: { csrfToken },
|
||||
}
|
||||
}
|
||||
import Script from "next/script";
|
||||
|
||||
type LoginSubmitForm = {
|
||||
email: string,
|
||||
acceptTerms: boolean
|
||||
};
|
||||
|
||||
type Props = {
|
||||
csrfToken: Token
|
||||
}
|
||||
|
||||
const MainPage = ({ csrfToken }: Props) => {
|
||||
const { data: session } = useSession();
|
||||
|
||||
const validationSchema = Yup.object().shape({
|
||||
// email: Yup.string().email(
|
||||
// "Veuillez rentrer une adresse mail valide"
|
||||
// ),
|
||||
// acceptTerms: Yup.bool().oneOf(
|
||||
// [true],
|
||||
// "Vous devez accepter les conditions obligatoire"
|
||||
// )
|
||||
})
|
||||
|
||||
const Connexion = () => {
|
||||
const {
|
||||
register,
|
||||
clearErrors,
|
||||
handleSubmit,
|
||||
watch,
|
||||
trigger,
|
||||
formState: { errors }
|
||||
} = useForm<LoginSubmitForm>({
|
||||
resolver: yupResolver(validationSchema)
|
||||
});
|
||||
} = useForm<LoginSubmitForm>();
|
||||
|
||||
const acceptTermCheckBox = watch("acceptTerms")
|
||||
|
||||
@@ -76,14 +33,12 @@ 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");
|
||||
}
|
||||
|
||||
|
||||
|
||||
const onCheckTerms = () => {
|
||||
if (acceptTermCheckBox) {
|
||||
return true;
|
||||
@@ -102,41 +57,33 @@ const MainPage = ({ csrfToken }: Props) => {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// try {
|
||||
// const body = { bioValue: data.bio };
|
||||
// await fetch(`/api/profile`, {
|
||||
// method: "POST",
|
||||
// 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);
|
||||
// }
|
||||
return (
|
||||
<>
|
||||
<Head>
|
||||
<title>Connexion</title>
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossOrigin="" />
|
||||
</Head>
|
||||
</Head>
|
||||
<Script async src="https://www.googletagmanager.com/gtag/js?id=G-QNZD85D13X"></Script>
|
||||
<Script>
|
||||
{`
|
||||
window.dataLayer = window.dataLayer || [];
|
||||
function gtag(){dataLayer.push(arguments);}
|
||||
gtag('js', new Date());
|
||||
|
||||
gtag('config', 'G-QNZD85D13X');
|
||||
`}
|
||||
</Script>
|
||||
<Script>{`(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
|
||||
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
|
||||
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
|
||||
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
|
||||
})(window,document,'script','dataLayer','GTM-MMHM9HX');`}</Script>
|
||||
|
||||
<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-6`}>
|
||||
<h1 className="fw-light">Connexion</h1>
|
||||
|
||||
<SiGnuprivacyguard size={50} />
|
||||
<form onSubmit={handleSubmit(onMailSubmit)}>
|
||||
<div className="form-group mx-auto my-3 w-100">
|
||||
@@ -158,7 +105,7 @@ const MainPage = ({ csrfToken }: Props) => {
|
||||
<span className={style.logo}><AiOutlineGoogle /></span>Se connecter avec google
|
||||
</button>
|
||||
</div>
|
||||
<div className="form-group">
|
||||
<div className="form-group my-1">
|
||||
<label
|
||||
htmlFor="acceptTerms"
|
||||
className="form-check-label"
|
||||
@@ -168,7 +115,7 @@ const MainPage = ({ csrfToken }: Props) => {
|
||||
</label>
|
||||
<input
|
||||
type="checkbox"
|
||||
className={`form-check-input ${errors.acceptTerms ? 'is-invalid' : ''}`}
|
||||
className={`form-check-input mx-1 ${errors.acceptTerms ? 'is-invalid' : ''}`}
|
||||
{...register("acceptTerms")}
|
||||
name="acceptTerms"
|
||||
id="acceptTerms"
|
||||
@@ -176,12 +123,9 @@ const MainPage = ({ csrfToken }: Props) => {
|
||||
</div>
|
||||
</form>
|
||||
</div >
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</>)
|
||||
};
|
||||
|
||||
export default MainPage;
|
||||
|
||||
|
||||
export default Connexion;
|
||||
@@ -1,11 +1,11 @@
|
||||
import React from "react";
|
||||
import Head from "next/head";
|
||||
|
||||
import style from '../styles/ToutSavoir.module.css';
|
||||
import Link from "next/link";
|
||||
|
||||
const Contact = () => {
|
||||
|
||||
return (
|
||||
<>
|
||||
<>
|
||||
<Head>
|
||||
<title>Contact</title>
|
||||
<meta name="description" content="Contact" />
|
||||
@@ -17,30 +17,44 @@ const Contact = () => {
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossOrigin="" />
|
||||
</Head>
|
||||
|
||||
<div className="container">
|
||||
<h1 className="text-center py-2 py-md-3">Contactez nous</h1>
|
||||
<div className="row pt-2 pb-3">
|
||||
<div className="col-12 col-md-6">
|
||||
<h2 className="text-center pb-4">Nos coordonées</h2>
|
||||
<div className="px-2">
|
||||
<h2>Par téléphone</h2>
|
||||
<a href="tel:0165389423">01.65.38.94.23</a>
|
||||
<h2 className="mt-3">Par mail</h2>
|
||||
<a href="mailto:contact@thetiptop.com">contact@thetiptop.com</a>
|
||||
<h2 className="mt-3">Sur nos réseaux</h2>
|
||||
<div>Réseau 1</div>
|
||||
<div>Réseau 2</div>
|
||||
<div>Réseau 3</div>
|
||||
|
||||
|
||||
|
||||
<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']} row`}>
|
||||
<h1 className="fw-light">Contactez nous</h1>
|
||||
<hr />
|
||||
<div className="col">
|
||||
<h2 className="text-center">Nos coordonées</h2>
|
||||
<hr />
|
||||
<div className="px-2">
|
||||
<h3>Par téléphone</h3>
|
||||
<a href="tel:0165389423">01.65.38.94.23</a>
|
||||
<h3 className="mt-3">Par mail</h3>
|
||||
<a href="mailto:contact@thetiptop.com">contact@thetiptop.com</a>
|
||||
<h3 className="mt-3">Sur nos réseaux</h3>
|
||||
<Link href={'https://www.instagram.com/the_tip_top_acem/?hl=fr'}><div>Instagram</div></Link>
|
||||
<Link href={'https://www.facebook.com/profile.php?id=100088390638593'}><div>Facebook</div></Link>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div className="col">
|
||||
<h2 className="text-center">Notre siège</h2>
|
||||
<hr />
|
||||
<iframe width="250" height="250" id="gmap_canvas" src="https://maps.google.com/maps?q=18%20rue%20L%C3%A9on%20Frot,%2075%20011%20Paris&t=&z=17&ie=UTF8&iwloc=&output=embed" frameBorder="0" scrolling="no" marginHeight={0} marginWidth={0}>
|
||||
</iframe>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div className="col-12 col-md-6 text-center">
|
||||
<h2 className="text-center pb-3">Notre siège</h2>
|
||||
<iframe width="300" height="300" id="gmap_canvas" src="https://maps.google.com/maps?q=18%20rue%20L%C3%A9on%20Frot,%2075%20011%20Paris&t=&z=17&ie=UTF8&iwloc=&output=embed" frameBorder="0" scrolling="no" marginHeight={0} marginWidth={0}>
|
||||
</iframe>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -1,39 +1,21 @@
|
||||
import React, { useState } from "react";
|
||||
import Layout from "../components/Layout";
|
||||
import prisma from '../lib/prisma'
|
||||
|
||||
import Image from 'next/image';
|
||||
import * as Yup from 'yup';
|
||||
import Head from "next/head";
|
||||
import { getSession, useSession } from "next-auth/react";
|
||||
import { yupResolver } from "@hookform/resolvers/yup";
|
||||
import { useSession } from "next-auth/react";
|
||||
import { useForm } from "react-hook-form";
|
||||
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 Link from "next/link";
|
||||
|
||||
import testerCodeCadeau from '../public/images/svg/testerlecode.svg'
|
||||
import feuilleGauche from '../public/images/feuilleGauche.webp'
|
||||
import feuilleDroite from '../public/images/feuilleBasDroite.webp'
|
||||
import unAnDeThe from '../public/images/unandethé.webp'
|
||||
import sablier from '../public/images/sablier.webp'
|
||||
import cadeau from '../public/images/cadeau.webp'
|
||||
import jeuConcours from '../public/images/jeuconcours.webp'
|
||||
import { GetServerSideProps } from "next";
|
||||
|
||||
import { toast } from "react-toastify";
|
||||
|
||||
|
||||
|
||||
import arrowUp from '../public/images/png/arrowup.png'
|
||||
|
||||
import footerGrass from '../public/images/footer_image.webp'
|
||||
|
||||
import Link from "next/link";
|
||||
import Script from "next/script";
|
||||
|
||||
type CodeSubmitForm = {
|
||||
codeCadeau: string;
|
||||
@@ -51,43 +33,18 @@ type ResponseData = {
|
||||
|
||||
|
||||
|
||||
const MainPage = () => {
|
||||
const Index = () => {
|
||||
|
||||
const { data: session } = useSession();
|
||||
const [response, setResponse] = useState<ResponseData | null>(null)
|
||||
const [winAnimation, setWinAnimation] = useState(false)
|
||||
|
||||
const validationSchema = Yup.object().shape({
|
||||
// codeCadeau: Yup.string().trim().required("Veuillez rentrer un code cadeau !"),
|
||||
});
|
||||
|
||||
const {
|
||||
register,
|
||||
handleSubmit,
|
||||
formState: { errors }
|
||||
} = useForm<CodeSubmitForm>({
|
||||
resolver: yupResolver(validationSchema)
|
||||
});
|
||||
|
||||
const mountedStyle = {
|
||||
animation: "inAnimation 250ms ease-in"
|
||||
};
|
||||
const unmountedStyle = {
|
||||
animation: "outAnimation 270ms ease-out",
|
||||
animationFillMode: "forwards"
|
||||
};
|
||||
|
||||
} = useForm<CodeSubmitForm>();
|
||||
|
||||
const onSubmit = async (data: CodeSubmitForm) => {
|
||||
|
||||
if (!errors) {
|
||||
if (!session) {
|
||||
return <Layout>
|
||||
<p>Vous devez vous connecter pour tester votre code cadeau!</p>
|
||||
</Layout>
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
const body = { codeCadeau: data.codeCadeau };
|
||||
await fetch(`/api/testcode`, {
|
||||
@@ -111,7 +68,6 @@ const MainPage = () => {
|
||||
theme: "light",
|
||||
});
|
||||
return;
|
||||
// await Router.push("/profile");
|
||||
}
|
||||
setWinAnimation(true)
|
||||
await confettiTime();
|
||||
@@ -119,7 +75,7 @@ const MainPage = () => {
|
||||
} catch (error) {
|
||||
console.error('ERROR :', error);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
const confettiTime = async (): Promise<void> => {
|
||||
const JSConfetti = (await import('js-confetti')).default
|
||||
@@ -143,6 +99,21 @@ const MainPage = () => {
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossOrigin="" />
|
||||
</Head>
|
||||
<Script async src="https://www.googletagmanager.com/gtag/js?id=G-QNZD85D13X"></Script>
|
||||
<Script>
|
||||
{`
|
||||
window.dataLayer = window.dataLayer || [];
|
||||
function gtag(){dataLayer.push(arguments);}
|
||||
gtag('js', new Date());
|
||||
|
||||
gtag('config', 'G-QNZD85D13X');
|
||||
`}
|
||||
</Script>
|
||||
<Script>{`(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
|
||||
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
|
||||
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
|
||||
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
|
||||
})(window,document,'script','dataLayer','GTM-MMHM9HX');`}</Script>
|
||||
|
||||
<div className={`${style['masthead']} body-content`}>
|
||||
<div className="d-flex flex-wrap justify-content-center align-items-center text-center">
|
||||
@@ -154,13 +125,15 @@ const MainPage = () => {
|
||||
className={`${style['rotatingSlow']}`}
|
||||
/>
|
||||
</div>
|
||||
<div className={`${style['jeuConcours']} ${style['imageContainer']}`}>
|
||||
<Image
|
||||
src={jeuConcours}
|
||||
alt="thetiptop jeu Concours"
|
||||
layout="responsive"
|
||||
className={`${style['zoomInOutCadeau']}`}
|
||||
/>
|
||||
<div className={`${style['jeuConcours']} ${style['imageContainer']} ${style['zoomInOutCadeauContainer']}`}>
|
||||
<Link href="/tout-savoir" legacyBehavior><a>
|
||||
<Image
|
||||
src={jeuConcours}
|
||||
alt="thetiptop jeu concours, tout savoir"
|
||||
layout="responsive"
|
||||
className={`${style['zoomInOutCadeau']}`}
|
||||
/>
|
||||
</a></Link>
|
||||
</div>
|
||||
<div className={`${style['cadeau']} ${style['imageContainer']}`}>
|
||||
<Image
|
||||
@@ -193,6 +166,7 @@ const MainPage = () => {
|
||||
<div className="form-group mx-auto my-3 w-100">
|
||||
<input type="text"
|
||||
id="codeInput" aria-describedby="codeHelp"
|
||||
data-testid="codeInput"
|
||||
placeholder="A293049430..."
|
||||
minLength={10}
|
||||
maxLength={10}
|
||||
@@ -204,23 +178,18 @@ const MainPage = () => {
|
||||
<div className="invalid-feedback alert alert-danger">{errors.codeCadeau?.message}</div>
|
||||
</div>
|
||||
<div className="form-group mx-auto my-3 w-100">
|
||||
<button type="submit" className={`${style['aButton']} btn btn-primary`}>Découvrir mon cadeau !</button>
|
||||
<button type="submit" data-testid="submit" className={`${style['aButton']} btn btn-primary`}>Découvrir mon cadeau !</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
</div>}
|
||||
|
||||
|
||||
{winAnimation && <div className="col-12 align-items-center d-flex flex-column">
|
||||
|
||||
<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>
|
||||
|
||||
<div className={`${style['imageWrapper']}`}>
|
||||
<Image
|
||||
src={arrowUp}
|
||||
@@ -231,29 +200,17 @@ const MainPage = () => {
|
||||
className={`${style['rotatingImage']}`}
|
||||
/>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div className="row">
|
||||
<button onClick={getCadeau} className={`${style['aButton']} btn btn-primary`}>Voir mes cadeaux !</button>
|
||||
<button onClick={() => setWinAnimation(false)} className={`${style['aButton']} btn btn-primary mt-2`}>Rejouer un ticket !</button>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
</div>}
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
<div className={`${style['footerGrass']} position-absolute`}>
|
||||
<Image
|
||||
src={footerGrass}
|
||||
alt="thetiptop feuille Gauche"
|
||||
layout="responsive"
|
||||
// className={`${style['footerGrass']}`}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
@@ -261,4 +218,4 @@ const MainPage = () => {
|
||||
);
|
||||
};
|
||||
|
||||
export default MainPage;
|
||||
export default Index;
|
||||
@@ -1,11 +1,11 @@
|
||||
import React from "react";
|
||||
import Head from "next/head";
|
||||
import style from "styled-jsx/style";
|
||||
import Script from "next/script";
|
||||
|
||||
const MentionsLegales = () => {
|
||||
|
||||
return (
|
||||
<>
|
||||
<>
|
||||
<Head>
|
||||
<title>Mentions légales</title>
|
||||
<meta name="description" content="Mentions légales" />
|
||||
@@ -16,7 +16,22 @@ const MentionsLegales = () => {
|
||||
<meta name="msnbot" content="index, follow" />
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossOrigin="" />
|
||||
</Head>
|
||||
</Head>
|
||||
<Script async src="https://www.googletagmanager.com/gtag/js?id=G-QNZD85D13X"></Script>
|
||||
<Script>
|
||||
{`
|
||||
window.dataLayer = window.dataLayer || [];
|
||||
function gtag(){dataLayer.push(arguments);}
|
||||
gtag('js', new Date());
|
||||
|
||||
gtag('config', 'G-QNZD85D13X');
|
||||
`}
|
||||
</Script>
|
||||
<Script>{`(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
|
||||
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
|
||||
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
|
||||
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
|
||||
})(window,document,'script','dataLayer','GTM-MMHM9HX');`}</Script>
|
||||
<div className={`${style['navbar']}`}>
|
||||
<div className="container py-2 py-md-3">
|
||||
<h1 className="text-center py-2 py-md-3">Mentions légales</h1>
|
||||
@@ -53,7 +68,7 @@ const MentionsLegales = () => {
|
||||
<br /><br />
|
||||
L’utilisation du site https://www.furiousducks.fr implique l’acceptation pleine et entière des conditions générales d’utilisation ci-après décrites. Ces conditions d’utilisation sont susceptibles d’être modifiées ou complétées à tout moment, les utilisateurs du site https://www.furiousducks.fr sont donc invités à les consulter de manière régulière.
|
||||
<br /><br />
|
||||
Ce site internet est normalement accessible à tout moment aux utilisateurs. Une interruption pour raison de maintenance technique peut être toutefois décidée par https://www.furiousducks.fr, qui s’efforcera alors de communiquer préalablement aux utilisateurs les dates et heures de l’intervention. Le site web https://www.furiousducks.fr est mis à jour régulièrement par https://www.furiousducks.fr responsable. De la même façon, les mentions légales peuvent être modifiées à tout moment : elles s’imposent néanmoins à l’utilisateur qui est invité à s’y référer le plus souvent possible afin d’en prendre connaissance.
|
||||
Ce site internet est normalement accessible à tout moment aux utilisateurs. Une interruption pour raison de maintenance technique peut être toutefois décidée par https://www.furiousducks.fr, qui s’efforcera alors de communiquer préalablement aux utilisateurs les dates et heures de l’intervention. Le site web https://www.furiousducks.fr est mis à jour régulièrement par https://www.furiousducks.fr responsable. De la même façon, les mentions légales peuvent être modifiées à tout moment : elles s’imposent néanmoins à l’utilisateur qui est invité à s’y référer le plus souvent possible afin d’en prendre connaissance.
|
||||
</p>
|
||||
<h2>Description des services fournis.</h2>
|
||||
<p>
|
||||
@@ -61,7 +76,7 @@ const MentionsLegales = () => {
|
||||
<br /><br />
|
||||
Toutes les informations indiquées sur le site https://www.furiousducks.fr sont données à titre indicatif, et sont susceptibles d’évoluer. Par ailleurs, les renseignements figurant sur le site https://www.furiousducks.fr ne sont pas exhaustifs. Ils sont donnés sous réserve de modifications ayant été apportées depuis leur mise en ligne.
|
||||
<br /><br />
|
||||
Le règlement et les modalités du jeu-concours ont été déposés auprès de Maître Arnaud Rick huissier de justice et le tirage au sort du gros lot sera également effectué sous le contrôle de ce dernier.
|
||||
Le règlement et les modalités du jeu-concours ont été déposés auprès de Maître Arnaud Rick huissier de justice et le tirage au sort du gros lot sera également effectué sous le contrôle de ce dernier.
|
||||
</p>
|
||||
<h2>Limitations contractuelles sur les données techniques.</h2>
|
||||
<p>
|
||||
@@ -69,13 +84,13 @@ const MentionsLegales = () => {
|
||||
<br /><br />
|
||||
L’objectif est d’apporter une prestation qui assure le meilleur taux d’accessibilité. L’hébergeur assure la continuité de son service 24 Heures sur 24, tous les jours de l’année. Il se réserve néanmoins la possibilité d’interrompre le service d’hébergement pour les durées les plus courtes possibles notamment à des fins de maintenance, d’amélioration de ses infrastructures, de défaillance de ses infrastructures ou si les Prestations et Services génèrent un trafic réputé anormal.
|
||||
<br /><br />
|
||||
https://www.furiousducks.fr et l’hébergeur ne pourront être tenus responsables en cas de dysfonctionnement du réseau Internet, des lignes téléphoniques ou du matériel informatique et de téléphonie lié notamment à l’encombrement du réseau empêchant l’accès au serveur.
|
||||
https://www.furiousducks.fr et l’hébergeur ne pourront être tenus responsables en cas de dysfonctionnement du réseau Internet, des lignes téléphoniques ou du matériel informatique et de téléphonie lié notamment à l’encombrement du réseau empêchant l’accès au serveur.
|
||||
</p>
|
||||
<h2>Propriété intellectuelle et contrefaçons.</h2>
|
||||
<p>
|
||||
https://www.furiousducks.fr est propriétaire des droits de propriété intellectuelle et détient les droits d’usage sur tous les éléments accessibles sur le site internet, notamment les textes, images, graphismes, logos, vidéos, icônes et sons. Toute reproduction, représentation, modification, publication, adaptation de tout ou partie des éléments du site, quel que soit le moyen ou le procédé utilisé, est interdite, sauf autorisation écrite préalable de : https://www.furiousducks.fr.
|
||||
<br /><br />
|
||||
Toute exploitation non autorisée du site ou de l’un quelconque des éléments qu’il contient sera considérée comme constitutive d’une contrefaçon et poursuivie conformément aux dispositions des articles L.335-2 et suivants du Code de Propriété Intellectuelle.
|
||||
Toute exploitation non autorisée du site ou de l’un quelconque des éléments qu’il contient sera considérée comme constitutive d’une contrefaçon et poursuivie conformément aux dispositions des articles L.335-2 et suivants du Code de Propriété Intellectuelle.
|
||||
</p>
|
||||
<h2>Limitations de responsabilité.</h2>
|
||||
<p>
|
||||
|
||||
@@ -1,40 +1,18 @@
|
||||
import React, { useEffect, useState, useSyncExternalStore } from "react";
|
||||
import React, { useState } from "react";
|
||||
import prisma from '../lib/prisma'
|
||||
|
||||
|
||||
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 Image from 'next/image';
|
||||
import { getSession, 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 { useForm } from "react-hook-form";
|
||||
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, User } from "@prisma/client";
|
||||
|
||||
import { Gain, User } from "@prisma/client";
|
||||
import unandethe from '../public/images/unandethe.webp'
|
||||
|
||||
type FormData = {
|
||||
email: string;
|
||||
@@ -47,7 +25,6 @@ type FormData = {
|
||||
|
||||
export async function getServerSideProps(context) {
|
||||
const session = await getSession(context)
|
||||
|
||||
if (!session) {
|
||||
return {
|
||||
redirect: {
|
||||
@@ -56,13 +33,11 @@ export async function getServerSideProps(context) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const user = await prisma.user.findUnique({
|
||||
where: {
|
||||
email: session?.user.email
|
||||
}
|
||||
});
|
||||
|
||||
const userGains = await prisma.gain.findMany({
|
||||
where: {
|
||||
userId: user.id
|
||||
@@ -75,20 +50,19 @@ export async function getServerSideProps(context) {
|
||||
return {
|
||||
props: {
|
||||
user: JSON.parse(JSON.stringify(user)),
|
||||
userGains,
|
||||
userGains: JSON.parse(JSON.stringify(userGains)),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
type Props = {
|
||||
user: User;
|
||||
userGains: any;
|
||||
userGains: Gain[];
|
||||
}
|
||||
|
||||
const MonCompte = (props: Props) => {
|
||||
|
||||
const { data: session, status } = useSession();
|
||||
const [response, setResponse] = useState(null)
|
||||
const { data: session } = useSession();
|
||||
const [, setResponse] = useState(null)
|
||||
|
||||
const validationSchema = Yup.object().shape({
|
||||
name: Yup.string()
|
||||
@@ -108,7 +82,7 @@ const MonCompte = (props: Props) => {
|
||||
.phone("FR", true, "le numéro de téléphone est invalide")
|
||||
});
|
||||
|
||||
const { register, setValue, handleSubmit, formState: { errors } } = useForm<FormData>({
|
||||
const { register, handleSubmit, formState: { errors } } = useForm<FormData>({
|
||||
resolver: yupResolver(validationSchema)
|
||||
});
|
||||
|
||||
@@ -172,77 +146,77 @@ 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">
|
||||
{props.user.isBigWinner &&
|
||||
<div>
|
||||
<h3>!!! Vous avez été séléctionné pour gagner 1 an de thé !!!</h3>
|
||||
<Image
|
||||
src={unandethe}
|
||||
alt="logo un an cadeau"
|
||||
width={190}
|
||||
height={180 - 40}
|
||||
className={`${style['rotatingSlow']}`} />
|
||||
|
||||
</div>}
|
||||
<div className="col-md-6 col-sm-12">
|
||||
<hr />
|
||||
<h1 className="fw-light">Mes informations <TfiInfoAlt size={40} /></h1>
|
||||
<hr />
|
||||
<form onSubmit={handleSubmit(onSubmit)}>
|
||||
<div className="form-group">
|
||||
|
||||
<div className="form-group row">
|
||||
<div className="form-group row my-1">
|
||||
<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">
|
||||
<div className="form-group row my-1">
|
||||
<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">
|
||||
<div className="form-group row my-1">
|
||||
<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">
|
||||
<div className="form-group row my-1">
|
||||
<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={props.user.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">
|
||||
<div className="form-group row my-1">
|
||||
<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={props.user.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">
|
||||
<div className="form-group row my-1">
|
||||
<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={props.user.phoneNumber} id="phoneNumber" placeholder="0123456789..." />
|
||||
<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 +231,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) => {
|
||||
return <tr>
|
||||
<th scope="row"></th>
|
||||
{props.userGains.map((info: any, index: number) => {
|
||||
return <tr key={index}>
|
||||
<th scope="row">{++index}</th>
|
||||
<td>{info.codeCadeau}</td>
|
||||
<td>{info.produit.nomProduit}</td>
|
||||
<td>{info.retrait ? '❌ déja récupéré' : '✔️ venir me chercher !'}</td>
|
||||
</tr>
|
||||
})}
|
||||
</tbody>
|
||||
</table>
|
||||
}
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div >
|
||||
|
||||
</div>
|
||||
</div >
|
||||
</>)
|
||||
|
||||
@@ -1,56 +0,0 @@
|
||||
{/* <div className={`${style['bloc-content']} col-12 col-md-10 d-flex row my-2 mx-0 py-2 py-md-2 px-0 px-md-3 `}>
|
||||
<h2 className="col-12 my-2">A gagner</h2>
|
||||
<div className="col d-flex justify-content-center">
|
||||
<div className={`${style['productToGain']}`}>
|
||||
<Image
|
||||
src={rotatingRightImage}
|
||||
alt="coffret de thé marron rempli de sachets de toutes couleurs"
|
||||
fill
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div className="col d-flex justify-content-center">
|
||||
<div className={`${style['productToGain']}`}>
|
||||
<Image
|
||||
src={rotatingRightImage}
|
||||
alt="coffret de thé marron rempli de sachets de toutes couleurs"
|
||||
fill
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div className="col d-flex justify-content-center">
|
||||
<div className={`${style['productToGain']}`}>
|
||||
<Image
|
||||
src={rotatingRightImage}
|
||||
alt="coffret de thé marron rempli de sachets de toutes couleurs"
|
||||
fill
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div className="col-12">
|
||||
<div className='btn btn-primary my-2'>
|
||||
<Link href="shop">Et bien d'autres !</Link>
|
||||
</div>
|
||||
</div>
|
||||
</div> */}
|
||||
|
||||
|
||||
|
||||
{/* <Section backgroundImagePath={'/images/three-cups-of-tea-steeping.png'}>
|
||||
<h2>Présentation du jeu concours</h2>
|
||||
<h4 className="fw-light">
|
||||
Gagnez de superbes cadeaux en achetant nos produits !
|
||||
<br />
|
||||
Pour participer, il vous suffit d'effectuer un achat en boutique d'une valeur supérieure à XXX euros. Retrouvez votre code sur la facture !
|
||||
<br />
|
||||
Saisissez votre code ... Félicitations ! Vous avez gagné un cadeau ! Il nous vous reste plus qu'à le récupérer en magasin.
|
||||
<br />
|
||||
Après la [XXX période], vous participerez au jeu concours final afin de gagner XXX. Un participation par personne est comptabilisée pour le concours final.
|
||||
</h4>
|
||||
</Section>
|
||||
<Section backgroundImagePath={'/images/top-view-of-a-tea-towel-and-container-holding-grain.png'}>
|
||||
<h2>Présentation de Thé Tip Top</h2>
|
||||
<h4 className="fw-light">
|
||||
Thé Tip Top est une entreprise de thé [XXX ajouter des spécifications en se basant sur le cahier des charges]
|
||||
</h4>
|
||||
</Section> */}
|
||||
@@ -2,11 +2,11 @@ import React from "react";
|
||||
import Image from 'next/image';
|
||||
import Head from "next/head";
|
||||
import style from '../styles/ToutSavoir.module.css'
|
||||
|
||||
|
||||
import test from '../public/images/tea-with-three-jars.webp';
|
||||
import prisma from "../lib/prisma";
|
||||
import Link from "next/link";
|
||||
import Script from "next/script";
|
||||
|
||||
|
||||
export async function getStaticProps() {
|
||||
const produits = await prisma.produit.findMany();
|
||||
@@ -28,11 +28,10 @@ type Produit = {
|
||||
nomProduit: string;
|
||||
prixTtc: number;
|
||||
image: string;
|
||||
description: string;
|
||||
}
|
||||
|
||||
const ToutSavoir = ({ produits }: Props) => {
|
||||
console.log('p', produits);
|
||||
|
||||
return (
|
||||
<>
|
||||
<Head>
|
||||
@@ -45,62 +44,88 @@ const ToutSavoir = ({ produits }: Props) => {
|
||||
<meta name="msnbot" content="index, follow" />
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossOrigin="" />
|
||||
</Head>
|
||||
{/* backgroundImagePath={'/images/ugh.png'} */}
|
||||
</Head>
|
||||
<Script async src="https://www.googletagmanager.com/gtag/js?id=G-QNZD85D13X"></Script>
|
||||
<Script>
|
||||
{`
|
||||
window.dataLayer = window.dataLayer || [];
|
||||
function gtag(){dataLayer.push(arguments);}
|
||||
gtag('js', new Date());
|
||||
|
||||
gtag('config', 'G-QNZD85D13X');
|
||||
`}
|
||||
</Script>
|
||||
<Script>{`(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
|
||||
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
|
||||
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
|
||||
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
|
||||
})(window,document,'script','dataLayer','GTM-MMHM9HX');`}</Script>
|
||||
|
||||
|
||||
<div className="body-content">
|
||||
<h1 className="text-center mt-3">Tout savoir sur le jeu concours</h1>
|
||||
<div className="container mt-3 ">
|
||||
<p className={`${style.explicationContainer} mt-lg-5`}>
|
||||
Le jeu concours vous est proposé à l'occasion de l'ouverture de notre 10e boutique à Nice !
|
||||
<br /> Pour participer, il vous suffit de faire un achat supérieur à 49€, un code vous sera fourni sur votre facture à saisir <Link href="/" legacyBehavior><a className={`link`}>ici</a></Link>
|
||||
<br />Le concours est effectif <b>du 12/12/2022 au 12/01/2023</b>. Vous pouvez récupérer votre lot dès la saisie de votre code.
|
||||
<br />A la fin du concours, vous pouvez encore récupérer votre cadeau pendant <b>1mois</b>, c'est à dire jusqu'au <b>12/02/2023</b>.
|
||||
</p>
|
||||
<div className={`${style.grosLot} row justify-content-between my-lg-5`}>
|
||||
<div className="col-12 col-lg-4">
|
||||
<Image
|
||||
className="card-img-top" src={test}
|
||||
width="286"
|
||||
height="180"
|
||||
alt="produit"
|
||||
/>
|
||||
</div>
|
||||
<div className="col-12 col-lg-8 mt-3 mt-lg-0">
|
||||
<div className="px-5 h-100 d-flex flex-column">
|
||||
<h2 className="text-center">Le gros lot</h2>
|
||||
<div className="h-100 d-flex align-items-center">
|
||||
<div>
|
||||
En participant au moins une fois à notre jeu concours, vous vous qualifiez pour gagner le gros lot : <b>1 an de thé</b> d'une valeur de 360€ !
|
||||
|
||||
<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']}`}>
|
||||
<h1 className="text-center mt-3">Tout savoir sur le jeu concours</h1>
|
||||
<hr />
|
||||
<div className="container mt-3 ">
|
||||
<p className={`${style.explicationContainer} mt-lg-5`}>
|
||||
Le jeu concours vous est proposé à l'occasion de l'ouverture de notre 10e boutique à Nice !
|
||||
<br /> Pour participer, il vous suffit de faire un achat supérieur à 49€, un code vous sera fourni sur votre facture à saisir <Link href="/" legacyBehavior><a className={`link`}>ici</a></Link>
|
||||
<br />Le concours est effectif <b>du 12/12/2022 au 12/01/2023</b>. Vous pouvez récupérer votre lot dès la saisie de votre code.
|
||||
<br />A la fin du concours, vous pouvez encore récupérer votre cadeau pendant <b>1mois</b>, c'est à dire jusqu'au <b>12/02/2023</b>.
|
||||
</p>
|
||||
<div className={`${style.grosLot} row justify-content-between my-lg-5`}>
|
||||
<div className="col-12 col-lg-4">
|
||||
<Image
|
||||
className="card-img-top" src={test}
|
||||
width="286"
|
||||
height="180"
|
||||
alt="produit"
|
||||
/>
|
||||
</div>
|
||||
<div className="col-12 col-lg-8 mt-3 mt-lg-0">
|
||||
<div className="px-5 h-100 d-flex flex-column">
|
||||
<h2 className="text-center">Le gros lot</h2>
|
||||
<div className="h-100 d-flex align-items-center">
|
||||
<div>
|
||||
En participant au moins une fois à notre jeu concours, vous vous qualifiez pour gagner le gros lot : <b>1 an de thé</b> d'une valeur de 360€ !
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className="row justify-content-center">
|
||||
{produits.map((produit: Produit) => {
|
||||
return <div className="col-12 col-lg-4 d-flex justify-content-center my-2 my-lg-3" key={produit.id}>
|
||||
<div className={`${style.aCard} card`}>
|
||||
<div className="d-flex justify-content-center p-0">
|
||||
<Image
|
||||
className="card-img-top" src={produit.image}
|
||||
width="286"
|
||||
height="180"
|
||||
alt="produit"
|
||||
/>
|
||||
</div>
|
||||
<div className="card-body d-flex flex-column h-100">
|
||||
<h5 className="card-title">{produit.nomProduit}</h5>
|
||||
<p className="card-text d-flex flex-column h-100">{produit.description}
|
||||
<br />
|
||||
<b className="mt-auto pt-2">Prix conseillé : {produit.prixTtc} €</b>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className="row justify-content-center">
|
||||
{produits.map((produit: Produit) => {
|
||||
return <div className="col-12 col-lg-4 d-flex justify-content-center my-2 my-lg-3" key={produit.id}>
|
||||
<div className={`${style.aCard} card`}>
|
||||
<div className="d-flex justify-content-center p-0">
|
||||
<Image
|
||||
className="card-img-top" src={produit.image}
|
||||
width="286"
|
||||
height="180"
|
||||
alt="produit"
|
||||
/>
|
||||
</div>
|
||||
<div className="card-body d-flex flex-column h-100">
|
||||
<h5 className="card-title">{produit.nomProduit}</h5>
|
||||
<p className="card-text d-flex flex-column h-100">{produit.description}
|
||||
<br />
|
||||
<b className="mt-auto pt-2">Prix conseillé : {produit.prixTtc} €</b>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -1,36 +1,10 @@
|
||||
import React, { useEffect } from "react";
|
||||
import prisma from '../lib/prisma'
|
||||
|
||||
|
||||
import Image from 'next/image';
|
||||
import * as Yup from 'yup';
|
||||
import Head from "next/head";
|
||||
import { getCsrfToken, signIn, useSession } from "next-auth/react";
|
||||
import { yupResolver } from "@hookform/resolvers/yup";
|
||||
import { useForm } from "react-hook-form";
|
||||
|
||||
import { AiOutlineCheck } from 'react-icons/ai'
|
||||
|
||||
import Router from "next/router";
|
||||
|
||||
|
||||
import style from '../styles/Connexion.module.css';
|
||||
|
||||
import imageConnexion from '../public/images/connexion_image.png'
|
||||
|
||||
|
||||
import Link from "next/link";
|
||||
|
||||
import { GrValidate } from 'react-icons/gr'
|
||||
import { toast } from "react-toastify";
|
||||
import { Token } from "nodemailer/lib/xoauth2";
|
||||
import { isGeneratorFunction } from "util/types";
|
||||
|
||||
|
||||
|
||||
const VerifyRequest = () => {
|
||||
|
||||
//va rediriger après 3 seconde
|
||||
useEffect(() => {
|
||||
setTimeout(() => {
|
||||
Router.push("/")
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
import { PlaywrightTestConfig, devices } from '@playwright/test'
|
||||
import path from 'path'
|
||||
|
||||
// Use process.env.PORT by default and fallback to port 3000
|
||||
const PORT = process.env.PORT || 3000
|
||||
|
||||
// Set webServer.url and use.baseURL with the location of the WebServer respecting the correct set port
|
||||
const baseURL = `http://localhost:${PORT}`
|
||||
|
||||
// Reference: https://playwright.dev/docs/test-configuration
|
||||
const config: PlaywrightTestConfig = {
|
||||
// Timeout per test
|
||||
timeout: 30 * 1000,
|
||||
// Test directory
|
||||
testDir: path.join(__dirname, 'e2e'),
|
||||
// If a test fails, retry it additional 2 times
|
||||
retries: 2,
|
||||
// Artifacts folder where screenshots, videos, and traces are stored.
|
||||
outputDir: 'test-results/',
|
||||
|
||||
// Run your local dev server before starting the tests:
|
||||
// https://playwright.dev/docs/test-advanced#launching-a-development-web-server-during-the-tests
|
||||
webServer: {
|
||||
command: 'npm run dev',
|
||||
url: baseURL,
|
||||
timeout: 120 * 1000,
|
||||
reuseExistingServer: !process.env.CI,
|
||||
},
|
||||
|
||||
use: {
|
||||
// Use baseURL so to make navigations relative.
|
||||
// More information: https://playwright.dev/docs/api/class-testoptions#test-options-base-url
|
||||
baseURL,
|
||||
|
||||
// Retry a test if its failing with enabled tracing. This allows you to analyse the DOM, console logs, network traffic etc.
|
||||
// More information: https://playwright.dev/docs/trace-viewer
|
||||
trace: 'retry-with-trace',
|
||||
|
||||
// All available context options: https://playwright.dev/docs/api/class-browser#browser-new-context
|
||||
// contextOptions: {
|
||||
// ignoreHTTPSErrors: true,
|
||||
// },
|
||||
},
|
||||
|
||||
projects: [
|
||||
{
|
||||
name: 'Desktop Chrome',
|
||||
use: {
|
||||
...devices['Desktop Chrome'],
|
||||
},
|
||||
},
|
||||
// {
|
||||
// name: 'Desktop Firefox',
|
||||
// use: {
|
||||
// ...devices['Desktop Firefox'],
|
||||
// },
|
||||
// },
|
||||
// {
|
||||
// name: 'Desktop Safari',
|
||||
// use: {
|
||||
// ...devices['Desktop Safari'],
|
||||
// },
|
||||
// },
|
||||
// Test against mobile viewports.
|
||||
// {
|
||||
// name: 'Mobile Chrome',
|
||||
// use: {
|
||||
// ...devices['Pixel 5'],
|
||||
// },
|
||||
// },
|
||||
// {
|
||||
// name: 'Mobile Safari',
|
||||
// use: devices['iPhone 12'],
|
||||
// },
|
||||
],
|
||||
}
|
||||
export default config
|
||||
@@ -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;
|
||||
@@ -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"
|
||||
@@ -45,6 +45,7 @@ model User {
|
||||
surname String?
|
||||
address String?
|
||||
zipCode Int?
|
||||
isBigWinner Boolean?
|
||||
phoneNumber Int?
|
||||
email String? @unique
|
||||
emailVerified DateTime? @map("email_verified")
|
||||
@@ -53,40 +54,37 @@ model User {
|
||||
updatedAt DateTime @updatedAt @map(name: "updated_at")
|
||||
accounts Account[]
|
||||
sessions Session[]
|
||||
gain Gain[]
|
||||
gains Gain[]
|
||||
role Role @default(USER)
|
||||
|
||||
@@map(name: "users")
|
||||
}
|
||||
|
||||
model TicketsRestants {
|
||||
id Int @id @default(autoincrement())
|
||||
total Int
|
||||
}
|
||||
|
||||
model Gain {
|
||||
id Int @id @default(autoincrement())
|
||||
codeCadeau String @unique
|
||||
dateAchat DateTime?
|
||||
dateRetrait DateTime?
|
||||
produit Produit? @relation(fields: [produitId], references: [id])
|
||||
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
|
||||
}
|
||||
|
||||
@@ -1,23 +1,14 @@
|
||||
import { PrismaClient } from '@prisma/client';
|
||||
// import prisma from '../lib/prisma'
|
||||
|
||||
import { generateGains } from './seed/gains'
|
||||
import { produitsData } from './seed/produits'
|
||||
// import { userData } from './seed/user'
|
||||
import { userData } from './seed/user'
|
||||
|
||||
const prisma = new PrismaClient();
|
||||
|
||||
async function main() {
|
||||
console.log(`Start seeding ...`)
|
||||
|
||||
//création des tickets restants
|
||||
const tickets = await prisma.ticketsRestants.create({
|
||||
data: {
|
||||
total: 1500000
|
||||
},
|
||||
})
|
||||
console.log(`Created ticket: ${tickets.total}`)
|
||||
|
||||
|
||||
//création des produits
|
||||
for (const p of produitsData) {
|
||||
@@ -29,17 +20,12 @@ 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 de 5 gains
|
||||
for (let i = 1; i <= 5; i++) {
|
||||
await generateGains();
|
||||
// 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}`)
|
||||
}
|
||||
|
||||
console.log(`Seeding finished.`)
|
||||
|
||||
@@ -1,50 +0,0 @@
|
||||
// import { produits } from './produits';
|
||||
import prisma from '../../lib/prisma'
|
||||
import { Chance } from 'chance'
|
||||
import { Cadeaux } from '../../enum/cadeaux.enum';
|
||||
import cryptoRandomString from 'crypto-random-string';
|
||||
let chance = new Chance();
|
||||
|
||||
export const generateGains = async () => {
|
||||
//génération d'un code cadeau
|
||||
const randomNoGain = cryptoRandomString({ length: 10, type: 'distinguishable' });
|
||||
|
||||
//création d'un gain
|
||||
const gainCreated = await prisma.gain.create({
|
||||
data: {
|
||||
codeCadeau: randomNoGain,
|
||||
}
|
||||
})
|
||||
|
||||
//crétion d'un id de produit de façon pondérée
|
||||
let weightedRandomGain = chance.weighted([
|
||||
Cadeaux.GrandCoffretDecouverte,
|
||||
Cadeaux.CoffretDecouverte,
|
||||
Cadeaux.TheSignature,
|
||||
Cadeaux.TheDetox,
|
||||
Cadeaux.Infuseur],
|
||||
[4, 6, 10, 20, 60]);
|
||||
|
||||
//mise à jour du gain avec l'id de produit pondéré
|
||||
const gainUpdated = await prisma.gain.update({
|
||||
where: { id: gainCreated.id },
|
||||
data: {
|
||||
produitId: weightedRandomGain,
|
||||
}
|
||||
})
|
||||
//on retire 1 ticket
|
||||
await prisma.ticketsRestants.update({
|
||||
where: {
|
||||
id: 1
|
||||
},
|
||||
data: {
|
||||
total: {
|
||||
decrement: 1
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
console.log(`Created gain ! : ${gainUpdated.codeCadeau}`)
|
||||
}
|
||||
|
||||
|
||||
@@ -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. "
|
||||
}]
|
||||
@@ -4,44 +4,74 @@ 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: 'USER'
|
||||
},
|
||||
{
|
||||
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'
|
||||
},
|
||||
{
|
||||
name: 'doug',
|
||||
email: 'doug@prisma.io',
|
||||
createdAt: new Date(),
|
||||
role: 'USER'
|
||||
},
|
||||
{
|
||||
name: 'molda',
|
||||
email: 'molda@prisma.io',
|
||||
createdAt: new Date(),
|
||||
role: 'USER'
|
||||
},
|
||||
{
|
||||
name: 'pierro',
|
||||
email: 'pierro@prisma.io',
|
||||
createdAt: new Date(),
|
||||
role: 'USER'
|
||||
},
|
||||
{
|
||||
name: 'brian',
|
||||
email: 'brian@prisma.io',
|
||||
createdAt: new Date(),
|
||||
role: 'USER'
|
||||
},
|
||||
{
|
||||
name: 'benji',
|
||||
email: 'benji@prisma.io',
|
||||
createdAt: new Date(),
|
||||
role: 'USER'
|
||||
},
|
||||
{
|
||||
name: 'abdel',
|
||||
email: 'abdel@prisma.io',
|
||||
createdAt: new Date(),
|
||||
role: 'USER'
|
||||
},
|
||||
{
|
||||
name: 'guillaume',
|
||||
email: 'guillaume@prisma.io',
|
||||
createdAt: new Date(),
|
||||
role: 'USER'
|
||||
},
|
||||
{
|
||||
name: 'roger',
|
||||
email: 'roger@prisma.io',
|
||||
createdAt: new Date(),
|
||||
role: 'USER'
|
||||
},
|
||||
{
|
||||
name: 'jacko',
|
||||
email: 'jacko@prisma.io',
|
||||
createdAt: new Date(),
|
||||
role: 'USER'
|
||||
},
|
||||
|
||||
]
|
||||
|
After Width: | Height: | Size: 31 KiB |
|
After Width: | Height: | Size: 61 KiB |
|
After Width: | Height: | Size: 497 KiB |
|
After Width: | Height: | Size: 3.1 KiB |
|
After Width: | Height: | Size: 3.6 MiB |
|
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 17 KiB |
@@ -0,0 +1,18 @@
|
||||
#!/usr/bin/env sh
|
||||
|
||||
set -x
|
||||
npm run build
|
||||
set +x
|
||||
|
||||
|
||||
set -x
|
||||
npm start &
|
||||
sleep 1
|
||||
echo $! > .pidfile
|
||||
set +x
|
||||
|
||||
echo 'Maintenant...'
|
||||
echo 'Visiter https://devops.dsp-archiwebo21-ad-ec-cb-mt.fr/ '
|
||||
echo 'L_application tourne sur le docker jenkins sur via le port 3000 voici un ip a'
|
||||
ip a
|
||||
echo 'Pour fermer l_application a appuyer sur le bouton proced'
|
||||
@@ -0,0 +1,7 @@
|
||||
#!/usr/bin/env sh
|
||||
|
||||
echo 'The following command terminates the "npm start" process using its PID'
|
||||
echo '(written to ".pidfile"), all of which were conducted when "deliver.sh"'
|
||||
echo 'was executed.'
|
||||
set -x
|
||||
kill $(cat .pidfile)
|
||||
@@ -0,0 +1,20 @@
|
||||
#!/usr/bin/env sh
|
||||
|
||||
echo 'The following "npm" command (if executed) installs the "cross-env"'
|
||||
echo 'dependency into the local "node_modules" directory, which will ultimately'
|
||||
echo 'be stored in the Jenkins home directory. As described in'
|
||||
echo 'https://docs.npmjs.com/cli/install, the "--save-dev" flag causes the'
|
||||
echo '"cross-env" dependency to be installed as "devDependencies". For the'
|
||||
echo 'purposes of this tutorial, this flag is not important. However, when'
|
||||
echo 'installing this dependency, it would typically be done so using this'
|
||||
echo 'flag. For a comprehensive explanation about "devDependencies", see'
|
||||
echo 'https://stackoverflow.com/questions/18875674/whats-the-difference-between-dependencies-devdependencies-and-peerdependencies.'
|
||||
set -x
|
||||
# npm install --save-dev cross-env
|
||||
set +x
|
||||
|
||||
echo 'The following "npm" command tests that your simple Node.js/React'
|
||||
echo 'application renders satisfactorily. This command actually invokes the test'
|
||||
echo 'runner Jest (https://facebook.github.io/jest/).'
|
||||
set -x
|
||||
npm test
|
||||
@@ -0,0 +1,9 @@
|
||||
.footer-separator{
|
||||
height:100px;
|
||||
}
|
||||
@media (min-width: 992px) {
|
||||
.footer-separator{
|
||||
height:50vh;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
.bloc-content {
|
||||
padding: 10vh;
|
||||
padding: 2vh;
|
||||
border-radius: 10px;
|
||||
background-position: 50% 50%;
|
||||
background-repeat: no-repeat;
|
||||
@@ -8,6 +8,16 @@
|
||||
/* animation: zoomInOut 3s ease-in-out infinite; */
|
||||
z-index: 8888
|
||||
}
|
||||
@media (min-width: 992px) {
|
||||
.bloc-content {
|
||||
padding: 5vh;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
.cursor:hover {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.imageWrapper {
|
||||
display: block;
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
.bloc-content {
|
||||
padding: 2vh;
|
||||
border-radius: 10px;
|
||||
background-position: 50% 50%;
|
||||
background-repeat: no-repeat;
|
||||
background-size: contain;
|
||||
background-color: rgba(255, 255, 255, 0.329);
|
||||
/* animation: zoomInOut 3s ease-in-out infinite; */
|
||||
z-index: 8888
|
||||
}
|
||||
@media (min-width: 992px) {
|
||||
.bloc-content {
|
||||
padding: 10vh;
|
||||
}
|
||||
}
|
||||
|
||||
.masthead {
|
||||
padding-top: 5vh;
|
||||
position: relative;
|
||||
}
|
||||
@@ -3,9 +3,9 @@
|
||||
/* margin-top:auto; */
|
||||
width:100%;
|
||||
display: table-footer-group;
|
||||
background-color: #006600e6;
|
||||
background-color: #006600;
|
||||
}
|
||||
|
||||
/* .footerContent{
|
||||
background-color: #006600e6;
|
||||
background-color: #006600;
|
||||
} */
|
||||
@@ -9,14 +9,19 @@
|
||||
|
||||
|
||||
.bloc-content {
|
||||
padding: 10vh;
|
||||
padding: 2vh;
|
||||
border-radius: 10px;
|
||||
background-image: url('/images/codebackground.webp');
|
||||
background-position: 50% 50%;
|
||||
background-repeat: no-repeat;
|
||||
background-size: contain;
|
||||
/* animation: zoomInOut 4s ease-in-out infinite; */
|
||||
z-index: 9000;
|
||||
z-index: 8999;
|
||||
}
|
||||
@media (min-width: 992px) {
|
||||
.bloc-content {
|
||||
padding: 10vh;
|
||||
}
|
||||
}
|
||||
|
||||
.cadeau-bloc-content {
|
||||
@@ -91,6 +96,7 @@
|
||||
}
|
||||
|
||||
@keyframes blinking {
|
||||
|
||||
0%,
|
||||
50%,
|
||||
100% {
|
||||
@@ -113,7 +119,7 @@
|
||||
|
||||
.aButton {
|
||||
position: relative;
|
||||
z-index: 9992;
|
||||
z-index: 9000;
|
||||
}
|
||||
|
||||
.aButton:after {
|
||||
@@ -167,6 +173,9 @@
|
||||
width: 20vw;
|
||||
}
|
||||
|
||||
.imageContainer.zoomInOutCadeauContainer{
|
||||
z-index:9000;
|
||||
}
|
||||
|
||||
.feuilleGauche,
|
||||
.feuilleDroite,
|
||||
@@ -232,7 +241,7 @@
|
||||
|
||||
.footerGrass {
|
||||
bottom: -5px;
|
||||
background-image: url('/image/footer_image.webp');
|
||||
/* background-image: url('/image/footer_image.webp'); */
|
||||
background-repeat: repeat-x;
|
||||
background-size: contain;
|
||||
width: 100vw;
|
||||
@@ -276,4 +285,4 @@
|
||||
50% {
|
||||
right: 0;
|
||||
}
|
||||
} */
|
||||
} */
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -26,10 +26,15 @@
|
||||
}
|
||||
|
||||
.bloc-content {
|
||||
padding: 5vh;
|
||||
padding: 2vh;
|
||||
border-radius: 10px;
|
||||
background-color: rgba(255, 255, 255, 0.8);
|
||||
}
|
||||
@media (min-width: 992px) {
|
||||
.bloc-content {
|
||||
padding: 10vh;
|
||||
}
|
||||
}
|
||||
|
||||
.logo {
|
||||
position: relative;
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -26,10 +26,15 @@
|
||||
}
|
||||
|
||||
.bloc-content {
|
||||
padding: 5vh;
|
||||
padding: 2vh;
|
||||
border-radius: 10px;
|
||||
background-color: rgba(255, 255, 255, 0.8);
|
||||
}
|
||||
@media (min-width: 992px) {
|
||||
.bloc-content {
|
||||
padding: 10vh;
|
||||
}
|
||||
}
|
||||
|
||||
.logo {
|
||||
position: relative;
|
||||
|
||||
@@ -1,26 +1,55 @@
|
||||
.bloc-content {
|
||||
padding: 2vh;
|
||||
border-radius: 10px;
|
||||
background-position: 50% 50%;
|
||||
background-repeat: no-repeat;
|
||||
background-size: contain;
|
||||
background-color: rgba(255, 255, 255, 0.329);
|
||||
/* animation: zoomInOut 3s ease-in-out infinite; */
|
||||
z-index: 8888
|
||||
}
|
||||
@media (min-width: 992px) {
|
||||
.bloc-content {
|
||||
padding: 5vh;
|
||||
}
|
||||
.masthead {
|
||||
padding-top: 10vh;
|
||||
}
|
||||
}
|
||||
|
||||
.masthead {
|
||||
padding-top: 2vh;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.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;
|
||||
}
|
||||
}
|
||||
@@ -24,9 +24,14 @@
|
||||
background-repeat: no-repeat;
|
||||
box-shadow: 5px 5px 15px 5px #000000;
|
||||
}
|
||||
@media (min-width: 992px) {
|
||||
.bloc-content {
|
||||
padding: 5vh;
|
||||
}
|
||||
}
|
||||
|
||||
.bloc-content {
|
||||
padding: 5vh;
|
||||
padding: 2vh;
|
||||
border-radius: 10px;
|
||||
background-color: rgba(255, 255, 255, 0.8);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"jsx": "react"
|
||||
}
|
||||
}
|
||||
@@ -25,7 +25,7 @@
|
||||
"include": [
|
||||
"next-env.d.ts",
|
||||
"**/*.ts",
|
||||
"**/*.tsx"
|
||||
"**/*.tsx",
|
||||
],
|
||||
"ts-node": {
|
||||
"compilerOptions": {
|
||||
|
||||
@@ -5,5 +5,6 @@ export type UserGainProps = {
|
||||
dateRetrait: Date;
|
||||
produit: Produit;
|
||||
produitId: number;
|
||||
actif: Boolean;
|
||||
codeActif: true,
|
||||
retrait: false
|
||||
}
|
||||