@ -0,0 +1,25 @@
|
||||
SECRET=thetiptop123
|
||||
|
||||
NEXTAUTH_URL='http://localhost:3000'
|
||||
# GitHub oAuth
|
||||
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"
|
||||
|
||||
# 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
|
||||
|
||||
DATABASE_URL="postgres://postgres:postgrespwd@127.0.0.1:5454/thetiptop"
|
||||
|
||||
API_KEY=1234
|
||||
|
||||
|
||||
@ -0,0 +1,2 @@
|
||||
node_modules/
|
||||
.next/
|
||||
@ -0,0 +1,32 @@
|
||||
{
|
||||
// Use IntelliSense to learn about possible attributes.
|
||||
// Hover to view descriptions of existing attributes.
|
||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Next.js: debug server-side",
|
||||
"type": "node-terminal",
|
||||
"request": "launch",
|
||||
"command": "npm run dev"
|
||||
},
|
||||
{
|
||||
"name": "Next.js: debug client-side",
|
||||
"type": "chrome",
|
||||
"request": "launch",
|
||||
"url": "http://localhost:3000"
|
||||
},
|
||||
{
|
||||
"type": "node",
|
||||
"request": "launch",
|
||||
"name": "Launch Program",
|
||||
"skipFiles": [
|
||||
"<node_internals>/**"
|
||||
],
|
||||
"program": "${workspaceFolder}\\pages\\moncompte.tsx",
|
||||
"outFiles": [
|
||||
"${workspaceFolder}/**/*.js"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@ -0,0 +1,7 @@
|
||||
{
|
||||
"workbench.colorCustomizations": {
|
||||
"activityBar.background": "#521342",
|
||||
"titleBar.activeBackground": "#731B5D",
|
||||
"titleBar.activeForeground": "#FDF8FC"
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,80 @@
|
||||
# TheTipTop - Fullstack App with Next.js
|
||||
|
||||
***********************************
|
||||
_Explication rapide en français :_
|
||||
|
||||
Une fois le repo cloné lancer les commandes suivantes :
|
||||
|
||||
**Lancer docker avec Docker Destop**
|
||||
|
||||
**docker compose up**
|
||||
pour créer les containers avec la base de donnée PosgreSQL et pgAdmin
|
||||
|
||||
**npm install**
|
||||
va installer les dépendances
|
||||
|
||||
**npx prisma migrate dev**
|
||||
va hydrater la db et jouer le fichier de seed
|
||||
(important)
|
||||
|
||||
**npm run db** (pour reset les data de la db)
|
||||
va reset la db et re-executer le fichier de seed
|
||||
|
||||
**npm run dev**
|
||||
va lancer l'application sur le _localhost:3000_
|
||||
|
||||
**npx prisma studio**
|
||||
pour naviguer dans la db via le _localhost:5555_ sans utiliser pgAdmin
|
||||
|
||||
http://localhost:3000/api/superadmin?pass=1234
|
||||
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)
|
||||
|
||||
***********************************
|
||||
|
||||
|
||||
This project use TypeScript with [Next.js](https://nextjs.org/)** using [React](https://reactjs.org/) (frontend), [Next.js API routes](https://nextjs.org/docs/api-routes/introduction) and [Prisma Client](https://www.prisma.io/docs/reference/tools-and-interfaces/prisma-client) (backend). It implement authentication using [NextAuth.js](https://next-auth.js.org/). The app uses an PostgreSQL database file on docker's container.
|
||||
|
||||
Note that the app uses a mix of server-side rendering with `getServerSideProps` (SSR) and static site generation with `getStaticProps` (SSG). When possible, SSG is used to make database queries already at build-time . Sometimes, the user requesting data needs to be authenticated, so SSR is being used to render data dynamically on the server-side.
|
||||
|
||||
## Getting started
|
||||
|
||||
|
||||
Install npm dependencies:
|
||||
|
||||
```
|
||||
npm install
|
||||
```
|
||||
|
||||
|
||||
### 2. Create and seed the database
|
||||
|
||||
Run the following command to create your PostgreSQL docker's container
|
||||
|
||||
```
|
||||
docker compose up
|
||||
```
|
||||
|
||||
```
|
||||
npx prisma migrate dev
|
||||
```
|
||||
|
||||
When `npx prisma migrate dev` is executed against a newly created database, seeding is also triggered. The seed file in [`prisma/seed.ts`](./prisma/seed.ts) will be executed and your database will be populated with the sample data.
|
||||
|
||||
If you want to reset the database data run the following command
|
||||
|
||||
```
|
||||
npm run db
|
||||
```
|
||||
|
||||
|
||||
### 4. Start the app
|
||||
|
||||
```
|
||||
npm run dev
|
||||
```
|
||||
|
||||
The app is now running, navigate to [`http://localhost:3000/`](http://localhost:3000/) in your browser to explore its UI.
|
||||
|
||||
@ -0,0 +1,76 @@
|
||||
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 style from '../styles/Footer.module.css'
|
||||
|
||||
import Link from 'next/link';
|
||||
|
||||
const Footer = () => {
|
||||
return (
|
||||
<footer className={`${style.footer}`}>
|
||||
<div className={`${style['footerContent']}`}>
|
||||
<div className="container border-bottom">
|
||||
<div className="row align-items-center">
|
||||
<div className="col-sm-6 col-md-3 d-flex justify-content-center">
|
||||
<Link href="/" passHref >
|
||||
<Image
|
||||
src={logo}
|
||||
alt="thetiptop navigation logo"
|
||||
width="110"
|
||||
height="110"
|
||||
/>
|
||||
</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>
|
||||
</li>
|
||||
<li className="nav-item px-2">
|
||||
<p>contact@thetiptop.com</p>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div className="col-sm-6 col-md-3 d-flex justify-content-center align-items-md-baseline align-items-sm-center">
|
||||
|
||||
<ul className="nav flex-md-column">
|
||||
<li className="nav-item py-2 px-2">
|
||||
<Image src={logoInstagram} alt="lien instagram" width="40"
|
||||
height="40" />
|
||||
</li>
|
||||
<li className="nav-item py-2 px-2">
|
||||
<Image src={logoLinkedin} alt="lien linkedin" width="40"
|
||||
height="40" />
|
||||
</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">
|
||||
<li className="nav-item">
|
||||
<Link href="/cgu" legacyBehavior >
|
||||
<a className='px-2'>CGU</a>
|
||||
</Link>
|
||||
</li>
|
||||
<li className="nav-item">
|
||||
<Link href="/mentions-legales" legacyBehavior >
|
||||
<a className='px-2'>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>
|
||||
</div>
|
||||
</div>
|
||||
</footer>
|
||||
);
|
||||
}
|
||||
|
||||
export default Footer;
|
||||
@ -0,0 +1,17 @@
|
||||
import React, { ReactNode } from "react";
|
||||
import NavBar from "./NavBar";
|
||||
import Footer from "./Footer";
|
||||
|
||||
type Props = {
|
||||
children?: React.ReactNode;
|
||||
};
|
||||
|
||||
const Layout = ({ children }: Props) =>
|
||||
<div className="layout-container">
|
||||
<NavBar />
|
||||
{children}
|
||||
<Footer />
|
||||
</div>
|
||||
|
||||
export default Layout;
|
||||
|
||||
@ -0,0 +1,91 @@
|
||||
import React, { useRef } from "react";
|
||||
import logo from '../public/images/thetiptop_logo.webp';
|
||||
import Link from "next/link";
|
||||
import { useRouter } from "next/router";
|
||||
import { signOut, useSession } from "next-auth/react";
|
||||
import style from '../styles/NavBar.module.css';
|
||||
import Image from 'next/image';
|
||||
|
||||
import { FiArrowRight } from 'react-icons/fi';
|
||||
|
||||
const NavBar = () => {
|
||||
|
||||
const navRef = useRef<HTMLInputElement>();
|
||||
|
||||
const router = useRouter();
|
||||
const { data: session, status } = useSession();
|
||||
console.log('role', session)
|
||||
|
||||
const closeNav = () => {
|
||||
navRef.current.style.height = "0%";
|
||||
}
|
||||
|
||||
const openNav = () => {
|
||||
navRef.current.style.height = "100%";
|
||||
}
|
||||
|
||||
let visitor = (
|
||||
<nav className={`${style['navbar']}`}>
|
||||
|
||||
<div className="d-flex justify-content-center">
|
||||
<Image
|
||||
src={logo}
|
||||
|
||||
alt="thetiptop navigation logo big"
|
||||
width={250}
|
||||
height={100}
|
||||
/>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<div className={`justify-content-center text-center ${style['hidden-mobile']}`}>
|
||||
<Link href="/" legacyBehavior><a className={style.link} >Accueil</a></Link> |
|
||||
<Link href="/" legacyBehavior><a className={style.link} >Nos produits</a></Link> |
|
||||
<Link href="/contact" legacyBehavior><a className={style.link} >Contactez-nous</a></Link> |
|
||||
{!session && <Link href="/connexion" legacyBehavior><a className={style.link} >Connexion</a></Link>}
|
||||
{session && <Link href="/connexion" legacyBehavior><a className={style.link} >Mon compte</a></Link>}
|
||||
{session && <Link href="/" legacyBehavior><a onClick={() => signOut()} className={style.link} >Se déconnecter</a></Link>}
|
||||
|
||||
|
||||
{session && <span className={`${style.connexion} badge rounded-pill bg-light text-dark`}><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> |
|
||||
<Link href="/" legacyBehavior><a className={style.link} >Nos produits</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>}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</nav>
|
||||
|
||||
)
|
||||
|
||||
return (<>
|
||||
{visitor}
|
||||
</>)
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
export default NavBar;
|
||||
@ -0,0 +1,33 @@
|
||||
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,41 @@
|
||||
version: '3.5'
|
||||
|
||||
services:
|
||||
postgres:
|
||||
container_name: postgres_container
|
||||
image: postgres
|
||||
environment:
|
||||
POSTGRES_USER: ${POSTGRES_USER:-postgres}
|
||||
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-postgrespwd}
|
||||
PGDATA: /data/postgres
|
||||
volumes:
|
||||
- postgres:/data/postgres
|
||||
ports:
|
||||
- "5454:5432"
|
||||
networks:
|
||||
- postgres
|
||||
restart: unless-stopped
|
||||
|
||||
pgadmin:
|
||||
container_name: pgadmin_container
|
||||
image: dpage/pgadmin4
|
||||
environment:
|
||||
PGADMIN_DEFAULT_EMAIL: ${PGADMIN_DEFAULT_EMAIL:-pgadmin4@pgadmin.org}
|
||||
PGADMIN_DEFAULT_PASSWORD: ${PGADMIN_DEFAULT_PASSWORD:-admin}
|
||||
PGADMIN_CONFIG_SERVER_MODE: 'False'
|
||||
volumes:
|
||||
- pgadmin:/var/lib/pgadmin
|
||||
|
||||
ports:
|
||||
- "${PGADMIN_PORT:-5050}:80"
|
||||
networks:
|
||||
- postgres
|
||||
restart: unless-stopped
|
||||
|
||||
networks:
|
||||
postgres:
|
||||
driver: bridge
|
||||
|
||||
volumes:
|
||||
postgres:
|
||||
pgadmin:
|
||||
@ -0,0 +1,7 @@
|
||||
export enum Cadeaux {
|
||||
CoffretDecouvert69 = 1,
|
||||
CoffretDecouvert39 = 2,
|
||||
TheSignature = 3,
|
||||
TheDetox = 4,
|
||||
Infuseur = 5,
|
||||
}
|
||||
@ -0,0 +1,5 @@
|
||||
export enum Role {
|
||||
USER = 'USER',
|
||||
ADMIN = 'ADMIN',
|
||||
SUPERADMIN = 'SUPERADMIN'
|
||||
}
|
||||
@ -0,0 +1,20 @@
|
||||
import { PrismaClient } from "@prisma/client";
|
||||
declare let global: { prisma: PrismaClient };
|
||||
|
||||
// PrismaClient is attached to the `global` object in development to prevent
|
||||
// exhausting your database connection limit.
|
||||
//
|
||||
// Learn more:
|
||||
// https://pris.ly/d/help/next-js-best-practices
|
||||
|
||||
let prisma: PrismaClient
|
||||
|
||||
if (process.env.NODE_ENV === 'production') {
|
||||
prisma = new PrismaClient()
|
||||
} else {
|
||||
if (!global.prisma) {
|
||||
global.prisma = new PrismaClient()
|
||||
}
|
||||
prisma = global.prisma
|
||||
}
|
||||
export default prisma
|
||||
@ -0,0 +1,12 @@
|
||||
import { NextResponse } from 'next/server'
|
||||
import type { NextRequest } from 'next/server'
|
||||
|
||||
// This function can be marked `async` if using `await` inside
|
||||
export function middleware(request: NextRequest) {
|
||||
return NextResponse.redirect(new URL('/about-2', request.url))
|
||||
}
|
||||
|
||||
// See "Matching Paths" below to learn more
|
||||
export const config = {
|
||||
matcher: '/api/',
|
||||
}
|
||||
@ -0,0 +1,5 @@
|
||||
/// <reference types="next" />
|
||||
/// <reference types="next/image-types/global" />
|
||||
|
||||
// NOTE: This file should not be edited
|
||||
// see https://nextjs.org/docs/basic-features/typescript for more information.
|
||||
@ -0,0 +1,9 @@
|
||||
/** @type {import('next').NextConfig} */
|
||||
const nextConfig = {
|
||||
i18n: {
|
||||
locales: ["fr"],
|
||||
defaultLocale: "fr",
|
||||
},
|
||||
}
|
||||
|
||||
export default nextConfig;
|
||||
@ -0,0 +1,46 @@
|
||||
{
|
||||
"name": "hello-next",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"keywords": [],
|
||||
"license": "MIT",
|
||||
"author": "",
|
||||
"scripts": {
|
||||
"dev": "next",
|
||||
"build": "next build",
|
||||
"start": "next start",
|
||||
"db": "npx prisma migrate reset --force"
|
||||
},
|
||||
"dependencies": {
|
||||
"@hookform/resolvers": "^2.9.10",
|
||||
"@next-auth/prisma-adapter": "1.0.5",
|
||||
"@prisma/client": "^4.6.1",
|
||||
"@types/nodemailer": "^6.4.6",
|
||||
"bootstrap": "^5.2.2",
|
||||
"chance": "^1.1.9",
|
||||
"crypto-random-string": "^3.0.0",
|
||||
"next": "13.0.2",
|
||||
"next-auth": "4.16.4",
|
||||
"nodemailer": "^6.8.0",
|
||||
"react": "18.2.0",
|
||||
"react-dom": "18.2.0",
|
||||
"react-hook-form": "^7.39.2",
|
||||
"react-icons": "^4.6.0",
|
||||
"react-markdown": "8.0.3",
|
||||
"react-toastify": "^9.1.1",
|
||||
"yup": "^0.32.11"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/chance": "^1.1.3",
|
||||
"@types/next-auth": "3.13.0",
|
||||
"@types/node": "18.11.9",
|
||||
"@types/react": "18.0.25",
|
||||
"prisma": "^4.6.1",
|
||||
"ts-node": "10.9.1",
|
||||
"typescript": "4.8.4"
|
||||
},
|
||||
"prisma": {
|
||||
"seed": "ts-node prisma/seed.ts"
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,30 @@
|
||||
import React from "react";
|
||||
import Head from "next/head";
|
||||
|
||||
const NotFound = () => {
|
||||
|
||||
return (
|
||||
<>
|
||||
<Head>
|
||||
<title>Page introuvable</title>
|
||||
<meta name="description" content="Page introuvable" />
|
||||
<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>
|
||||
{/* 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>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default NotFound;
|
||||
@ -0,0 +1,27 @@
|
||||
import { SessionProvider } from "next-auth/react";
|
||||
import { AppProps } from "next/app";
|
||||
import { useEffect } from "react";
|
||||
|
||||
import 'bootstrap/dist/css/bootstrap.css'
|
||||
import "../styles/globals.css";
|
||||
import 'react-toastify/dist/ReactToastify.css';
|
||||
import { ToastContainer } from 'react-toastify';
|
||||
import Layout from "../components/Layout";
|
||||
|
||||
const App = ({ Component, pageProps }: AppProps) => {
|
||||
useEffect(() => {
|
||||
import("bootstrap/dist/js/bootstrap");
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<SessionProvider session={pageProps.session}>
|
||||
<Layout>
|
||||
<Component {...pageProps} />
|
||||
|
||||
</Layout>
|
||||
<ToastContainer />
|
||||
</SessionProvider>
|
||||
);
|
||||
};
|
||||
|
||||
export default App;
|
||||
@ -0,0 +1,26 @@
|
||||
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.`
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,25 @@
|
||||
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' })
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,34 @@
|
||||
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.`
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,19 @@
|
||||
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' })
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,81 @@
|
||||
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;
|
||||
@ -0,0 +1,78 @@
|
||||
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;
|
||||
@ -0,0 +1,91 @@
|
||||
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;
|
||||
@ -0,0 +1,171 @@
|
||||
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,52 @@
|
||||
import { NextApiHandler } from "next";
|
||||
import NextAuth from "next-auth";
|
||||
import Providers from "next-auth/providers";
|
||||
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'
|
||||
|
||||
|
||||
const authHandler: NextApiHandler = (req, res) => NextAuth(req, res, options);
|
||||
export default authHandler;
|
||||
|
||||
const options = {
|
||||
providers: [
|
||||
GoogleProvider({
|
||||
clientId: process.env.GOOGLE_CLIENT_ID,
|
||||
clientSecret: process.env.GOOGLE_CLIENT_SECRET,
|
||||
authorization: 'https://accounts.google.com/o/oauth2/v2/auth?prompt=consent&access_type=offline&response_type=code',
|
||||
}),
|
||||
EmailProvider({
|
||||
server: {
|
||||
host: process.env.EMAIL_SERVER_HOST,
|
||||
port: parseInt(process.env.EMAIL_SERVER_PORT),
|
||||
auth: {
|
||||
user: process.env.EMAIL_SERVER_USER,
|
||||
pass: process.env.EMAIL_SERVER_PASSWORD
|
||||
}
|
||||
},
|
||||
from: process.env.EMAIL_FROM
|
||||
}),
|
||||
],
|
||||
adapter: PrismaAdapter(prisma),
|
||||
secret: process.env.SECRET,
|
||||
callbacks: {
|
||||
async session({ session, user }) {
|
||||
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
|
||||
}
|
||||
},
|
||||
pages: {
|
||||
// signIn: '/auth/signin',
|
||||
// signOut: '/auth/signout',
|
||||
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,105 @@
|
||||
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.CoffretDecouvert69,
|
||||
Cadeaux.CoffretDecouvert39,
|
||||
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 super admin (pour les developpeurs)
|
||||
//--> http://localhost:3000/api/superadmin?pass=1234 (a effacer)
|
||||
|
||||
export default async function makeMeSuper(req: NextApiRequest, res: NextApiResponse) {
|
||||
const { pass } = req.query;
|
||||
const session = await getSession({ req })
|
||||
const goodPassword = pass === '1234';
|
||||
|
||||
//si utilisateur connecté et que le parametre 'pass' est '1234'
|
||||
if (session && goodPassword) {
|
||||
|
||||
//MAJ de l'utilisateur en superadmin
|
||||
await prisma.user.update({
|
||||
where: { email: session.user.email },
|
||||
data: {
|
||||
role: Role.SUPERADMIN,
|
||||
},
|
||||
})
|
||||
return res.status(200).send({ message: 'Profiled updated welcome SUPERADMIN !' });
|
||||
} else {
|
||||
res.status(401).send({ message: 'Unauthorized' })
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -0,0 +1,110 @@
|
||||
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 })
|
||||
const { codeCadeau } = req.body;
|
||||
const regex = /[A-Z0-9]{10}/;
|
||||
|
||||
// est-ce la méthode est un POST ?
|
||||
if (req.method !== "POST") {
|
||||
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: 'Veuillez vous connecter' });
|
||||
return;
|
||||
}
|
||||
|
||||
//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' });
|
||||
return
|
||||
}
|
||||
|
||||
//si oui ? récupération des informations concernant le code
|
||||
const codeCadeauInfo = await prisma.gain.findUnique({
|
||||
where: { codeCadeau }
|
||||
})
|
||||
|
||||
//check si le code a déja été utilisé
|
||||
if (!codeCadeauInfo.actif) {
|
||||
res.status(401).json({ err: 'Ce code a déja été utilisé' });
|
||||
return;
|
||||
}
|
||||
|
||||
//CODE BON ? =>
|
||||
//récupération des informations de l'utilisateur connecté
|
||||
const getCurrentUser = await prisma.user.findMany({
|
||||
where: { email: session.user.email },
|
||||
})
|
||||
|
||||
//ajout du gain au profil de l'utilisateur
|
||||
const joinGainWithUser = await prisma.user.update({
|
||||
where: { id: getCurrentUser[0].id },
|
||||
data: {
|
||||
gain: {
|
||||
connect: {
|
||||
id: codeCadeauInfo.id
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
//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({
|
||||
where: {
|
||||
id: codeCadeauInfo.id
|
||||
},
|
||||
data: {
|
||||
actif: false,
|
||||
dateRetrait: new Date()
|
||||
}
|
||||
})
|
||||
|
||||
//retourne l'id du produit
|
||||
res.status(200).send({ success: 'Vous avez gagner un gain !', productId: codeCadeauInfo.produitId });
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -0,0 +1,68 @@
|
||||
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(() => {
|
||||
Router.push("/")
|
||||
}, 3000)
|
||||
}, [])
|
||||
|
||||
return (
|
||||
<>
|
||||
<Head>
|
||||
<title>Page Confirmation email</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-lg-6`}>
|
||||
<h1 className="fw-light">Un email a été envoyé</h1>
|
||||
<GrValidate size={100} />
|
||||
<div className="d-grid mt-4">
|
||||
<button onClick={() => Router.push("/")} type="button" className={`btn btn-primary`}>
|
||||
Cliquez ici si vous n'êtes pas rediriger à l'accueil
|
||||
</button>
|
||||
</div>
|
||||
</div >
|
||||
</div>
|
||||
</div>
|
||||
</>)
|
||||
};
|
||||
|
||||
export default AuthError;
|
||||
|
||||
|
||||
@ -0,0 +1,187 @@
|
||||
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 { 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 },
|
||||
}
|
||||
}
|
||||
|
||||
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 {
|
||||
register,
|
||||
clearErrors,
|
||||
handleSubmit,
|
||||
watch,
|
||||
trigger,
|
||||
formState: { errors }
|
||||
} = useForm<LoginSubmitForm>({
|
||||
resolver: yupResolver(validationSchema)
|
||||
});
|
||||
|
||||
const acceptTermCheckBox = watch("acceptTerms")
|
||||
|
||||
const connexionWithGoogle = async () => {
|
||||
if (onCheckTerms()) {
|
||||
signIn("google")
|
||||
}
|
||||
await trigger("acceptTerms");
|
||||
}
|
||||
|
||||
const onMailSubmit = async (data: LoginSubmitForm) => {
|
||||
if (onCheckTerms()) {
|
||||
signIn("email", { email: data.email, callbackUrl: `${window.location.origin}/create` })
|
||||
}
|
||||
await trigger("acceptTerms");
|
||||
await trigger("email");
|
||||
}
|
||||
|
||||
|
||||
|
||||
const onCheckTerms = () => {
|
||||
if (acceptTermCheckBox) {
|
||||
return true;
|
||||
} else {
|
||||
toast.error('Vous devez accepter les conditions obligatoires', {
|
||||
position: "top-center",
|
||||
autoClose: 2000,
|
||||
hideProgressBar: false,
|
||||
closeOnClick: true,
|
||||
pauseOnHover: true,
|
||||
draggable: true,
|
||||
progress: undefined,
|
||||
theme: "light",
|
||||
});
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// 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>
|
||||
|
||||
<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">
|
||||
<input
|
||||
type="email" id="email" name="email"
|
||||
className={`mb-3 form-control ${errors.email ? 'is-invalid' : ''}`}
|
||||
placeholder="Email..."
|
||||
{...register("email")}
|
||||
/>
|
||||
<div className="d-grid">
|
||||
<button type="submit" className="btn d-grid btn-primary">
|
||||
Se connecter avec mon email
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<hr />
|
||||
<div className="d-grid">
|
||||
<button onClick={connexionWithGoogle} type="button" className={`btn btn-primary ${style.loginButton}`} style={{ backgroundColor: "#dd4b39" }}>
|
||||
<span className={style.logo}><AiOutlineGoogle /></span>Se connecter avec google
|
||||
</button>
|
||||
</div>
|
||||
<div className="form-group">
|
||||
<label
|
||||
htmlFor="acceptTerms"
|
||||
className="form-check-label"
|
||||
>
|
||||
J'ai lu et j'accepte les
|
||||
conditions
|
||||
</label>
|
||||
<input
|
||||
type="checkbox"
|
||||
className={`form-check-input ${errors.acceptTerms ? 'is-invalid' : ''}`}
|
||||
{...register("acceptTerms")}
|
||||
name="acceptTerms"
|
||||
id="acceptTerms"
|
||||
/>
|
||||
</div>
|
||||
</form>
|
||||
</div >
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</>)
|
||||
};
|
||||
|
||||
export default MainPage;
|
||||
|
||||
|
||||
@ -0,0 +1,48 @@
|
||||
import React from "react";
|
||||
import Head from "next/head";
|
||||
|
||||
|
||||
const Contact = () => {
|
||||
|
||||
return (
|
||||
<>
|
||||
<Head>
|
||||
<title>Contact</title>
|
||||
<meta name="description" content="Contact" />
|
||||
<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">
|
||||
<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>
|
||||
</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>
|
||||
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default Contact;
|
||||
@ -0,0 +1,213 @@
|
||||
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 { useForm } from "react-hook-form";
|
||||
import Router from "next/router";
|
||||
|
||||
|
||||
import style from '../styles/Index.module.css';
|
||||
|
||||
import rotatingLeftImage from '../public/images/coffret-degustation-mousselines-individuelles-n3-PhotoRoom.webp';
|
||||
import rotatingRightImage from '../public/images/coffret-the-PhotoRoom.webp';
|
||||
import Link from "next/link";
|
||||
|
||||
import testerCodeCadeau from '../public/images/testerlecode.webp'
|
||||
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 footerGrass from '../public/images/footer_image.webp'
|
||||
|
||||
// // doesn't do anything, supposed to add the land in <html>
|
||||
// import "next.config.mjs";
|
||||
|
||||
|
||||
type CodeSubmitForm = {
|
||||
codeCadeau: string;
|
||||
};
|
||||
|
||||
|
||||
const MainPage = () => {
|
||||
const { data: session } = useSession();
|
||||
const [response, setResponse] = useState(null)
|
||||
|
||||
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 onSubmit = async (data: CodeSubmitForm) => {
|
||||
|
||||
if (!errors) {
|
||||
if (!session) {
|
||||
return <Layout>
|
||||
<p>Vous devez vous connecter pour tester votre !</p>
|
||||
</Layout>
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
try {
|
||||
const body = { codeCadeau: data.codeCadeau };
|
||||
await fetch(`/api/testcode`, {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify(body),
|
||||
})
|
||||
.then((res) => res.json())
|
||||
.then((data) => {
|
||||
setResponse(data);
|
||||
console.log('response', data);
|
||||
if (data.err) {
|
||||
console.log('ERR', data);
|
||||
toast.error(data.err, {
|
||||
position: "top-center",
|
||||
autoClose: 2000,
|
||||
hideProgressBar: false,
|
||||
closeOnClick: true,
|
||||
pauseOnHover: true,
|
||||
draggable: true,
|
||||
progress: undefined,
|
||||
theme: "light",
|
||||
});
|
||||
return;
|
||||
// await Router.push("/profile");
|
||||
}
|
||||
console.log('SUCESS', data);
|
||||
toast.success(data.success, {
|
||||
position: "top-center",
|
||||
autoClose: 5000,
|
||||
hideProgressBar: false,
|
||||
closeOnClick: true,
|
||||
pauseOnHover: true,
|
||||
draggable: true,
|
||||
progress: undefined,
|
||||
theme: "light",
|
||||
});
|
||||
})
|
||||
} catch (error) {
|
||||
console.error('ERROR :', error);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
return (
|
||||
<>
|
||||
<Head>
|
||||
<title>Thé Tip Top</title>
|
||||
<meta name="description" content="Participez au jeu concours Thé Tip Top ! Recevez un cadeau, et tentez votre chance pour gagner le gros lot final !" />
|
||||
<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={`${style['masthead']} body-content`}>
|
||||
<div className="d-flex flex-wrap justify-content-center align-items-center text-center">
|
||||
<div className={`${style['feuilleGauche']} ${style['imageContainer']}`}>
|
||||
<Image
|
||||
src={feuilleGauche}
|
||||
alt="thetiptop feuille Gauche"
|
||||
layout="responsive"
|
||||
className={`${style['rotatingSlow']}`}
|
||||
/>
|
||||
</div>
|
||||
<div className={`${style['jeuConcours']} ${style['imageContainer']}`}>
|
||||
<Image
|
||||
src={jeuConcours}
|
||||
alt="thetiptop jeu Concours"
|
||||
layout="responsive"
|
||||
className={`${style['zoomInOutCadeau']}`}
|
||||
/>
|
||||
</div>
|
||||
<div className={`${style['cadeau']} ${style['imageContainer']}`}>
|
||||
<Image
|
||||
src={cadeau}
|
||||
alt="thetiptop cadeau"
|
||||
layout="responsive"
|
||||
className={`${style['zoomInOutJeuConcours']}`}
|
||||
/>
|
||||
</div>
|
||||
<div className={`${style['feuilleDroite']} ${style['imageContainer']}`}>
|
||||
<Image
|
||||
src={feuilleDroite}
|
||||
alt="thetiptop feuille Droite"
|
||||
layout="responsive"
|
||||
className={`${style['rotatingSlow']}`}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="col-12 align-items-center d-flex flex-column">
|
||||
<div className={`${style['bloc-content']} col-12 col-md-6`}>
|
||||
<div className={`${style['imageWrapper']}`}>
|
||||
<Image
|
||||
src={testerCodeCadeau}
|
||||
alt="thetiptop navigation logo"
|
||||
layout="responsive"
|
||||
className={`${style['rotatingImage']}`}
|
||||
/>
|
||||
</div>
|
||||
<form onSubmit={handleSubmit(onSubmit)}>
|
||||
<div className="form-group mx-auto my-3 w-100">
|
||||
<input type="text"
|
||||
id="codeInput" aria-describedby="codeHelp"
|
||||
placeholder="A293049430..."
|
||||
minLength={10}
|
||||
maxLength={10}
|
||||
{...register('codeCadeau')}
|
||||
className={`form-control ${errors.codeCadeau ? 'is-invalid' : ''}`}
|
||||
|
||||
/>
|
||||
<small id="codeHelp" className="form-text text-muted">Code à usage unique</small>
|
||||
<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>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
<div className={`${style['footerGrass']} position-absolute`}>
|
||||
<Image
|
||||
src={footerGrass}
|
||||
alt="thetiptop feuille Gauche"
|
||||
layout="responsive"
|
||||
// className={`${style['footerGrass']}`}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default MainPage;
|
||||
@ -0,0 +1,56 @@
|
||||
{/* <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> */}
|
||||
@ -0,0 +1,78 @@
|
||||
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/coffret-the-PhotoRoom.webp';
|
||||
import prisma from "../lib/prisma";
|
||||
|
||||
export async function getStaticProps() {
|
||||
const produits = await prisma.produit.findMany();
|
||||
|
||||
return {
|
||||
props: {
|
||||
produits,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
type Props = {
|
||||
produits: Produit[];
|
||||
}
|
||||
|
||||
type Produit = {
|
||||
id: number;
|
||||
actif: boolean;
|
||||
nomProduit: string;
|
||||
prixTtc: number;
|
||||
}
|
||||
|
||||
const ToutSavoir = ({ produits }: Props) => {
|
||||
console.log('p', produits);
|
||||
|
||||
return (
|
||||
<>
|
||||
<Head>
|
||||
<title>Tout savoir</title>
|
||||
<meta name="description" content="Tout savoir" />
|
||||
<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>
|
||||
{/* backgroundImagePath={'/images/ugh.png'} */}
|
||||
<div className="body-content">
|
||||
<h1 className="text-center mt-3">Tout savoir sur le jeu concours</h1>
|
||||
<div className="container">
|
||||
<p className="mt-5 text-center">
|
||||
Le jeu concours vous est proposé à l'occasion de ...
|
||||
</p>
|
||||
<div className="row">
|
||||
{produits.map((produit: Produit) => {
|
||||
return <div className="col-6 col-lg-3 d-flex justify-content-center my-2 my-lg-3" key={produit.id}>
|
||||
<div className={`${style.aCard} card`}>
|
||||
<Image
|
||||
className="card-img-top" src={test}
|
||||
width="286"
|
||||
height="180"
|
||||
alt="produit"
|
||||
/>
|
||||
<div className="card-body">
|
||||
<h5 className="card-title">{produit.nomProduit}</h5>
|
||||
<p className="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default ToutSavoir;
|
||||
@ -0,0 +1,68 @@
|
||||
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("/")
|
||||
}, 3000)
|
||||
}, [])
|
||||
|
||||
return (
|
||||
<>
|
||||
<Head>
|
||||
<title>Page Confirmation email</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-6`}>
|
||||
<h1 className="fw-light">Un email a été envoyé</h1>
|
||||
<GrValidate size={100} />
|
||||
<div className="d-grid mt-4">
|
||||
<button onClick={() => Router.push("/")} type="button" className={`btn btn-primary`}>
|
||||
Cliquez ici si vous n'êtes pas rediriger à l'accueil
|
||||
</button>
|
||||
</div>
|
||||
</div >
|
||||
</div>
|
||||
</div>
|
||||
</>)
|
||||
};
|
||||
|
||||
export default VerifyRequest;
|
||||
|
||||
|
||||
@ -0,0 +1,144 @@
|
||||
-- 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,
|
||||
"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 "Post" (
|
||||
"id" SERIAL NOT NULL,
|
||||
"title" TEXT NOT NULL,
|
||||
"content" TEXT,
|
||||
"published" BOOLEAN NOT NULL DEFAULT false,
|
||||
"authorId" INTEGER,
|
||||
|
||||
CONSTRAINT "Post_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "Profile" (
|
||||
"id" SERIAL NOT NULL,
|
||||
"bio" TEXT,
|
||||
"userId" INTEGER NOT NULL,
|
||||
|
||||
CONSTRAINT "Profile_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,
|
||||
|
||||
CONSTRAINT "Gain_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "Produit" (
|
||||
"id" SERIAL NOT NULL,
|
||||
"actif" BOOLEAN,
|
||||
"nomProduit" TEXT,
|
||||
"prixTtc" DECIMAL(65,30),
|
||||
|
||||
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 "Profile_userId_key" ON "Profile"("userId");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "Gain_codeCadeau_key" ON "Gain"("codeCadeau");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "Gain_userId_key" ON "Gain"("userId");
|
||||
|
||||
-- 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 "Post" ADD CONSTRAINT "Post_authorId_fkey" FOREIGN KEY ("authorId") REFERENCES "users"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Profile" ADD CONSTRAINT "Profile_userId_fkey" FOREIGN KEY ("userId") REFERENCES "users"("id") ON DELETE RESTRICT 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,2 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE "Gain" ADD COLUMN "disponible" BOOLEAN NOT NULL DEFAULT true;
|
||||
@ -0,0 +1,9 @@
|
||||
/*
|
||||
Warnings:
|
||||
|
||||
- You are about to drop the column `disponible` on the `Gain` table. All the data in the column will be lost.
|
||||
|
||||
*/
|
||||
-- AlterTable
|
||||
ALTER TABLE "Gain" DROP COLUMN "disponible",
|
||||
ADD COLUMN "actif" BOOLEAN NOT NULL DEFAULT true;
|
||||
@ -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"
|
||||
@ -0,0 +1,113 @@
|
||||
generator client {
|
||||
provider = "prisma-client-js"
|
||||
}
|
||||
|
||||
datasource db {
|
||||
provider = "postgresql"
|
||||
url = env("DATABASE_URL")
|
||||
}
|
||||
|
||||
model Account {
|
||||
id Int @id @default(autoincrement())
|
||||
userId Int @map("user_id")
|
||||
type String
|
||||
provider String
|
||||
providerAccountId String @map("provider_account_id")
|
||||
refresh_token String?
|
||||
access_token String?
|
||||
expires_at Int?
|
||||
token_type String?
|
||||
scope String?
|
||||
id_token String?
|
||||
session_state String?
|
||||
oauth_token_secret String?
|
||||
oauth_token String?
|
||||
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
|
||||
@@unique([provider, providerAccountId])
|
||||
@@map("accounts")
|
||||
}
|
||||
|
||||
model Session {
|
||||
id Int @id @default(autoincrement())
|
||||
sessionToken String @unique @map("session_token")
|
||||
userId Int @map("user_id")
|
||||
expires DateTime
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
|
||||
@@map("sessions")
|
||||
}
|
||||
|
||||
model User {
|
||||
id Int @id @default(autoincrement())
|
||||
name String?
|
||||
email String? @unique
|
||||
emailVerified DateTime? @map("email_verified")
|
||||
image String?
|
||||
createdAt DateTime @default(now()) @map(name: "created_at")
|
||||
updatedAt DateTime @updatedAt @map(name: "updated_at")
|
||||
posts Post[]
|
||||
accounts Account[]
|
||||
sessions Session[]
|
||||
profile Profile?
|
||||
gain Gain?
|
||||
role Role @default(USER)
|
||||
|
||||
@@map(name: "users")
|
||||
}
|
||||
|
||||
model Post {
|
||||
id Int @id @default(autoincrement())
|
||||
title String
|
||||
content String?
|
||||
published Boolean @default(false)
|
||||
author User? @relation(fields: [authorId], references: [id])
|
||||
authorId Int?
|
||||
}
|
||||
|
||||
model Profile {
|
||||
id Int @id @default(autoincrement())
|
||||
bio String?
|
||||
user User? @relation(fields: [userId], references: [id])
|
||||
userId Int @unique
|
||||
}
|
||||
|
||||
model TicketsRestants {
|
||||
id Int @id @default(autoincrement())
|
||||
total Int
|
||||
}
|
||||
|
||||
model Gain {
|
||||
id Int @id @default(autoincrement())
|
||||
codeCadeau String @unique
|
||||
dateRetrait DateTime?
|
||||
produit Produit? @relation(fields: [produitId], references: [id])
|
||||
produitId Int?
|
||||
user User? @relation(fields: [userId], references: [id])
|
||||
userId Int? @unique
|
||||
actif Boolean @default(true)
|
||||
}
|
||||
|
||||
model Produit {
|
||||
id Int @id @default(autoincrement())
|
||||
actif Boolean?
|
||||
nomProduit String?
|
||||
prixTtc Int?
|
||||
refGain Gain[]
|
||||
}
|
||||
|
||||
enum Role {
|
||||
USER
|
||||
ADMIN
|
||||
SUPERADMIN
|
||||
}
|
||||
|
||||
model VerificationToken {
|
||||
identifier String
|
||||
token String @unique
|
||||
expires DateTime
|
||||
|
||||
@@unique([identifier, token])
|
||||
@@map("verificationtokens")
|
||||
}
|
||||
@ -0,0 +1,57 @@
|
||||
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'
|
||||
|
||||
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) {
|
||||
const produit = await prisma.produit.create({
|
||||
data: p,
|
||||
})
|
||||
console.log(`Created produit: ${produit.nomProduit}`)
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
//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();
|
||||
}
|
||||
|
||||
console.log(`Seeding finished.`)
|
||||
}
|
||||
|
||||
|
||||
main()
|
||||
.then(async () => {
|
||||
await prisma.$disconnect()
|
||||
})
|
||||
.catch(async (e) => {
|
||||
console.error(e)
|
||||
await prisma.$disconnect()
|
||||
process.exit(1)
|
||||
})
|
||||
@ -0,0 +1,50 @@
|
||||
// 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.CoffretDecouvert69,
|
||||
Cadeaux.CoffretDecouvert39,
|
||||
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}`)
|
||||
}
|
||||
|
||||
|
||||
@ -0,0 +1,24 @@
|
||||
import { Prisma } from "@prisma/client";
|
||||
|
||||
export const produitsData: Prisma.ProduitCreateInput[] = [
|
||||
{
|
||||
nomProduit: 'coffret découverte à 69€',
|
||||
prixTtc: 69,
|
||||
|
||||
},
|
||||
{
|
||||
nomProduit: 'coffret découverte à 39€',
|
||||
prixTtc: 39,
|
||||
},
|
||||
{
|
||||
nomProduit: 'thé signature',
|
||||
prixTtc: 10,
|
||||
},
|
||||
{
|
||||
nomProduit: 'thé détox ou infusion',
|
||||
prixTtc: 6,
|
||||
},
|
||||
{
|
||||
nomProduit: 'infuseur à thé',
|
||||
prixTtc: 3,
|
||||
}]
|
||||
@ -0,0 +1,47 @@
|
||||
import { Prisma } from "@prisma/client";
|
||||
|
||||
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,
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'Nilu',
|
||||
email: 'nilu@prisma.io',
|
||||
posts: {
|
||||
create: [
|
||||
{
|
||||
title: 'Follow Prisma on Twitter',
|
||||
content: 'https://www.twitter.com/prisma',
|
||||
published: true,
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
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',
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
]
|
||||
|
After Width: | Height: | Size: 114 KiB |
|
After Width: | Height: | Size: 1.2 MiB |
|
After Width: | Height: | Size: 2.6 MiB |
|
After Width: | Height: | Size: 27 KiB |
|
After Width: | Height: | Size: 52 KiB |
|
After Width: | Height: | Size: 30 KiB |
|
After Width: | Height: | Size: 61 KiB |
|
After Width: | Height: | Size: 7.1 KiB |
|
After Width: | Height: | Size: 45 KiB |
|
After Width: | Height: | Size: 45 KiB |
|
After Width: | Height: | Size: 7.1 KiB |
|
After Width: | Height: | Size: 70 KiB |
|
After Width: | Height: | Size: 2.8 MiB |
|
After Width: | Height: | Size: 575 KiB |
|
After Width: | Height: | Size: 900 KiB |
|
After Width: | Height: | Size: 58 KiB |
|
After Width: | Height: | Size: 26 KiB |
|
After Width: | Height: | Size: 186 KiB |
|
After Width: | Height: | Size: 2.5 KiB |
|
After Width: | Height: | Size: 1.7 KiB |
|
After Width: | Height: | Size: 4.3 KiB |
|
After Width: | Height: | Size: 278 KiB |
|
After Width: | Height: | Size: 42 KiB |
|
After Width: | Height: | Size: 134 KiB |
|
After Width: | Height: | Size: 16 MiB |
|
After Width: | Height: | Size: 20 MiB |
|
After Width: | Height: | Size: 332 KiB |
|
After Width: | Height: | Size: 60 KiB |
|
After Width: | Height: | Size: 226 KiB |
|
After Width: | Height: | Size: 497 KiB |
|
After Width: | Height: | Size: 15 KiB |
|
After Width: | Height: | Size: 713 KiB |
|
After Width: | Height: | Size: 726 KiB |
|
After Width: | Height: | Size: 80 KiB |
|
After Width: | Height: | Size: 662 KiB |
|
After Width: | Height: | Size: 21 MiB |
|
After Width: | Height: | Size: 10 MiB |
|
After Width: | Height: | Size: 13 MiB |
|
After Width: | Height: | Size: 58 KiB |
|
After Width: | Height: | Size: 452 KiB |
|
After Width: | Height: | Size: 4.3 KiB |
|
After Width: | Height: | Size: 2.7 KiB |
|
After Width: | Height: | Size: 9.3 KiB |
|
After Width: | Height: | Size: 549 KiB |
|
After Width: | Height: | Size: 2.7 MiB |
|
After Width: | Height: | Size: 33 KiB |
|
After Width: | Height: | Size: 95 KiB |
|
After Width: | Height: | Size: 15 MiB |
|
After Width: | Height: | Size: 12 MiB |