Added CSRF & YouTube and dark mode
This commit is contained in:
@@ -15,3 +15,10 @@ FRONTEND_HOSTNAME=${FRONTEND_HOSTNAME:-latosa-frontend}
|
|||||||
BACKEND_HOSTNAME=${BACKEND_HOSTNAME:-latosa-backend}
|
BACKEND_HOSTNAME=${BACKEND_HOSTNAME:-latosa-backend}
|
||||||
DATABASE_HOSTNAME=${DATABASE_HOSTNAME:-latosa-database}
|
DATABASE_HOSTNAME=${DATABASE_HOSTNAME:-latosa-database}
|
||||||
SERVER_NAME=${SERVER_NAME:-localhost}
|
SERVER_NAME=${SERVER_NAME:-localhost}
|
||||||
|
CORS_AllowOrigin=${CORS_AllowOrigin:-*}
|
||||||
|
|
||||||
|
SMTP_DOMAIN=${SMTP_DOMAIN:-smtp.gmail.com}
|
||||||
|
SMTP_PORT=${SMTP_PORT:-587}
|
||||||
|
SMTP_EMAIL=${SMTP_EMAIL}
|
||||||
|
SMTP_APP_PASSWORD=${SMTP_APP_PASSWORD}
|
||||||
|
YOUTUBE_API_KEY=${YOUTUBE_API_KEY}
|
||||||
|
|||||||
61
backend/api/contact.go
Normal file
61
backend/api/contact.go
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
package api
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
|
"net/http"
|
||||||
|
"os"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
|
"fr.latosa-escrima/api/core"
|
||||||
|
"gopkg.in/gomail.v2"
|
||||||
|
)
|
||||||
|
|
||||||
|
type ContactForm struct {
|
||||||
|
Firstname string `json:"firstname"`
|
||||||
|
Lastname string `json:"lastname"`
|
||||||
|
EMail string `json:"email"`
|
||||||
|
Subject string `json:"subject"`
|
||||||
|
Message string `json:"message"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func HandleContact(w http.ResponseWriter, r *http.Request) {
|
||||||
|
// TODO: Warning email not being sent ?
|
||||||
|
var form ContactForm
|
||||||
|
err := json.NewDecoder(r.Body).Decode(&form)
|
||||||
|
if err != nil {
|
||||||
|
core.JSONError{
|
||||||
|
Status: core.Error,
|
||||||
|
Message: err.Error(),
|
||||||
|
}.Respond(w, http.StatusBadRequest)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Println("Received form", form)
|
||||||
|
fmt.Println("ENV:", os.Environ())
|
||||||
|
|
||||||
|
m := gomail.NewMessage()
|
||||||
|
m.SetHeader("From", os.Getenv("SMTP_EMAIL"))
|
||||||
|
// m.SetHeader("Reply-To", form.EMail)
|
||||||
|
m.SetHeader("To", os.Getenv("SMTP_EMAIL"))
|
||||||
|
m.SetHeader("Subject", form.Subject)
|
||||||
|
m.SetBody("text/plain", fmt.Sprintf("%s %s vous a envoyé un email:\n\n%s", form.Firstname, form.Lastname, form.Message))
|
||||||
|
port, err := strconv.Atoi(os.Getenv("SMTP_PORT"))
|
||||||
|
if err != nil {
|
||||||
|
port = 587
|
||||||
|
}
|
||||||
|
d := gomail.NewDialer(os.Getenv("SMTP_DOMAIN"), port, os.Getenv("SMTP_EMAIL"), os.Getenv("SMTP_APP_PASSWORD"))
|
||||||
|
|
||||||
|
if err = d.DialAndSend(); err != nil {
|
||||||
|
core.JSONError{
|
||||||
|
Status: core.Error,
|
||||||
|
Message: err.Error(),
|
||||||
|
}.Respond(w, http.StatusInternalServerError)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
core.JSONSuccess{
|
||||||
|
Status: core.Success,
|
||||||
|
Message: "Email sent.",
|
||||||
|
}.Respond(w, http.StatusAccepted)
|
||||||
|
}
|
||||||
3
backend/api/core/csrf.go
Normal file
3
backend/api/core/csrf.go
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
package core
|
||||||
|
|
||||||
|
var CSRF_KEY = []byte("32-byte-long-auth-key")
|
||||||
19
backend/api/get_csrf.go
Normal file
19
backend/api/get_csrf.go
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
package api
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"fr.latosa-escrima/api/core"
|
||||||
|
"github.com/gorilla/csrf"
|
||||||
|
)
|
||||||
|
|
||||||
|
func HandleCSRF(w http.ResponseWriter, r *http.Request) {
|
||||||
|
token := csrf.Token(r)
|
||||||
|
fmt.Println(token)
|
||||||
|
core.JSONSuccess{
|
||||||
|
Status: core.Success,
|
||||||
|
Message: "CSRF generated.",
|
||||||
|
Data: map[string]string{"csrf": token},
|
||||||
|
}.Respond(w, http.StatusOK)
|
||||||
|
}
|
||||||
@@ -12,6 +12,12 @@ require (
|
|||||||
github.com/uptrace/bun/driver/pgdriver v1.2.8
|
github.com/uptrace/bun/driver/pgdriver v1.2.8
|
||||||
)
|
)
|
||||||
|
|
||||||
|
require (
|
||||||
|
github.com/gorilla/csrf v1.7.2 // direct
|
||||||
|
github.com/gorilla/securecookie v1.1.2 // indirect
|
||||||
|
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc // indirect
|
||||||
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/fatih/color v1.18.0 // indirect
|
github.com/fatih/color v1.18.0 // indirect
|
||||||
github.com/jinzhu/inflection v1.0.0 // indirect
|
github.com/jinzhu/inflection v1.0.0 // indirect
|
||||||
@@ -24,5 +30,6 @@ require (
|
|||||||
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
|
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
|
||||||
golang.org/x/crypto v0.31.0 // indirect
|
golang.org/x/crypto v0.31.0 // indirect
|
||||||
golang.org/x/sys v0.29.0 // indirect
|
golang.org/x/sys v0.29.0 // indirect
|
||||||
|
gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df
|
||||||
mellium.im/sasl v0.3.2 // indirect
|
mellium.im/sasl v0.3.2 // indirect
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -8,6 +8,10 @@ github.com/golang-jwt/jwt/v5 v5.2.1 h1:OuVbFODueb089Lh128TAcimifWaLhJwVflnrgM17w
|
|||||||
github.com/golang-jwt/jwt/v5 v5.2.1/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk=
|
github.com/golang-jwt/jwt/v5 v5.2.1/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk=
|
||||||
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
|
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
|
||||||
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||||
|
github.com/gorilla/csrf v1.7.2 h1:oTUjx0vyf2T+wkrx09Trsev1TE+/EbDAeHtSTbtC2eI=
|
||||||
|
github.com/gorilla/csrf v1.7.2/go.mod h1:F1Fj3KG23WYHE6gozCmBAezKookxbIvUJT+121wTuLk=
|
||||||
|
github.com/gorilla/securecookie v1.1.2 h1:YCIWL56dvtr73r6715mJs5ZvhtnY73hBvEF8kXD8ePA=
|
||||||
|
github.com/gorilla/securecookie v1.1.2/go.mod h1:NfCASbcHqRSY+3a8tlWJwsQap2VX5pwzwo4h3eOamfo=
|
||||||
github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E=
|
github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E=
|
||||||
github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc=
|
github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc=
|
||||||
github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
|
github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
|
||||||
@@ -45,6 +49,10 @@ golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBc
|
|||||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.29.0 h1:TPYlXGxvx1MGTn2GiZDhnjPA9wZzZeGKHHmKhHYvgaU=
|
golang.org/x/sys v0.29.0 h1:TPYlXGxvx1MGTn2GiZDhnjPA9wZzZeGKHHmKhHYvgaU=
|
||||||
golang.org/x/sys v0.29.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
golang.org/x/sys v0.29.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||||
|
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc h1:2gGKlE2+asNV9m7xrywl36YYNnBG5ZQ0r/BOOxqPpmk=
|
||||||
|
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc/go.mod h1:m7x9LTH6d71AHyAX77c9yqWCCa3UKHcVEj9y7hAtKDk=
|
||||||
|
gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df h1:n7WqCuqOuCbNr617RXOY0AWRXxgwEyPp2z+p0+hgMuE=
|
||||||
|
gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df/go.mod h1:LRQQ+SO6ZHR7tOkpBDuZnXENFzX8qRjMDMyPD6BRkCw=
|
||||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
mellium.im/sasl v0.3.2 h1:PT6Xp7ccn9XaXAnJ03FcEjmAn7kK1x7aoXV6F+Vmrl0=
|
mellium.im/sasl v0.3.2 h1:PT6Xp7ccn9XaXAnJ03FcEjmAn7kK1x7aoXV6F+Vmrl0=
|
||||||
|
|||||||
@@ -2,29 +2,34 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/joho/godotenv"
|
|
||||||
"github.com/uptrace/bun/extra/bundebug"
|
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
|
"github.com/joho/godotenv"
|
||||||
|
"github.com/uptrace/bun/extra/bundebug"
|
||||||
|
|
||||||
_ "github.com/lib/pq"
|
_ "github.com/lib/pq"
|
||||||
|
|
||||||
api "fr.latosa-escrima/api"
|
"fr.latosa-escrima/api"
|
||||||
"fr.latosa-escrima/api/core"
|
"fr.latosa-escrima/api/core"
|
||||||
|
"github.com/gorilla/csrf"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var CORS_AllowOrigin string
|
||||||
|
|
||||||
func handler(w http.ResponseWriter, r *http.Request) {
|
func handler(w http.ResponseWriter, r *http.Request) {
|
||||||
fmt.Fprintf(w, "<html><body><h1>Hello, World!</h1></body></html>")
|
fmt.Fprintf(w, "<html><body><h1>Hello, World!</h1></body></html>")
|
||||||
}
|
}
|
||||||
func Cors(next http.Handler) http.Handler {
|
func Cors(next http.Handler) http.Handler {
|
||||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
// Allow all origins (can restrict to specific origins)
|
// Allow all origins (can restrict to specific origins)
|
||||||
w.Header().Set("Access-Control-Allow-Origin", "*")
|
w.Header().Set("Access-Control-Allow-Origin", CORS_AllowOrigin)
|
||||||
// Allow certain HTTP methods (you can customize these as needed)
|
// Allow certain HTTP methods (you can customize these as needed)
|
||||||
w.Header().Set("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS, PATCH")
|
w.Header().Set("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS, PATCH")
|
||||||
// Allow certain headers (you can add more as needed)
|
// Allow certain headers (you can add more as needed)
|
||||||
w.Header().Set("Access-Control-Allow-Headers", "Content-Type, Authorization")
|
w.Header().Set("Access-Control-Allow-Headers", "Content-Type, Authorization, X-CSRF-Token")
|
||||||
|
w.Header().Set("Access-Control-Allow-Credentials", "true")
|
||||||
// Handle OPTIONS pre-flight request
|
// Handle OPTIONS pre-flight request
|
||||||
if r.Method == http.MethodOptions {
|
if r.Method == http.MethodOptions {
|
||||||
return
|
return
|
||||||
@@ -43,6 +48,7 @@ func main() {
|
|||||||
port := os.Getenv("BACKEND_DOCKER_PORT")
|
port := os.Getenv("BACKEND_DOCKER_PORT")
|
||||||
hostname := os.Getenv("DATABASE_HOSTNAME")
|
hostname := os.Getenv("DATABASE_HOSTNAME")
|
||||||
postgres_port := os.Getenv("POSTGRES_DOCKER_PORT")
|
postgres_port := os.Getenv("POSTGRES_DOCKER_PORT")
|
||||||
|
CORS_AllowOrigin = os.Getenv("CORS_AllowOrigin")
|
||||||
if environ == "DEV" {
|
if environ == "DEV" {
|
||||||
port = os.Getenv("BACKEND_PORT")
|
port = os.Getenv("BACKEND_PORT")
|
||||||
hostname = "localhost"
|
hostname = "localhost"
|
||||||
@@ -66,6 +72,12 @@ func main() {
|
|||||||
|
|
||||||
defer core.DB.Close()
|
defer core.DB.Close()
|
||||||
|
|
||||||
|
CSRFMiddleware := csrf.Protect(
|
||||||
|
core.CSRF_KEY,
|
||||||
|
csrf.Secure(environ != "DEV"),
|
||||||
|
csrf.HttpOnly(true),
|
||||||
|
)
|
||||||
|
|
||||||
mux := http.NewServeMux()
|
mux := http.NewServeMux()
|
||||||
|
|
||||||
core.HandleRoutes(mux, map[string]core.Handler{
|
core.HandleRoutes(mux, map[string]core.Handler{
|
||||||
@@ -108,6 +120,14 @@ func main() {
|
|||||||
Handler: api.HandleVerifyMedia,
|
Handler: api.HandleVerifyMedia,
|
||||||
Middlewares: []core.Middleware{api.Methods("POST"), api.AuthJWT},
|
Middlewares: []core.Middleware{api.Methods("POST"), api.AuthJWT},
|
||||||
},
|
},
|
||||||
|
"/contact": {
|
||||||
|
Handler: api.HandleContact,
|
||||||
|
Middlewares: []core.Middleware{api.Methods("POST"), CSRFMiddleware},
|
||||||
|
},
|
||||||
|
"/csrf-token": {
|
||||||
|
Handler: api.HandleCSRF,
|
||||||
|
Middlewares: []core.Middleware{api.Methods("GET"), CSRFMiddleware},
|
||||||
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
fmt.Printf("Serving on port %s\n", port)
|
fmt.Printf("Serving on port %s\n", port)
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ services:
|
|||||||
depends_on:
|
depends_on:
|
||||||
- psql
|
- psql
|
||||||
volumes:
|
volumes:
|
||||||
- ./backend/media:/media
|
- ./backend/media:/app/media
|
||||||
build:
|
build:
|
||||||
context: ./backend/
|
context: ./backend/
|
||||||
dockerfile: Dockerfile
|
dockerfile: Dockerfile
|
||||||
|
|||||||
@@ -9,21 +9,19 @@ export default async function HistoryDetails({
|
|||||||
params: Promise<{ blog_id: string }>;
|
params: Promise<{ blog_id: string }>;
|
||||||
}) {
|
}) {
|
||||||
const { blog_id } = await params;
|
const { blog_id } = await params;
|
||||||
let blog = {}
|
let blog = {};
|
||||||
try {
|
try {
|
||||||
const res = await fetch('http://localhost:3001/blogs/' + blog_id, {method: "GET"})
|
const res = await fetch("http://localhost:3001/blogs/" + blog_id, {
|
||||||
blog = await res.json()
|
method: "GET",
|
||||||
console.log(blog as Blog)
|
});
|
||||||
} catch(e) {
|
blog = await res.json();
|
||||||
|
console.log(blog as Blog);
|
||||||
|
} catch (e) {
|
||||||
console.log(e);
|
console.log(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(blog == null) {
|
if (blog == null) {
|
||||||
return(
|
return <>Error</>;
|
||||||
<>
|
|
||||||
Error
|
|
||||||
</>
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const blog_item_params: BlogItemParams = {
|
const blog_item_params: BlogItemParams = {
|
||||||
|
|||||||
@@ -4,8 +4,16 @@ import Features, { FeatureItem } from "@/components/features";
|
|||||||
import Gallery from "@/components/gallery";
|
import Gallery from "@/components/gallery";
|
||||||
import Hero from "@/components/hero";
|
import Hero from "@/components/hero";
|
||||||
import Testimonial from "@/components/testimonial";
|
import Testimonial from "@/components/testimonial";
|
||||||
|
import { CarouselItem } from "@/components/ui/carousel";
|
||||||
|
import { IYoutube } from "@/interfaces/youtube";
|
||||||
|
|
||||||
export default async function Home() {
|
export default async function Home() {
|
||||||
|
let videos: IYoutube | null = null;
|
||||||
|
if (process.env.YOUTUBE_API_KEY) {
|
||||||
|
const query = `https://www.googleapis.com/youtube/v3/search?key=${process.env.YOUTUBE_API_KEY}&channelId=UCzuFLl5I0WxSMqbeMaiq_FQ&part=snippet,id&order=date&maxResults=50`;
|
||||||
|
const res = await fetch(query);
|
||||||
|
videos = await res.json();
|
||||||
|
}
|
||||||
return (
|
return (
|
||||||
<main>
|
<main>
|
||||||
<Hero />
|
<Hero />
|
||||||
@@ -20,10 +28,10 @@ export default async function Home() {
|
|||||||
position="left"
|
position="left"
|
||||||
image="https://shadcnblocks.com/images/block/placeholder-2.svg"
|
image="https://shadcnblocks.com/images/block/placeholder-2.svg"
|
||||||
>
|
>
|
||||||
<ol className="list-decimal text-justify flex flex-col gap-4">
|
<ol className="flex list-decimal flex-col gap-4 text-justify">
|
||||||
<li>
|
<li>
|
||||||
Un Système Centré sur les Concepts{" "}
|
Un Système Centré sur les Concepts{" "}
|
||||||
<ul className="list-disc list-inside">
|
<ul className="list-inside list-disc">
|
||||||
<li>
|
<li>
|
||||||
Étude et application des meilleurs
|
Étude et application des meilleurs
|
||||||
concepts et stratégies issus de
|
concepts et stratégies issus de
|
||||||
@@ -37,7 +45,7 @@ export default async function Home() {
|
|||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
Éducation au Mouvement et à l’Efficacité
|
Éducation au Mouvement et à l’Efficacité
|
||||||
<ul className="list-disc list-inside">
|
<ul className="list-inside list-disc">
|
||||||
<li>
|
<li>
|
||||||
Plus qu’un enchaînement de techniques :
|
Plus qu’un enchaînement de techniques :
|
||||||
une véritable éducation aux mouvements
|
une véritable éducation aux mouvements
|
||||||
@@ -56,12 +64,12 @@ export default async function Home() {
|
|||||||
position="right"
|
position="right"
|
||||||
image="https://shadcnblocks.com/images/block/placeholder-2.svg"
|
image="https://shadcnblocks.com/images/block/placeholder-2.svg"
|
||||||
>
|
>
|
||||||
<ol className="list-none text-justify flex flex-col gap-4">
|
<ol className="flex list-none flex-col gap-4 text-justify">
|
||||||
<li>
|
<li>
|
||||||
<span className="font-bold">
|
<span className="font-bold">
|
||||||
Les Premières Étapes
|
Les Premières Étapes
|
||||||
</span>
|
</span>
|
||||||
<ul className="list-disc list-inside">
|
<ul className="list-inside list-disc">
|
||||||
<li>
|
<li>
|
||||||
Initialement centré sur les techniques
|
Initialement centré sur les techniques
|
||||||
et mouvements, le système s’est montré
|
et mouvements, le système s’est montré
|
||||||
@@ -78,10 +86,10 @@ export default async function Home() {
|
|||||||
<span className="font-bold">
|
<span className="font-bold">
|
||||||
La Découverte des Concepts Clés
|
La Découverte des Concepts Clés
|
||||||
</span>{" "}
|
</span>{" "}
|
||||||
<ul className="list-disc list-inside">
|
<ul className="list-inside list-disc">
|
||||||
<li>
|
<li>
|
||||||
Rôle central des concepts de combat :
|
Rôle central des concepts de combat :
|
||||||
<ul className="list-disc list-inside pl-4">
|
<ul className="list-inside list-disc pl-4">
|
||||||
<li>Puissance dans les frappes.</li>
|
<li>Puissance dans les frappes.</li>
|
||||||
<li>Blocage ferme.</li>
|
<li>Blocage ferme.</li>
|
||||||
<li>Équilibre et attitude.</li>
|
<li>Équilibre et attitude.</li>
|
||||||
@@ -103,7 +111,7 @@ export default async function Home() {
|
|||||||
>
|
>
|
||||||
Latosa Escrima Concepts repose sur cinq concepts
|
Latosa Escrima Concepts repose sur cinq concepts
|
||||||
fondamentaux :
|
fondamentaux :
|
||||||
<ul className="list-disc list-inside">
|
<ul className="list-inside list-disc">
|
||||||
<li>Équilibre</li>
|
<li>Équilibre</li>
|
||||||
<li>Vitesse (Timing et Distance)</li>
|
<li>Vitesse (Timing et Distance)</li>
|
||||||
<li>Puissance</li>
|
<li>Puissance</li>
|
||||||
@@ -112,8 +120,35 @@ export default async function Home() {
|
|||||||
</ul>
|
</ul>
|
||||||
</FeatureItem>
|
</FeatureItem>
|
||||||
</Features>
|
</Features>
|
||||||
<Gallery />
|
<Gallery
|
||||||
<Gallery />
|
tagLine="Tag Line"
|
||||||
|
cta="Book a demo"
|
||||||
|
ctaHref="#"
|
||||||
|
title="Gallery"
|
||||||
|
/>
|
||||||
|
{videos && (
|
||||||
|
<Gallery
|
||||||
|
tagLine=""
|
||||||
|
cta="Accéder à la chaîne"
|
||||||
|
ctaHref="https://youtube.com/@WingTsunPicardie"
|
||||||
|
title="Vidéos YouTube"
|
||||||
|
>
|
||||||
|
{videos.items.map((video) => {
|
||||||
|
return (
|
||||||
|
<CarouselItem
|
||||||
|
key={video.id.videoId}
|
||||||
|
className="pl-[20px] md:max-w-[452px]"
|
||||||
|
>
|
||||||
|
<iframe
|
||||||
|
width="424"
|
||||||
|
height="238"
|
||||||
|
src={`https://www.youtube.com/embed/${video.id.videoId}`}
|
||||||
|
></iframe>
|
||||||
|
</CarouselItem>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</Gallery>
|
||||||
|
)}
|
||||||
<Testimonial />
|
<Testimonial />
|
||||||
</div>
|
</div>
|
||||||
</main>
|
</main>
|
||||||
|
|||||||
199
frontend/app/(main)/planning/page.tsx
Normal file
199
frontend/app/(main)/planning/page.tsx
Normal file
@@ -0,0 +1,199 @@
|
|||||||
|
"use client";
|
||||||
|
|
||||||
|
import "@schedule-x/theme-shadcn/dist/index.css";
|
||||||
|
import { useNextCalendarApp, ScheduleXCalendar } from "@schedule-x/react";
|
||||||
|
import { createEventsServicePlugin } from "@schedule-x/events-service";
|
||||||
|
import {
|
||||||
|
CalendarEventExternal,
|
||||||
|
createViewDay,
|
||||||
|
createViewWeek,
|
||||||
|
} from "@schedule-x/calendar";
|
||||||
|
import { useEffect, useState } from "react";
|
||||||
|
import { format } from "date-fns";
|
||||||
|
import { Dialog } from "@radix-ui/react-dialog";
|
||||||
|
import {
|
||||||
|
DialogContent,
|
||||||
|
DialogDescription,
|
||||||
|
DialogFooter,
|
||||||
|
DialogHeader,
|
||||||
|
DialogTitle,
|
||||||
|
} from "@/components/ui/dialog";
|
||||||
|
import { Label } from "@/components/ui/label";
|
||||||
|
import { Input } from "@/components/ui/input";
|
||||||
|
import { Button } from "@/components/ui/button";
|
||||||
|
import {
|
||||||
|
Popover,
|
||||||
|
PopoverContent,
|
||||||
|
PopoverTrigger,
|
||||||
|
} from "@/components/ui/popover";
|
||||||
|
import { CalendarIcon } from "lucide-react";
|
||||||
|
import { Calendar } from "@/components/ui/calendar";
|
||||||
|
import { cn } from "@/lib/utils";
|
||||||
|
|
||||||
|
const Planning = () => {
|
||||||
|
const plugins = [createEventsServicePlugin()];
|
||||||
|
const [eventSelected, setEventSelected] =
|
||||||
|
useState<CalendarEventExternal | null>(null);
|
||||||
|
const [events, setEvents] = useState<CalendarEventExternal[]>([
|
||||||
|
{
|
||||||
|
id: "1",
|
||||||
|
title: "Event 1",
|
||||||
|
start: format(new Date(Date.now()), "yyyy-MM-dd HH:mm"),
|
||||||
|
end: format(
|
||||||
|
new Date(Date.now() + 1 * 3600 * 1000),
|
||||||
|
"yyyy-MM-dd HH:mm",
|
||||||
|
),
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
const calendar = useNextCalendarApp(
|
||||||
|
{
|
||||||
|
theme: "shadcn",
|
||||||
|
views: [createViewDay(), createViewWeek()],
|
||||||
|
defaultView: "week",
|
||||||
|
isDark: true,
|
||||||
|
isResponsive: true,
|
||||||
|
locale: "fr-FR",
|
||||||
|
dayBoundaries: {
|
||||||
|
start: "06:00",
|
||||||
|
end: "00:00",
|
||||||
|
},
|
||||||
|
events,
|
||||||
|
callbacks: {
|
||||||
|
onEventClick(event, e) {
|
||||||
|
setEventSelected(event);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
plugins,
|
||||||
|
);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
// get all events
|
||||||
|
calendar?.events.getAll();
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<div className="m-8">
|
||||||
|
<ScheduleXCalendar calendarApp={calendar} />
|
||||||
|
</div>
|
||||||
|
<Dialog
|
||||||
|
open={eventSelected !== null}
|
||||||
|
onOpenChange={(open) => {
|
||||||
|
setEventSelected((e) => (open ? e : null));
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<DialogContent className="sm:max-w-md">
|
||||||
|
<DialogHeader>
|
||||||
|
<DialogTitle>{eventSelected?.title}</DialogTitle>
|
||||||
|
<DialogDescription>
|
||||||
|
{eventSelected?.description}
|
||||||
|
</DialogDescription>
|
||||||
|
</DialogHeader>
|
||||||
|
|
||||||
|
<div className="grid gap-4 py-4">
|
||||||
|
<div className="grid grid-cols-4 items-center gap-4">
|
||||||
|
<Label htmlFor="start" className="text-right">
|
||||||
|
Début
|
||||||
|
</Label>
|
||||||
|
{/*<Popover>
|
||||||
|
<PopoverTrigger asChild>
|
||||||
|
<Button
|
||||||
|
variant={"outline"}
|
||||||
|
className={cn(
|
||||||
|
"w-[240px] pl-3 text-left font-normal",
|
||||||
|
!eventSelected?.start &&
|
||||||
|
"text-muted-foreground",
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
{eventSelected?.start ? (
|
||||||
|
format(eventSelected?.start, "PPP")
|
||||||
|
) : (
|
||||||
|
<span>Choisissez une date.</span>
|
||||||
|
)}
|
||||||
|
<CalendarIcon className="ml-auto h-4 w-4 opacity-50" />
|
||||||
|
</Button>
|
||||||
|
</PopoverTrigger>
|
||||||
|
<PopoverContent
|
||||||
|
className="w-auto p-0"
|
||||||
|
align="start"
|
||||||
|
>
|
||||||
|
<Calendar
|
||||||
|
mode="single"
|
||||||
|
selected={
|
||||||
|
new Date(
|
||||||
|
eventSelected?.start ??
|
||||||
|
Date.now(),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
// onSelect={field.onChange}
|
||||||
|
disabled={(date) =>
|
||||||
|
date > new Date() ||
|
||||||
|
date < new Date("1900-01-01")
|
||||||
|
}
|
||||||
|
initialFocus
|
||||||
|
/>
|
||||||
|
</PopoverContent>
|
||||||
|
</Popover> */}
|
||||||
|
<Input
|
||||||
|
id="start"
|
||||||
|
value={eventSelected?.start}
|
||||||
|
onChange={(e) => {
|
||||||
|
const val = e.currentTarget.value;
|
||||||
|
console.log(val);
|
||||||
|
setEventSelected((ev) => {
|
||||||
|
if (ev)
|
||||||
|
return {
|
||||||
|
...ev,
|
||||||
|
start: val,
|
||||||
|
};
|
||||||
|
return ev;
|
||||||
|
});
|
||||||
|
}}
|
||||||
|
className="col-span-3"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div className="grid grid-cols-4 items-center gap-4">
|
||||||
|
<Label htmlFor="end" className="text-right">
|
||||||
|
Fin
|
||||||
|
</Label>
|
||||||
|
<Input
|
||||||
|
id="end"
|
||||||
|
value={eventSelected?.end}
|
||||||
|
onChange={(e) =>
|
||||||
|
setEventSelected((ev) => {
|
||||||
|
if (ev)
|
||||||
|
return {
|
||||||
|
...ev,
|
||||||
|
end: e.currentTarget.value,
|
||||||
|
};
|
||||||
|
return ev;
|
||||||
|
})
|
||||||
|
}
|
||||||
|
className="col-span-3"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<DialogFooter>
|
||||||
|
<Button
|
||||||
|
onClick={() => {
|
||||||
|
setEvents((evs) => {
|
||||||
|
evs = evs.filter(
|
||||||
|
(e) => e.id !== eventSelected?.id,
|
||||||
|
);
|
||||||
|
evs.push(eventSelected!);
|
||||||
|
return evs;
|
||||||
|
});
|
||||||
|
}}
|
||||||
|
type="submit"
|
||||||
|
>
|
||||||
|
Mettre à jour
|
||||||
|
</Button>
|
||||||
|
</DialogFooter>
|
||||||
|
</DialogContent>
|
||||||
|
</Dialog>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default Planning;
|
||||||
@@ -8,75 +8,59 @@ body {
|
|||||||
|
|
||||||
@layer base {
|
@layer base {
|
||||||
:root {
|
:root {
|
||||||
/* Define your custom padding value */
|
--background: 0 0% 98%;
|
||||||
--background: 0 0% 100%;
|
--foreground: 226 32% 15%;
|
||||||
--foreground: 0 0% 3.9%;
|
|
||||||
--card: 0 0% 100%;
|
--card: 0 0% 100%;
|
||||||
--card-foreground: 0 0% 3.9%;
|
--card-foreground: 226 32% 15%;
|
||||||
--popover: 0 0% 100%;
|
--popover: 0 0% 100%;
|
||||||
--popover-foreground: 0 0% 3.9%;
|
--popover-foreground: 226 32% 15%;
|
||||||
--primary: 0 0% 9%;
|
--primary: 354 70% 44%;
|
||||||
--primary-foreground: 0 0% 98%;
|
--primary-foreground: 0 0% 98%;
|
||||||
--secondary: 0 0% 96.1%;
|
--secondary: 0 0% 94%;
|
||||||
--secondary-foreground: 0 0% 9%;
|
--secondary-foreground: 226 32% 15%;
|
||||||
--muted: 0 0% 96.1%;
|
--muted: 0 0% 94%;
|
||||||
--muted-foreground: 0 0% 45.1%;
|
--muted-foreground: 226 32% 70%;
|
||||||
--accent: 0 0% 96.1%;
|
--accent: 354 70% 44%;
|
||||||
--accent-foreground: 0 0% 9%;
|
--accent-foreground: 0 0% 98%;
|
||||||
--destructive: 0 84.2% 60.2%;
|
--destructive: 0 84% 60%;
|
||||||
--destructive-foreground: 0 0% 98%;
|
--destructive-foreground: 0 0% 98%;
|
||||||
--border: 0 0% 89.8%;
|
--border: 0 0% 90%;
|
||||||
--input: 0 0% 89.8%;
|
--input: 0 0% 94%;
|
||||||
--ring: 0 0% 3.9%;
|
--ring: 354 70% 44%;
|
||||||
--chart-1: 12 76% 61%;
|
--radius: 0.75rem;
|
||||||
--chart-2: 173 58% 39%;
|
--chart-1: 354 70% 44%;
|
||||||
--chart-3: 197 37% 24%;
|
--chart-2: 20 90% 50%;
|
||||||
--chart-4: 43 74% 66%;
|
--chart-3: 200 90% 50%;
|
||||||
--chart-5: 27 87% 67%;
|
--chart-4: 300 90% 50%;
|
||||||
--radius: 0.5rem;
|
--chart-5: 60 90% 50%;
|
||||||
--sidebar-background: 0 0% 98%;
|
|
||||||
--sidebar-foreground: 240 5.3% 26.1%;
|
|
||||||
--sidebar-primary: 240 5.9% 10%;
|
|
||||||
--sidebar-primary-foreground: 0 0% 98%;
|
|
||||||
--sidebar-accent: 240 4.8% 95.9%;
|
|
||||||
--sidebar-accent-foreground: 240 5.9% 10%;
|
|
||||||
--sidebar-border: 220 13% 91%;
|
|
||||||
--sidebar-ring: 217.2 91.2% 59.8%;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.dark {
|
.dark {
|
||||||
--background: 0 0% 3.9%;
|
--background: 226 32% 15%;
|
||||||
--foreground: 0 0% 98%;
|
--foreground: 0 0% 98%;
|
||||||
--card: 0 0% 3.9%;
|
--card: 226 32% 20%;
|
||||||
--card-foreground: 0 0% 98%;
|
--card-foreground: 0 0% 98%;
|
||||||
--popover: 0 0% 3.9%;
|
--popover: 226 32% 20%;
|
||||||
--popover-foreground: 0 0% 98%;
|
--popover-foreground: 0 0% 98%;
|
||||||
--primary: 0 0% 98%;
|
--primary: 354 70% 44%;
|
||||||
--primary-foreground: 0 0% 9%;
|
--primary-foreground: 0 0% 98%;
|
||||||
--secondary: 0 0% 14.9%;
|
--secondary: 226 32% 25%;
|
||||||
--secondary-foreground: 0 0% 98%;
|
--secondary-foreground: 0 0% 98%;
|
||||||
--muted: 0 0% 14.9%;
|
--muted: 226 32% 25%;
|
||||||
--muted-foreground: 0 0% 63.9%;
|
--muted-foreground: 0 0% 70%;
|
||||||
--accent: 0 0% 14.9%;
|
--accent: 354 70% 44%;
|
||||||
--accent-foreground: 0 0% 98%;
|
--accent-foreground: 0 0% 98%;
|
||||||
--destructive: 0 62.8% 30.6%;
|
--destructive: 0 84% 60%;
|
||||||
--destructive-foreground: 0 0% 98%;
|
--destructive-foreground: 0 0% 98%;
|
||||||
--border: 0 0% 14.9%;
|
--border: 226 32% 35%;
|
||||||
--input: 0 0% 14.9%;
|
--input: 226 32% 25%;
|
||||||
--ring: 0 0% 83.1%;
|
--ring: 354 70% 44%;
|
||||||
--chart-1: 220 70% 50%;
|
--radius: 0.75rem;
|
||||||
--chart-2: 160 60% 45%;
|
--chart-1: 354 70% 44%;
|
||||||
--chart-3: 30 80% 55%;
|
--chart-2: 20 90% 50%;
|
||||||
--chart-4: 280 65% 60%;
|
--chart-3: 200 90% 50%;
|
||||||
--chart-5: 340 75% 55%;
|
--chart-4: 300 90% 50%;
|
||||||
--sidebar-background: 240 5.9% 10%;
|
--chart-5: 60 90% 50%;
|
||||||
--sidebar-foreground: 240 4.8% 95.9%;
|
|
||||||
--sidebar-primary: 224.3 76.3% 48%;
|
|
||||||
--sidebar-primary-foreground: 0 0% 100%;
|
|
||||||
--sidebar-accent: 240 3.7% 15.9%;
|
|
||||||
--sidebar-accent-foreground: 240 4.8% 95.9%;
|
|
||||||
--sidebar-border: 240 3.7% 15.9%;
|
|
||||||
--sidebar-ring: 217.2 91.2% 59.8%;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import type { Metadata } from "next";
|
|||||||
import { Geist, Geist_Mono } from "next/font/google";
|
import { Geist, Geist_Mono } from "next/font/google";
|
||||||
import "@/app/globals.css";
|
import "@/app/globals.css";
|
||||||
import SWRLayout from "@/components/layouts/swr-layout";
|
import SWRLayout from "@/components/layouts/swr-layout";
|
||||||
|
import { ThemeProvider } from "@/components/ThemeProvider";
|
||||||
|
|
||||||
const geistSans = Geist({
|
const geistSans = Geist({
|
||||||
variable: "--font-geist-sans",
|
variable: "--font-geist-sans",
|
||||||
@@ -28,7 +29,14 @@ export default function RootLayout({
|
|||||||
<body
|
<body
|
||||||
className={`${geistSans.variable} ${geistMono.variable} antialiased`}
|
className={`${geistSans.variable} ${geistMono.variable} antialiased`}
|
||||||
>
|
>
|
||||||
<SWRLayout>{children}</SWRLayout>
|
<ThemeProvider
|
||||||
|
attribute="class"
|
||||||
|
defaultTheme="dark"
|
||||||
|
enableSystem
|
||||||
|
disableTransitionOnChange
|
||||||
|
>
|
||||||
|
<SWRLayout>{children}</SWRLayout>
|
||||||
|
</ThemeProvider>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
);
|
);
|
||||||
|
|||||||
11
frontend/components/ThemeProvider.tsx
Normal file
11
frontend/components/ThemeProvider.tsx
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
"use client";
|
||||||
|
|
||||||
|
import * as React from "react";
|
||||||
|
import { ThemeProvider as NextThemesProvider } from "next-themes";
|
||||||
|
|
||||||
|
export function ThemeProvider({
|
||||||
|
children,
|
||||||
|
...props
|
||||||
|
}: React.ComponentProps<typeof NextThemesProvider>) {
|
||||||
|
return <NextThemesProvider {...props}>{children}</NextThemesProvider>;
|
||||||
|
}
|
||||||
@@ -1,9 +1,71 @@
|
|||||||
|
"use client";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import { Input } from "@/components/ui/input";
|
import { Input } from "@/components/ui/input";
|
||||||
import { Label } from "@/components/ui/label";
|
import { Label } from "@/components/ui/label";
|
||||||
import { Textarea } from "@/components/ui/textarea";
|
import { Textarea } from "@/components/ui/textarea";
|
||||||
|
import { ApiResponse } from "@/hooks/use-api";
|
||||||
|
import { API_URL } from "@/lib/constants";
|
||||||
|
import { useEffect, useState } from "react";
|
||||||
|
|
||||||
|
interface FormData {
|
||||||
|
firstname: string;
|
||||||
|
lastname: string;
|
||||||
|
email: string;
|
||||||
|
subject: string;
|
||||||
|
message: string;
|
||||||
|
}
|
||||||
|
|
||||||
const Contact = () => {
|
const Contact = () => {
|
||||||
|
const [formData, setFormData] = useState<FormData>({
|
||||||
|
firstname: "",
|
||||||
|
lastname: "",
|
||||||
|
subject: "",
|
||||||
|
email: "",
|
||||||
|
message: "",
|
||||||
|
});
|
||||||
|
|
||||||
|
const [csrfToken, setCsrfToken] = useState("");
|
||||||
|
|
||||||
|
const handleChange = (
|
||||||
|
e: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>,
|
||||||
|
) => {
|
||||||
|
console.log(e.currentTarget);
|
||||||
|
setFormData({
|
||||||
|
...formData,
|
||||||
|
[e.currentTarget.name]: e.currentTarget.value,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const fetchCsrfToken = async () => {
|
||||||
|
try {
|
||||||
|
const response = await fetch(`${API_URL}/csrf-token`, {
|
||||||
|
credentials: "include",
|
||||||
|
});
|
||||||
|
const data: ApiResponse<{ csrf: string }> =
|
||||||
|
await response.json();
|
||||||
|
if (data.data) setCsrfToken(data.data.csrf);
|
||||||
|
} catch (e: any) {
|
||||||
|
console.log(e);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
fetchCsrfToken();
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const handleSubmit = async (e: React.FormEvent<HTMLFormElement>) => {
|
||||||
|
e.preventDefault();
|
||||||
|
const res = await fetch(`${API_URL}/contact`, {
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
"X-CSRF-Token": csrfToken,
|
||||||
|
},
|
||||||
|
method: "POST",
|
||||||
|
body: JSON.stringify(formData),
|
||||||
|
credentials: "include",
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<section className="py-32">
|
<section className="py-32">
|
||||||
<div className="p-4">
|
<div className="p-4">
|
||||||
@@ -38,50 +100,75 @@ const Contact = () => {
|
|||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="mx-auto flex max-w-screen-md flex-col gap-6 rounded-lg border p-10">
|
<form
|
||||||
|
onSubmit={handleSubmit}
|
||||||
|
className="mx-auto flex max-w-screen-md flex-col gap-6 rounded-lg border p-10"
|
||||||
|
>
|
||||||
<div className="flex gap-4">
|
<div className="flex gap-4">
|
||||||
<div className="grid w-full items-center gap-1.5">
|
<div className="grid w-full items-center gap-1.5">
|
||||||
<Label htmlFor="firstname">Prénom</Label>
|
<Label htmlFor="firstname">Prénom</Label>
|
||||||
<Input
|
<Input
|
||||||
|
value={formData.firstname}
|
||||||
|
onChange={handleChange}
|
||||||
type="text"
|
type="text"
|
||||||
id="firstname"
|
id="firstname"
|
||||||
|
name="firstname"
|
||||||
placeholder="Prénom"
|
placeholder="Prénom"
|
||||||
|
required
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div className="grid w-full items-center gap-1.5">
|
<div className="grid w-full items-center gap-1.5">
|
||||||
<Label htmlFor="lastname">Nom de famille</Label>
|
<Label htmlFor="lastname">Nom de famille</Label>
|
||||||
<Input
|
<Input
|
||||||
|
value={formData.lastname}
|
||||||
|
onChange={handleChange}
|
||||||
type="text"
|
type="text"
|
||||||
id="lastname"
|
id="lastname"
|
||||||
|
name="lastname"
|
||||||
placeholder="Nom de famille"
|
placeholder="Nom de famille"
|
||||||
|
required
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="grid w-full items-center gap-1.5">
|
<div className="grid w-full items-center gap-1.5">
|
||||||
<Label htmlFor="email">Email</Label>
|
<Label htmlFor="email">Email</Label>
|
||||||
<Input
|
<Input
|
||||||
|
value={formData.email}
|
||||||
|
onChange={handleChange}
|
||||||
type="email"
|
type="email"
|
||||||
id="email"
|
id="email"
|
||||||
|
name="email"
|
||||||
placeholder="Email"
|
placeholder="Email"
|
||||||
|
required
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div className="grid w-full items-center gap-1.5">
|
<div className="grid w-full items-center gap-1.5">
|
||||||
<Label htmlFor="subject">Objet</Label>
|
<Label htmlFor="subject">Objet</Label>
|
||||||
<Input
|
<Input
|
||||||
|
value={formData.subject}
|
||||||
|
onChange={handleChange}
|
||||||
type="text"
|
type="text"
|
||||||
id="subject"
|
id="subject"
|
||||||
|
name="subject"
|
||||||
placeholder="Objet"
|
placeholder="Objet"
|
||||||
|
required
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div className="grid w-full gap-1.5">
|
<div className="grid w-full gap-1.5">
|
||||||
<Label htmlFor="message">Message</Label>
|
<Label htmlFor="message">Message</Label>
|
||||||
<Textarea
|
<Textarea
|
||||||
|
value={formData.message}
|
||||||
|
onChange={handleChange}
|
||||||
placeholder="Écrivez votre message ici."
|
placeholder="Écrivez votre message ici."
|
||||||
id="message"
|
id="message"
|
||||||
|
name="message"
|
||||||
|
required
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<Button className="w-full">Envoyer</Button>
|
<Button type="submit" className="w-full">
|
||||||
</div>
|
Envoyer
|
||||||
|
</Button>
|
||||||
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|||||||
@@ -54,7 +54,14 @@ const data = [
|
|||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
const Gallery = () => {
|
const Gallery: React.FC<
|
||||||
|
React.PropsWithChildren<{
|
||||||
|
tagLine: string;
|
||||||
|
title: string;
|
||||||
|
cta: string;
|
||||||
|
ctaHref: string;
|
||||||
|
}>
|
||||||
|
> = ({ children, tagLine, title, cta, ctaHref }) => {
|
||||||
const [carouselApi, setCarouselApi] = useState<CarouselApi>();
|
const [carouselApi, setCarouselApi] = useState<CarouselApi>();
|
||||||
const [canScrollPrev, setCanScrollPrev] = useState(false);
|
const [canScrollPrev, setCanScrollPrev] = useState(false);
|
||||||
const [canScrollNext, setCanScrollNext] = useState(false);
|
const [canScrollNext, setCanScrollNext] = useState(false);
|
||||||
@@ -73,21 +80,21 @@ const Gallery = () => {
|
|||||||
};
|
};
|
||||||
}, [carouselApi]);
|
}, [carouselApi]);
|
||||||
return (
|
return (
|
||||||
<section className="lg:md:py-24 sm:py-12 flex flex-col items-center overflow-visible">
|
<section className="flex flex-col items-center overflow-visible sm:py-12 lg:md:py-24">
|
||||||
<div className="container">
|
<div className="container">
|
||||||
<div className="mb-8 flex flex-col justify-between md:mb-14 md:flex-row md:items-end lg:mb-16">
|
<div className="mb-8 flex flex-col justify-between md:mb-14 md:flex-row md:items-end lg:mb-16">
|
||||||
<div>
|
<div>
|
||||||
<p className="mb-6 text-xs font-medium uppercase tracking-wider">
|
<p className="mb-6 text-xs font-medium uppercase tracking-wider">
|
||||||
Tag Line
|
{tagLine}
|
||||||
</p>
|
</p>
|
||||||
<h2 className="mb-3 text-xl font-semibold md:mb-4 md:text-4xl lg:mb-6">
|
<h2 className="mb-3 text-xl font-semibold md:mb-4 md:text-4xl lg:mb-6">
|
||||||
Gallery
|
{title}
|
||||||
</h2>
|
</h2>
|
||||||
<a
|
<a
|
||||||
href="#"
|
href={ctaHref}
|
||||||
className="group flex items-center text-xs font-medium md:text-base lg:text-lg"
|
className="group flex items-center text-xs font-medium md:text-base lg:text-lg"
|
||||||
>
|
>
|
||||||
Book a demo{" "}
|
{cta}
|
||||||
<ArrowRight className="ml-2 size-4 transition-transform group-hover:translate-x-1" />
|
<ArrowRight className="ml-2 size-4 transition-transform group-hover:translate-x-1" />
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
@@ -129,41 +136,16 @@ const Gallery = () => {
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<CarouselContent className="">
|
<CarouselContent className="">
|
||||||
{data.map((item) => (
|
{children
|
||||||
<CarouselItem
|
? children
|
||||||
key={item.id}
|
: data.map((item) => (
|
||||||
className="pl-[20px] md:max-w-[452px]"
|
<CarouselItem
|
||||||
>
|
key={item.id}
|
||||||
<a
|
className="pl-[20px] md:max-w-[452px]"
|
||||||
href={item.href}
|
>
|
||||||
className="group flex flex-col justify-between"
|
<DefaultGalleryItem item={item} />
|
||||||
>
|
</CarouselItem>
|
||||||
<div>
|
))}
|
||||||
<div className="flex aspect-[3/2] overflow-clip rounded-xl">
|
|
||||||
<div className="flex-1">
|
|
||||||
<div className="relative h-full w-full origin-bottom transition duration-300 group-hover:scale-105">
|
|
||||||
<img
|
|
||||||
src={item.image}
|
|
||||||
alt={item.title}
|
|
||||||
className="h-full w-full object-cover object-center"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div className="mb-2 line-clamp-3 break-words pt-4 text-lg font-medium md:mb-3 md:pt-4 md:text-xl lg:pt-4 lg:text-2xl">
|
|
||||||
{item.title}
|
|
||||||
</div>
|
|
||||||
<div className="mb-8 line-clamp-2 text-sm text-muted-foreground md:mb-12 md:text-base lg:mb-9">
|
|
||||||
{item.summary}
|
|
||||||
</div>
|
|
||||||
<div className="flex items-center text-sm">
|
|
||||||
Read more{" "}
|
|
||||||
<ArrowRight className="ml-2 size-5 transition-transform group-hover:translate-x-1" />
|
|
||||||
</div>
|
|
||||||
</a>
|
|
||||||
</CarouselItem>
|
|
||||||
))}
|
|
||||||
</CarouselContent>
|
</CarouselContent>
|
||||||
</Carousel>
|
</Carousel>
|
||||||
</div>
|
</div>
|
||||||
@@ -171,4 +153,36 @@ const Gallery = () => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const DefaultGalleryItem: React.FC<{ item: (typeof data)[0] }> = ({
|
||||||
|
item,
|
||||||
|
}) => {
|
||||||
|
return (
|
||||||
|
<a href={item.href} className="group flex flex-col justify-between">
|
||||||
|
<div>
|
||||||
|
<div className="flex aspect-[3/2] overflow-clip rounded-xl">
|
||||||
|
<div className="flex-1">
|
||||||
|
<div className="relative h-full w-full origin-bottom transition duration-300 group-hover:scale-105">
|
||||||
|
<img
|
||||||
|
src={item.image}
|
||||||
|
alt={item.title}
|
||||||
|
className="h-full w-full object-cover object-center"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="mb-2 line-clamp-3 break-words pt-4 text-lg font-medium md:mb-3 md:pt-4 md:text-xl lg:pt-4 lg:text-2xl">
|
||||||
|
{item.title}
|
||||||
|
</div>
|
||||||
|
<div className="mb-8 line-clamp-2 text-sm text-muted-foreground md:mb-12 md:text-base lg:mb-9">
|
||||||
|
{item.summary}
|
||||||
|
</div>
|
||||||
|
<div className="flex items-center text-sm">
|
||||||
|
Read more{" "}
|
||||||
|
<ArrowRight className="ml-2 size-5 transition-transform group-hover:translate-x-1" />
|
||||||
|
</div>
|
||||||
|
</a>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
export default Gallery;
|
export default Gallery;
|
||||||
|
|||||||
@@ -8,9 +8,9 @@ import Link from "next/link";
|
|||||||
|
|
||||||
const Hero = () => {
|
const Hero = () => {
|
||||||
return (
|
return (
|
||||||
<section className="flex h-[calc(100vh-68px)] justify-center items-center relative overflow-hidden py-32">
|
<section className="relative flex h-[calc(100vh-68px)] items-center justify-center overflow-hidden py-32">
|
||||||
<div className="">
|
<div className="">
|
||||||
<div className="bg-blue-50 magicpattern absolute inset-x-0 top-0 -z-10 flex h-full w-full items-center justify-center opacity-100" />
|
<div className="magicpattern absolute inset-x-0 top-0 -z-10 flex h-full w-full items-center justify-center bg-blue-50 opacity-100" />
|
||||||
<div className="mx-auto flex max-w-5xl flex-col items-center">
|
<div className="mx-auto flex max-w-5xl flex-col items-center">
|
||||||
<div className="z-10 flex flex-col items-center gap-6 text-center">
|
<div className="z-10 flex flex-col items-center gap-6 text-center">
|
||||||
<img
|
<img
|
||||||
@@ -20,7 +20,7 @@ const Hero = () => {
|
|||||||
/>
|
/>
|
||||||
<Badge variant="outline">Latosa-Escrima</Badge>
|
<Badge variant="outline">Latosa-Escrima</Badge>
|
||||||
<div>
|
<div>
|
||||||
<h1 className="mb-6 text-pretty text-2xl font-bold lg:text-5xl">
|
<h1 className="mb-6 text-pretty text-2xl font-bold text-primary lg:text-5xl">
|
||||||
Trouvez votre équilibre avec Latosa-Escrima
|
Trouvez votre équilibre avec Latosa-Escrima
|
||||||
</h1>
|
</h1>
|
||||||
<p className="text-muted-foreground lg:text-xl">
|
<p className="text-muted-foreground lg:text-xl">
|
||||||
|
|||||||
@@ -3,10 +3,12 @@ import { cn } from "@/lib/utils";
|
|||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import { Input } from "@/components/ui/input";
|
import { Input } from "@/components/ui/input";
|
||||||
import { Label } from "@/components/ui/label";
|
import { Label } from "@/components/ui/label";
|
||||||
import { useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { useRouter } from "next/navigation";
|
import { useRouter } from "next/navigation";
|
||||||
import useLogin from "@/hooks/use-login";
|
import useLogin from "@/hooks/use-login";
|
||||||
import { Loader2 } from "lucide-react";
|
import { Loader2 } from "lucide-react";
|
||||||
|
import { API_URL } from "@/lib/constants";
|
||||||
|
import { ApiResponse } from "@/hooks/use-api";
|
||||||
|
|
||||||
export function LoginForm({
|
export function LoginForm({
|
||||||
className,
|
className,
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ const subMenuItemsTwo = [
|
|||||||
|
|
||||||
const Navbar = () => {
|
const Navbar = () => {
|
||||||
return (
|
return (
|
||||||
<section className="p-4 bg-white top-0 sticky z-50">
|
<section className="sticky top-0 z-50 bg-background p-4">
|
||||||
<div>
|
<div>
|
||||||
<nav className="hidden justify-between lg:flex">
|
<nav className="hidden justify-between lg:flex">
|
||||||
<div className="flex items-center gap-6">
|
<div className="flex items-center gap-6">
|
||||||
@@ -103,7 +103,7 @@ const Navbar = () => {
|
|||||||
variant: "ghost",
|
variant: "ghost",
|
||||||
}),
|
}),
|
||||||
)}
|
)}
|
||||||
href="/"
|
href="/planning"
|
||||||
>
|
>
|
||||||
Planning
|
Planning
|
||||||
</a>
|
</a>
|
||||||
|
|||||||
82
frontend/components/ui/calendar.tsx
Normal file
82
frontend/components/ui/calendar.tsx
Normal file
@@ -0,0 +1,82 @@
|
|||||||
|
"use client";
|
||||||
|
|
||||||
|
import * as React from "react";
|
||||||
|
import { ChevronLeft, ChevronRight } from "lucide-react";
|
||||||
|
import { DayPicker } from "react-day-picker";
|
||||||
|
|
||||||
|
import { cn } from "@/lib/utils";
|
||||||
|
import { buttonVariants } from "@/components/ui/button";
|
||||||
|
|
||||||
|
export type CalendarProps = React.ComponentProps<typeof DayPicker>;
|
||||||
|
|
||||||
|
function Calendar({
|
||||||
|
className,
|
||||||
|
classNames,
|
||||||
|
showOutsideDays = true,
|
||||||
|
...props
|
||||||
|
}: CalendarProps) {
|
||||||
|
return (
|
||||||
|
<DayPicker
|
||||||
|
showOutsideDays={showOutsideDays}
|
||||||
|
className={cn("p-3", className)}
|
||||||
|
classNames={{
|
||||||
|
months: "flex flex-col sm:flex-row space-y-4 sm:space-x-4 sm:space-y-0",
|
||||||
|
month: "space-y-4",
|
||||||
|
caption: "flex justify-center pt-1 relative items-center",
|
||||||
|
caption_label: "text-sm font-medium",
|
||||||
|
nav: "space-x-1 flex items-center",
|
||||||
|
nav_button: cn(
|
||||||
|
buttonVariants({ variant: "outline" }),
|
||||||
|
"h-7 w-7 bg-transparent p-0 opacity-50 hover:opacity-100",
|
||||||
|
),
|
||||||
|
nav_button_previous: "absolute left-1",
|
||||||
|
nav_button_next: "absolute right-1",
|
||||||
|
table: "w-full border-collapse space-y-1",
|
||||||
|
head_row: "flex",
|
||||||
|
head_cell:
|
||||||
|
"text-muted-foreground rounded-md w-8 font-normal text-[0.8rem]",
|
||||||
|
row: "flex w-full mt-2",
|
||||||
|
cell: cn(
|
||||||
|
"relative p-0 text-center text-sm focus-within:relative focus-within:z-20 [&:has([aria-selected])]:bg-accent [&:has([aria-selected].day-outside)]:bg-accent/50 [&:has([aria-selected].day-range-end)]:rounded-r-md",
|
||||||
|
props.mode === "range"
|
||||||
|
? "[&:has(>.day-range-end)]:rounded-r-md [&:has(>.day-range-start)]:rounded-l-md first:[&:has([aria-selected])]:rounded-l-md last:[&:has([aria-selected])]:rounded-r-md"
|
||||||
|
: "[&:has([aria-selected])]:rounded-md",
|
||||||
|
),
|
||||||
|
day: cn(
|
||||||
|
buttonVariants({ variant: "ghost" }),
|
||||||
|
"h-8 w-8 p-0 font-normal aria-selected:opacity-100",
|
||||||
|
),
|
||||||
|
day_range_start: "day-range-start",
|
||||||
|
day_range_end: "day-range-end",
|
||||||
|
day_selected:
|
||||||
|
"bg-primary text-primary-foreground hover:bg-primary hover:text-primary-foreground focus:bg-primary focus:text-primary-foreground",
|
||||||
|
day_today: "bg-accent text-accent-foreground",
|
||||||
|
day_outside:
|
||||||
|
"day-outside text-muted-foreground aria-selected:bg-accent/50 aria-selected:text-muted-foreground",
|
||||||
|
day_disabled: "text-muted-foreground opacity-50",
|
||||||
|
day_range_middle:
|
||||||
|
"aria-selected:bg-accent aria-selected:text-accent-foreground",
|
||||||
|
day_hidden: "invisible",
|
||||||
|
...classNames,
|
||||||
|
}}
|
||||||
|
components={{
|
||||||
|
IconLeft: ({ className, ...props }) => (
|
||||||
|
<ChevronLeft
|
||||||
|
className={cn("h-4 w-4", className)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
),
|
||||||
|
IconRight: ({ className, ...props }) => (
|
||||||
|
<ChevronRight
|
||||||
|
className={cn("h-4 w-4", className)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
),
|
||||||
|
}}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
Calendar.displayName = "Calendar";
|
||||||
|
|
||||||
|
export { Calendar };
|
||||||
122
frontend/components/ui/dialog.tsx
Normal file
122
frontend/components/ui/dialog.tsx
Normal file
@@ -0,0 +1,122 @@
|
|||||||
|
"use client";
|
||||||
|
|
||||||
|
import * as React from "react";
|
||||||
|
import * as DialogPrimitive from "@radix-ui/react-dialog";
|
||||||
|
import { X } from "lucide-react";
|
||||||
|
|
||||||
|
import { cn } from "@/lib/utils";
|
||||||
|
|
||||||
|
const Dialog = DialogPrimitive.Root;
|
||||||
|
|
||||||
|
const DialogTrigger = DialogPrimitive.Trigger;
|
||||||
|
|
||||||
|
const DialogPortal = DialogPrimitive.Portal;
|
||||||
|
|
||||||
|
const DialogClose = DialogPrimitive.Close;
|
||||||
|
|
||||||
|
const DialogOverlay = React.forwardRef<
|
||||||
|
React.ComponentRef<typeof DialogPrimitive.Overlay>,
|
||||||
|
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Overlay>
|
||||||
|
>(({ className, ...props }, ref) => (
|
||||||
|
<DialogPrimitive.Overlay
|
||||||
|
ref={ref}
|
||||||
|
className={cn(
|
||||||
|
"fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
|
||||||
|
className,
|
||||||
|
)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
));
|
||||||
|
DialogOverlay.displayName = DialogPrimitive.Overlay.displayName;
|
||||||
|
|
||||||
|
const DialogContent = React.forwardRef<
|
||||||
|
React.ComponentRef<typeof DialogPrimitive.Content>,
|
||||||
|
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Content>
|
||||||
|
>(({ className, children, ...props }, ref) => (
|
||||||
|
<DialogPortal>
|
||||||
|
<DialogOverlay />
|
||||||
|
<DialogPrimitive.Content
|
||||||
|
ref={ref}
|
||||||
|
className={cn(
|
||||||
|
"fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",
|
||||||
|
className,
|
||||||
|
)}
|
||||||
|
{...props}
|
||||||
|
>
|
||||||
|
{children}
|
||||||
|
<DialogPrimitive.Close className="absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground">
|
||||||
|
<X className="h-4 w-4" />
|
||||||
|
<span className="sr-only">Close</span>
|
||||||
|
</DialogPrimitive.Close>
|
||||||
|
</DialogPrimitive.Content>
|
||||||
|
</DialogPortal>
|
||||||
|
));
|
||||||
|
DialogContent.displayName = DialogPrimitive.Content.displayName;
|
||||||
|
|
||||||
|
const DialogHeader = ({
|
||||||
|
className,
|
||||||
|
...props
|
||||||
|
}: React.HTMLAttributes<HTMLDivElement>) => (
|
||||||
|
<div
|
||||||
|
className={cn(
|
||||||
|
"flex flex-col space-y-1.5 text-center sm:text-left",
|
||||||
|
className,
|
||||||
|
)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
DialogHeader.displayName = "DialogHeader";
|
||||||
|
|
||||||
|
const DialogFooter = ({
|
||||||
|
className,
|
||||||
|
...props
|
||||||
|
}: React.HTMLAttributes<HTMLDivElement>) => (
|
||||||
|
<div
|
||||||
|
className={cn(
|
||||||
|
"flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",
|
||||||
|
className,
|
||||||
|
)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
DialogFooter.displayName = "DialogFooter";
|
||||||
|
|
||||||
|
const DialogTitle = React.forwardRef<
|
||||||
|
React.ComponentRef<typeof DialogPrimitive.Title>,
|
||||||
|
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Title>
|
||||||
|
>(({ className, ...props }, ref) => (
|
||||||
|
<DialogPrimitive.Title
|
||||||
|
ref={ref}
|
||||||
|
className={cn(
|
||||||
|
"text-lg font-semibold leading-none tracking-tight",
|
||||||
|
className,
|
||||||
|
)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
));
|
||||||
|
DialogTitle.displayName = DialogPrimitive.Title.displayName;
|
||||||
|
|
||||||
|
const DialogDescription = React.forwardRef<
|
||||||
|
React.ComponentRef<typeof DialogPrimitive.Description>,
|
||||||
|
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Description>
|
||||||
|
>(({ className, ...props }, ref) => (
|
||||||
|
<DialogPrimitive.Description
|
||||||
|
ref={ref}
|
||||||
|
className={cn("text-sm text-muted-foreground", className)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
));
|
||||||
|
DialogDescription.displayName = DialogPrimitive.Description.displayName;
|
||||||
|
|
||||||
|
export {
|
||||||
|
Dialog,
|
||||||
|
DialogPortal,
|
||||||
|
DialogOverlay,
|
||||||
|
DialogTrigger,
|
||||||
|
DialogClose,
|
||||||
|
DialogContent,
|
||||||
|
DialogHeader,
|
||||||
|
DialogFooter,
|
||||||
|
DialogTitle,
|
||||||
|
DialogDescription,
|
||||||
|
};
|
||||||
33
frontend/components/ui/popover.tsx
Normal file
33
frontend/components/ui/popover.tsx
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
"use client";
|
||||||
|
|
||||||
|
import * as React from "react";
|
||||||
|
import * as PopoverPrimitive from "@radix-ui/react-popover";
|
||||||
|
|
||||||
|
import { cn } from "@/lib/utils";
|
||||||
|
|
||||||
|
const Popover = PopoverPrimitive.Root;
|
||||||
|
|
||||||
|
const PopoverTrigger = PopoverPrimitive.Trigger;
|
||||||
|
|
||||||
|
const PopoverAnchor = PopoverPrimitive.Anchor;
|
||||||
|
|
||||||
|
const PopoverContent = React.forwardRef<
|
||||||
|
React.ComponentRef<typeof PopoverPrimitive.Content>,
|
||||||
|
React.ComponentPropsWithoutRef<typeof PopoverPrimitive.Content>
|
||||||
|
>(({ className, align = "center", sideOffset = 4, ...props }, ref) => (
|
||||||
|
<PopoverPrimitive.Portal>
|
||||||
|
<PopoverPrimitive.Content
|
||||||
|
ref={ref}
|
||||||
|
align={align}
|
||||||
|
sideOffset={sideOffset}
|
||||||
|
className={cn(
|
||||||
|
"z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
|
||||||
|
className,
|
||||||
|
)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
</PopoverPrimitive.Portal>
|
||||||
|
));
|
||||||
|
PopoverContent.displayName = PopoverPrimitive.Content.displayName;
|
||||||
|
|
||||||
|
export { Popover, PopoverTrigger, PopoverContent, PopoverAnchor };
|
||||||
@@ -1,29 +1,29 @@
|
|||||||
"use client"
|
"use client";
|
||||||
|
|
||||||
import * as React from "react"
|
import * as React from "react";
|
||||||
import * as SwitchPrimitives from "@radix-ui/react-switch"
|
import * as SwitchPrimitives from "@radix-ui/react-switch";
|
||||||
|
|
||||||
import { cn } from "@/lib/utils"
|
import { cn } from "@/lib/utils";
|
||||||
|
|
||||||
const Switch = React.forwardRef<
|
const Switch = React.forwardRef<
|
||||||
React.ElementRef<typeof SwitchPrimitives.Root>,
|
React.ComponentRef<typeof SwitchPrimitives.Root>,
|
||||||
React.ComponentPropsWithoutRef<typeof SwitchPrimitives.Root>
|
React.ComponentPropsWithoutRef<typeof SwitchPrimitives.Root>
|
||||||
>(({ className, ...props }, ref) => (
|
>(({ className, ...props }, ref) => (
|
||||||
<SwitchPrimitives.Root
|
<SwitchPrimitives.Root
|
||||||
className={cn(
|
className={cn(
|
||||||
"peer inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent shadow-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",
|
"peer inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent shadow-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",
|
||||||
className
|
className,
|
||||||
)}
|
)}
|
||||||
{...props}
|
{...props}
|
||||||
ref={ref}
|
ref={ref}
|
||||||
>
|
>
|
||||||
<SwitchPrimitives.Thumb
|
<SwitchPrimitives.Thumb
|
||||||
className={cn(
|
className={cn(
|
||||||
"pointer-events-none block h-4 w-4 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0"
|
"pointer-events-none block h-4 w-4 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0",
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
</SwitchPrimitives.Root>
|
</SwitchPrimitives.Root>
|
||||||
))
|
));
|
||||||
Switch.displayName = SwitchPrimitives.Root.displayName
|
Switch.displayName = SwitchPrimitives.Root.displayName;
|
||||||
|
|
||||||
export { Switch }
|
export { Switch };
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ async function request<T>(
|
|||||||
method?: "GET" | "POST" | "PATCH" | "DELETE";
|
method?: "GET" | "POST" | "PATCH" | "DELETE";
|
||||||
body?: any;
|
body?: any;
|
||||||
requiresAuth?: boolean;
|
requiresAuth?: boolean;
|
||||||
|
csrfToken?: boolean;
|
||||||
} = {},
|
} = {},
|
||||||
): Promise<ApiResponse<T>> {
|
): Promise<ApiResponse<T>> {
|
||||||
const { method = "GET", body, requiresAuth = true } = options;
|
const { method = "GET", body, requiresAuth = true } = options;
|
||||||
@@ -23,6 +24,13 @@ async function request<T>(
|
|||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (options.csrfToken) {
|
||||||
|
const res: ApiResponse<{ csrf: string }> = await (
|
||||||
|
await fetch(`${API_URL}/csrf-token`)
|
||||||
|
).json();
|
||||||
|
if (res.data) headers["X-CSRF-Token"] = res.data.csrf;
|
||||||
|
}
|
||||||
|
|
||||||
if (requiresAuth) {
|
if (requiresAuth) {
|
||||||
const authToken = getCookie("auth_token");
|
const authToken = getCookie("auth_token");
|
||||||
if (!authToken) {
|
if (!authToken) {
|
||||||
@@ -35,6 +43,7 @@ async function request<T>(
|
|||||||
method,
|
method,
|
||||||
headers,
|
headers,
|
||||||
body: body ? JSON.stringify(body) : undefined,
|
body: body ? JSON.stringify(body) : undefined,
|
||||||
|
credentials: options.csrfToken ? "include" : "omit",
|
||||||
});
|
});
|
||||||
|
|
||||||
const apiResponse: ApiResponse<T> = await response.json();
|
const apiResponse: ApiResponse<T> = await response.json();
|
||||||
@@ -49,8 +58,9 @@ async function request<T>(
|
|||||||
async function fetcher<T>(
|
async function fetcher<T>(
|
||||||
url: string,
|
url: string,
|
||||||
requiresAuth: boolean = true,
|
requiresAuth: boolean = true,
|
||||||
|
csrfToken?: boolean,
|
||||||
): Promise<ApiResponse<T>> {
|
): Promise<ApiResponse<T>> {
|
||||||
return request(url, { requiresAuth });
|
return request(url, { requiresAuth, csrfToken });
|
||||||
}
|
}
|
||||||
|
|
||||||
async function mutationHandler<T, A>(
|
async function mutationHandler<T, A>(
|
||||||
@@ -59,23 +69,26 @@ async function mutationHandler<T, A>(
|
|||||||
arg,
|
arg,
|
||||||
method,
|
method,
|
||||||
requiresAuth,
|
requiresAuth,
|
||||||
|
csrfToken,
|
||||||
}: {
|
}: {
|
||||||
arg: A;
|
arg: A;
|
||||||
method: "GET" | "POST" | "PATCH" | "DELETE";
|
method: "GET" | "POST" | "PATCH" | "DELETE";
|
||||||
requiresAuth: boolean;
|
requiresAuth: boolean;
|
||||||
|
csrfToken?: boolean;
|
||||||
},
|
},
|
||||||
): Promise<ApiResponse<T>> {
|
): Promise<ApiResponse<T>> {
|
||||||
return request(url, { method, body: arg, requiresAuth });
|
return request(url, { method, body: arg, requiresAuth, csrfToken });
|
||||||
}
|
}
|
||||||
|
|
||||||
export function useApi<T>(
|
export function useApi<T>(
|
||||||
url: string,
|
url: string,
|
||||||
config?: SWRConfiguration,
|
config?: SWRConfiguration,
|
||||||
requiresAuth: boolean = true,
|
requiresAuth: boolean = true,
|
||||||
|
csrfToken?: boolean,
|
||||||
) {
|
) {
|
||||||
const swr = useSWR<ApiResponse<T>>(
|
const swr = useSWR<ApiResponse<T>>(
|
||||||
url,
|
url,
|
||||||
() => fetcher(url, requiresAuth),
|
() => fetcher(url, requiresAuth, csrfToken),
|
||||||
config,
|
config,
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -92,10 +105,12 @@ export default function useApiMutation<T, A>(
|
|||||||
config?: SWRMutationConfiguration<ApiResponse<T>, Error, string, A>,
|
config?: SWRMutationConfiguration<ApiResponse<T>, Error, string, A>,
|
||||||
method: "GET" | "POST" | "PATCH" | "DELETE" = "GET",
|
method: "GET" | "POST" | "PATCH" | "DELETE" = "GET",
|
||||||
requiresAuth: boolean = false,
|
requiresAuth: boolean = false,
|
||||||
|
csrfToken?: boolean,
|
||||||
) {
|
) {
|
||||||
const mutation = useSWRMutation<ApiResponse<T>, Error, string, A>(
|
const mutation = useSWRMutation<ApiResponse<T>, Error, string, A>(
|
||||||
endpoint,
|
endpoint,
|
||||||
(url, { arg }) => mutationHandler(url, { arg, method, requiresAuth }),
|
(url, { arg }) =>
|
||||||
|
mutationHandler(url, { arg, method, requiresAuth, csrfToken }),
|
||||||
config,
|
config,
|
||||||
);
|
);
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { setCookie } from "cookies-next";
|
import { setCookie } from "cookies-next";
|
||||||
import useApiMutation from "./use-api";
|
import useApiMutation, { ApiResponse } from "./use-api";
|
||||||
|
import { useEffect, useState } from "react";
|
||||||
|
import { API_URL } from "@/lib/constants";
|
||||||
|
|
||||||
export interface LoginArgs {
|
export interface LoginArgs {
|
||||||
email: string;
|
email: string;
|
||||||
@@ -13,7 +15,13 @@ export default function useLogin() {
|
|||||||
trigger,
|
trigger,
|
||||||
isMutating: loading,
|
isMutating: loading,
|
||||||
isSuccess,
|
isSuccess,
|
||||||
} = useApiMutation<string, LoginArgs>("/users/login", undefined, "POST");
|
} = useApiMutation<string, LoginArgs>(
|
||||||
|
"/users/login",
|
||||||
|
undefined,
|
||||||
|
"POST",
|
||||||
|
false,
|
||||||
|
true,
|
||||||
|
);
|
||||||
|
|
||||||
const login = async (inputs: LoginArgs) => {
|
const login = async (inputs: LoginArgs) => {
|
||||||
try {
|
try {
|
||||||
|
|||||||
48
frontend/interfaces/youtube.ts
Normal file
48
frontend/interfaces/youtube.ts
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
export interface IYoutube {
|
||||||
|
kind: string;
|
||||||
|
etag: string;
|
||||||
|
nextPageToken: string;
|
||||||
|
regionCode: string;
|
||||||
|
pageInfo: IYoutubePageInfo;
|
||||||
|
items: IYoutubeItem[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface IYoutubeItem {
|
||||||
|
kind: string;
|
||||||
|
etag: string;
|
||||||
|
id: IYoutubeID;
|
||||||
|
snippet: IYoutubeSnippet;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface IYoutubeID {
|
||||||
|
kind: string;
|
||||||
|
videoId: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface IYoutubeSnippet {
|
||||||
|
publishedAt: Date;
|
||||||
|
channelId: string;
|
||||||
|
title: string;
|
||||||
|
description: string;
|
||||||
|
thumbnails: IYoutubeThumbnails;
|
||||||
|
channelTitle: string;
|
||||||
|
liveBroadcastContent: string;
|
||||||
|
publishTime: Date;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface IYoutubeThumbnails {
|
||||||
|
default: IYoutubeDefault;
|
||||||
|
medium: IYoutubeDefault;
|
||||||
|
high: IYoutubeDefault;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface IYoutubeDefault {
|
||||||
|
url: string;
|
||||||
|
width: number;
|
||||||
|
height: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface IYoutubePageInfo {
|
||||||
|
totalResults: number;
|
||||||
|
resultsPerPage: number;
|
||||||
|
}
|
||||||
@@ -8,10 +8,6 @@ const apiUrl =
|
|||||||
const nextConfig: NextConfig = {
|
const nextConfig: NextConfig = {
|
||||||
/* config options here */
|
/* config options here */
|
||||||
output: "standalone",
|
output: "standalone",
|
||||||
// webpack: (config) => {
|
|
||||||
// config.resolve.alias["@"] = path.resolve(__dirname, "./");
|
|
||||||
// return config;
|
|
||||||
// },
|
|
||||||
images: {
|
images: {
|
||||||
remotePatterns: [
|
remotePatterns: [
|
||||||
{
|
{
|
||||||
|
|||||||
356
frontend/package-lock.json
generated
356
frontend/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -16,17 +16,24 @@
|
|||||||
"@radix-ui/react-dropdown-menu": "^2.1.4",
|
"@radix-ui/react-dropdown-menu": "^2.1.4",
|
||||||
"@radix-ui/react-label": "^2.1.1",
|
"@radix-ui/react-label": "^2.1.1",
|
||||||
"@radix-ui/react-navigation-menu": "^1.2.3",
|
"@radix-ui/react-navigation-menu": "^1.2.3",
|
||||||
|
"@radix-ui/react-popover": "^1.1.4",
|
||||||
"@radix-ui/react-select": "^2.1.4",
|
"@radix-ui/react-select": "^2.1.4",
|
||||||
"@radix-ui/react-separator": "^1.1.1",
|
"@radix-ui/react-separator": "^1.1.1",
|
||||||
"@radix-ui/react-slot": "^1.1.1",
|
"@radix-ui/react-slot": "^1.1.1",
|
||||||
"@radix-ui/react-switch": "^1.1.2",
|
"@radix-ui/react-switch": "^1.1.2",
|
||||||
"@radix-ui/react-tooltip": "^1.1.6",
|
"@radix-ui/react-tooltip": "^1.1.6",
|
||||||
|
"@schedule-x/events-service": "^2.14.3",
|
||||||
|
"@schedule-x/react": "^2.13.3",
|
||||||
|
"@schedule-x/theme-default": "^2.14.3",
|
||||||
|
"@schedule-x/theme-shadcn": "^2.14.3",
|
||||||
"class-variance-authority": "^0.7.1",
|
"class-variance-authority": "^0.7.1",
|
||||||
"clsx": "^2.1.1",
|
"clsx": "^2.1.1",
|
||||||
"cookies-next": "^5.1.0",
|
"cookies-next": "^5.1.0",
|
||||||
|
"date-fns": "^3.0.0",
|
||||||
"embla-carousel-react": "^8.5.2",
|
"embla-carousel-react": "^8.5.2",
|
||||||
"lucide-react": "^0.471.1",
|
"lucide-react": "^0.471.1",
|
||||||
"next": "15.1.4",
|
"next": "15.1.4",
|
||||||
|
"next-themes": "^0.4.4",
|
||||||
"react": "^19.0.0",
|
"react": "^19.0.0",
|
||||||
"react-dom": "^19.0.0",
|
"react-dom": "^19.0.0",
|
||||||
"react-icons": "^5.4.0",
|
"react-icons": "^5.4.0",
|
||||||
@@ -42,6 +49,8 @@
|
|||||||
"eslint": "^9",
|
"eslint": "^9",
|
||||||
"eslint-config-next": "15.1.4",
|
"eslint-config-next": "15.1.4",
|
||||||
"postcss": "^8",
|
"postcss": "^8",
|
||||||
|
"prettier": "^3.4.2",
|
||||||
|
"prettier-plugin-tailwindcss": "^0.6.10",
|
||||||
"tailwindcss": "^3.4.1",
|
"tailwindcss": "^3.4.1",
|
||||||
"typescript": "^5.7.3"
|
"typescript": "^5.7.3"
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user