Refactoring

This commit is contained in:
Rampeur
2025-08-07 09:00:42 +02:00
parent 2a3a03dd31
commit 3ce58faa1c
11 changed files with 400 additions and 300 deletions
+12 -1
View File
@@ -1,3 +1,14 @@
{ {
"extends": "next/core-web-vitals" "extends": ["next/core-web-vitals", "next/typescript", "prettier"],
"rules": {
"@typescript-eslint/no-unused-vars": [
"warn",
{
"argsIgnorePattern": "^_",
"varsIgnorePattern": "^_",
"caughtErrorsIgnorePattern": "^_",
"destructuredArrayIgnorePattern": "^_"
}
]
}
} }
+13
View File
@@ -28,6 +28,7 @@
"@types/react-dom": "^19.1.7", "@types/react-dom": "^19.1.7",
"eslint": "^9.32.0", "eslint": "^9.32.0",
"eslint-config-next": "^15.4.5", "eslint-config-next": "^15.4.5",
"eslint-config-prettier": "^9.1.0",
"husky": "^9.1.6", "husky": "^9.1.6",
"lint-staged": "^15.2.10", "lint-staged": "^15.2.10",
"openapi-typescript": "^7.4.1", "openapi-typescript": "^7.4.1",
@@ -3134,6 +3135,18 @@
} }
} }
}, },
"node_modules/eslint-config-prettier": {
"version": "9.1.2",
"resolved": "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-9.1.2.tgz",
"integrity": "sha512-iI1f+D2ViGn+uvv5HuHVUamg8ll4tN+JRHGc6IJi4TP9Kl976C57fzPXgseXNs8v0iA8aSJpHsTWjDb9QJamGQ==",
"dev": true,
"bin": {
"eslint-config-prettier": "bin/cli.js"
},
"peerDependencies": {
"eslint": ">=7.0.0"
}
},
"node_modules/eslint-import-resolver-node": { "node_modules/eslint-import-resolver-node": {
"version": "0.3.9", "version": "0.3.9",
"resolved": "https://registry.npmjs.org/eslint-import-resolver-node/-/eslint-import-resolver-node-0.3.9.tgz", "resolved": "https://registry.npmjs.org/eslint-import-resolver-node/-/eslint-import-resolver-node-0.3.9.tgz",
+1
View File
@@ -37,6 +37,7 @@
"@types/react-dom": "^19.1.7", "@types/react-dom": "^19.1.7",
"eslint": "^9.32.0", "eslint": "^9.32.0",
"eslint-config-next": "^15.4.5", "eslint-config-next": "^15.4.5",
"eslint-config-prettier": "^9.1.0",
"husky": "^9.1.6", "husky": "^9.1.6",
"lint-staged": "^15.2.10", "lint-staged": "^15.2.10",
"openapi-typescript": "^7.4.1", "openapi-typescript": "^7.4.1",
+40 -30
View File
@@ -1,10 +1,9 @@
"use client"; "use client";
import React, { useEffect } from 'react'; import React, { useEffect } from "react";
const TimeClock: React.FC = () => { const TimeClock: React.FC = () => {
useEffect(() => { useEffect(() => {
const numbers = [ const numbers = [
[1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1], // 0 [1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1], // 0
[1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1], // 1 [1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1], // 1
@@ -15,48 +14,47 @@ const TimeClock: React.FC = () => {
[1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 0, 1, 1, 1], // 6 [1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 0, 1, 1, 1], // 6
[1, 0, 0, 0, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0], // 7 [1, 0, 0, 0, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0], // 7
[1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1], // 8 [1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1], // 8
[1, 1, 1, 0, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1] // 9 [1, 1, 1, 0, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1], // 9
]; ];
const blocks: Array<Element[]> = []; const blocks: Array<Element[]> = [];
const digits = Array.from(document.querySelectorAll('.block')); const digits = Array.from(document.querySelectorAll(".block"));
for (let i = 0; i < 4; i++) { for (let i = 0; i < 4; i++) {
blocks.push(digits.slice(i * 15, i * 15 + 15)); blocks.push(digits.slice(i * 15, i * 15 + 15));
} }
const setNum = (block: Array<Element>, num: number) => { const setNum = (block: Array<Element>, num: number) => {
let n = numbers[num]; const n = numbers[num];
for (let i = 0; i < block.length; i++) { for (let i = 0; i < block.length; i++) {
block[i].classList[n[i] === 1 ? 'add' : 'remove']('active'); block[i].classList[n[i] === 1 ? "add" : "remove"]("active");
} }
}; };
const time = { const time = {
s: '', s: "",
m: '', m: "",
h: '', h: "",
p: 0 p: 0,
}; };
// time loop // time loop
const animator = () => { const animator = () => {
let d = new Date(), const d = new Date();
h = d.getHours().toString(), let h = d.getHours().toString(),
m = d.getMinutes().toString(), m = d.getMinutes().toString(),
s = d.getSeconds().toString(); s = d.getSeconds().toString();
s = s.length === 1 ? '0' + s : s; s = s.length === 1 ? "0" + s : s;
m = m.length === 1 ? '0' + m : m; m = m.length === 1 ? "0" + m : m;
h = h.length === 1 ? '0' + h : h; h = h.length === 1 ? "0" + h : h;
if (s !== time.s) { if (s !== time.s) {
for (let i = 0; i < digits.length; i++) { for (let i = 0; i < digits.length; i++) {
let d = digits[i]; const d = digits[i];
if (i === +s) { if (i === +s) {
d.classList.add('second'); d.classList.add("second");
if (time.p !== null) if (time.p !== null) digits[time.p].classList.remove("second");
digits[time.p].classList.remove('second');
time.p = i; time.p = i;
time.s = s; time.s = s;
} }
@@ -74,22 +72,34 @@ const TimeClock: React.FC = () => {
setNum(blocks[1], parseInt(Array.from(h)[1])); setNum(blocks[1], parseInt(Array.from(h)[1]));
time.h = h; time.h = h;
} }
window.requestAnimationFrame(animator) window.requestAnimationFrame(animator);
} };
// init // init
window.requestAnimationFrame(animator) window.requestAnimationFrame(animator);
// toggle button // toggle button
var d = new Date(); const d = new Date();
var days = ["Dimanche", "Lundi", "Mardi", "Mercredi", "Jeudi", "Vendredi", "Samedi"]; const days = ["Dimanche", "Lundi", "Mardi", "Mercredi", "Jeudi", "Vendredi", "Samedi"];
var months = ["Janvier", "Février", "Mars", "Avril", "Mai", "Juin", "Juillet", "Août", "Septembre", "Octobre", "Novembre", "Décembre"]; const months = [
var lib_d = days[d.getDay()]; "Janvier",
var lib_m = months[d.getMonth()]; "Février",
var lib_n = d.getDate(); "Mars",
var lib_y = d.getFullYear(); "Avril",
"Mai",
"Juin",
"Juillet",
"Août",
"Septembre",
"Octobre",
"Novembre",
"Décembre",
];
const lib_d = days[d.getDay()];
const lib_m = months[d.getMonth()];
const lib_n = d.getDate();
const lib_y = d.getFullYear();
document.getElementById("datelib")!.innerHTML = lib_d + " " + lib_n + " " + lib_m + " " + lib_y; document.getElementById("datelib")!.innerHTML = lib_d + " " + lib_n + " " + lib_m + " " + lib_y;
}, []); }, []);
return ( return (
@@ -7,6 +7,7 @@ import { convertMarkdownToHtml } from "@/modules/features/article/functions";
import { FollowButton } from "@/modules/features/profile/components/followButton"; import { FollowButton } from "@/modules/features/profile/components/followButton";
import { Article, User } from "@/utils/types/models"; import { Article, User } from "@/utils/types/models";
import Link from "next/link"; import Link from "next/link";
import Image from "next/image";
import { ReactNode } from "react"; import { ReactNode } from "react";
import styles from "./articleArea.module.css"; import styles from "./articleArea.module.css";
import { showDeleteArticleButton, showEditArticleButton, showFollowButton } from "./functions"; import { showDeleteArticleButton, showEditArticleButton, showFollowButton } from "./functions";
@@ -18,7 +19,7 @@ const Actions = ({ article, currentUser }: { article: Article; currentUser?: Use
return ( return (
<div className="article-meta"> <div className="article-meta">
<Link href={`/profile/${profile.username}`}>{profile.image && <img src={profile.image} alt="" />}</Link> <Link href={`/profile/${profile.username}`}>{profile.image && <Image src={profile.image} alt="" />}</Link>
<div className="info"> <div className="info">
<Link href={`/profile/${profile.username}`} className="author"> <Link href={`/profile/${profile.username}`} className="author">
{profile.username} {profile.username}
@@ -1,5 +1,6 @@
import { Comment } from "@/utils/types/models";
import Link from "next/link"; import Link from "next/link";
import Image from "next/image";
import { Comment } from "@/utils/types/models";
import styles from "./presentation.module.css"; import styles from "./presentation.module.css";
type Props = { type Props = {
@@ -17,7 +18,7 @@ export const CommentCard = ({ comment, showDeleteCommentButton, deleteCommentAct
</div> </div>
<div className="card-footer"> <div className="card-footer">
<Link href={`/profile/${comment.author.username}`} className="comment-author"> <Link href={`/profile/${comment.author.username}`} className="comment-author">
{comment.author.image && <img src={comment.author.image} className="comment-author-img" alt="" />} {comment.author.image && <Image src={comment.author.image} className="comment-author-img" alt="" />}
</Link> </Link>
&nbsp; &nbsp;
<Link href={`/profile/${comment.author.username}`} className="comment-author"> <Link href={`/profile/${comment.author.username}`} className="comment-author">
@@ -1,3 +1,4 @@
import Image from "next/image";
import { Button } from "@/modules/common/components/button"; import { Button } from "@/modules/common/components/button";
import { ErrorMessage } from "@/modules/common/components/errorMessage"; import { ErrorMessage } from "@/modules/common/components/errorMessage";
import { SubmissionResult, useForm } from "@conform-to/react"; import { SubmissionResult, useForm } from "@conform-to/react";
@@ -51,7 +52,7 @@ export const CommentForm = ({ slug, authorImage, result, postCommentAction, isPe
<ErrorMessage messages={errors} /> <ErrorMessage messages={errors} />
</div> </div>
<div className="card-footer"> <div className="card-footer">
{authorImage && <img src={authorImage} alt="" className="comment-author-img" />} {authorImage && <Image src={authorImage} alt="" className="comment-author-img" />}
<Button component="button" type="submit" disabled={isPending}> <Button component="button" type="submit" disabled={isPending}>
Post Comment Post Comment
</Button> </Button>
+1 -3
View File
@@ -34,9 +34,7 @@ const Page = async (props: { searchParams: Promise<{ [key: string]: string | str
<Row> <Row>
<Col sm={6} md={7} lg={8}> <Col sm={6} md={7} lg={8}>
<h1 className="mt-4">Ad Astra, bientôt en ligne!</h1> <h1 className="mt-4">Ad Astra, bientôt en ligne!</h1>
<p className="fs-4"> <p className="fs-4">Encore un peu de patience, notre site sera disponible d&apos;ici peu.</p>
Encore un peu de patience, notre site sera disponible d'ici peu.
</p>
</Col> </Col>
<Col sm={6} md={5} lg={4}> <Col sm={6} md={5} lg={4}>
<TimeClock /> <TimeClock />
+3 -2
View File
@@ -1,9 +1,10 @@
import { ReactNode } from "react";
import Image from "next/image";
import { Button } from "@/modules/common/components/button"; import { Button } from "@/modules/common/components/button";
import { fetchCurrentUser } from "@/modules/features/auth/fetch/fetchCurrentUser"; import { fetchCurrentUser } from "@/modules/features/auth/fetch/fetchCurrentUser";
import { FollowButton } from "@/modules/features/profile/components/followButton"; import { FollowButton } from "@/modules/features/profile/components/followButton";
import { fetchProfile } from "@/modules/features/profile/fetch/fetchProfile"; import { fetchProfile } from "@/modules/features/profile/fetch/fetchProfile";
import { getSession } from "@/utils/auth/session"; import { getSession } from "@/utils/auth/session";
import { ReactNode } from "react";
import { showEditProfileSettingsButton, showFollowButton } from "./_functions"; import { showEditProfileSettingsButton, showFollowButton } from "./_functions";
type Props = { type Props = {
@@ -23,7 +24,7 @@ const Layout = async ({ children, params }: Props) => {
<div className="container"> <div className="container">
<div className="row"> <div className="row">
<div className="col-xs-12 col-md-10 offset-md-1"> <div className="col-xs-12 col-md-10 offset-md-1">
{profile.image && <img src={profile.image} className="user-img" alt="" />} {profile.image && <Image src={profile.image} className="user-img" alt="" />}
<h4>{profile.username}</h4> <h4>{profile.username}</h4>
{profile.bio && <p>{profile.bio}</p>} {profile.bio && <p>{profile.bio}</p>}
{showFollowButton(profile.username, currentUser) && <FollowButton {...profile} color="secondary" />} {showFollowButton(profile.username, currentUser) && <FollowButton {...profile} color="secondary" />}
+89 -27
View File
@@ -1,63 +1,125 @@
import Link from "next/link"; import Link from "next/link";
import LogoSmall from "@/app/_components/layoutElements/logoSmall"; import LogoSmall from "@/app/_components/layoutElements/logoSmall";
import { ComponentPropsWithoutRef } from "react"; //import { ComponentPropsWithoutRef } from "react";
type Props = ComponentPropsWithoutRef<"footer">; //type Props = ComponentPropsWithoutRef<"footer">;
export const Footer = (props: Props) => ( export const Footer = () => (
<footer className="bd-footer pt-3 pb-2 pt-md-4 mt-5 bg-blue-gold"> <footer className="bd-footer pt-3 pb-2 pt-md-4 mt-5 bg-blue-gold">
<div className="container py-4 py-md-5 px-4 px-md-3 text-body-secondary"> <div className="container py-4 py-md-5 px-4 px-md-3 text-body-secondary">
<div className="row"> <div className="row">
<div className="col-lg-3 mb-3"> <div className="col-lg-3 mb-3">
<Link className="d-inline-flex align-items-center mb-2 text-body-emphasis text-decoration-none" href="/" aria-label="Bootstrap"> <Link
className="d-inline-flex align-items-center mb-2 text-body-emphasis text-decoration-none"
href="/"
aria-label="Bootstrap"
>
<LogoSmall /> <LogoSmall />
</Link> </Link>
<ul className="list-unstyled small"> <ul className="list-unstyled small">
<li className="mb-2"> <li className="mb-2">
L'équipe de passionnés Ad Astra est réactive et à l'écoute de vos demandes afin de vous accompagner au mieux et satisfaire vos besoins en fleurs et hashes CBD de qualité. L&apos;équipe de passionnés Ad Astra est réactive et à l&apos;écoute de vos demandes afin de vous
</li> accompagner au mieux et satisfaire vos besoins en fleurs et hashes CBD de qualité.
<li className="mb-2">
Exigez la qualité Ad Astra, vous la méritez.
</li> </li>
<li className="mb-2">Exigez la qualité Ad Astra, vous la méritez.</li>
</ul> </ul>
</div> </div>
<div className="col-6 col-lg-2 offset-lg-1 mb-3"> <div className="col-6 col-lg-2 offset-lg-1 mb-3">
<h5>Nos produits</h5> <h5>Nos produits</h5>
<ul className="list-unstyled"> <ul className="list-unstyled">
<li className="mb-2"><Link href="/">Accueil</Link></li> <li className="mb-2">
<li className="mb-2"><Link href="/produits/fleurs">Lien 2</Link></li> <Link href="/">Accueil</Link>
<li className="mb-2"><Link href="/produits/resines">Lien 3</Link></li> </li>
<li className="mb-2"><Link href="/produits/molecules">Lien 4</Link></li> <li className="mb-2">
<li className="mb-2"><Link href="/produits/concentres">Lien 5</Link></li> <Link href="/produits/fleurs">Lien 2</Link>
</li>
<li className="mb-2">
<Link href="/produits/resines">Lien 3</Link>
</li>
<li className="mb-2">
<Link href="/produits/molecules">Lien 4</Link>
</li>
<li className="mb-2">
<Link href="/produits/concentres">Lien 5</Link>
</li>
</ul> </ul>
</div> </div>
<div className="col-6 col-lg-2 mb-3"> <div className="col-6 col-lg-2 mb-3">
<h5>Documentation</h5> <h5>Documentation</h5>
<ul className="list-unstyled"> <ul className="list-unstyled">
<li className="mb-2"><Link href="/fleurs">Les fleurs</Link></li> <li className="mb-2">
<li className="mb-2"><Link href="/resines">Les hashes</Link></li> <Link href="/fleurs">Les fleurs</Link>
<li className="mb-2"><Link href="/molecules">Les molécules</Link></li> </li>
<li className="mb-2"><Link href="/concentres">Les concentrés</Link></li> <li className="mb-2">
<Link href="/resines">Les hashes</Link>
</li>
<li className="mb-2">
<Link href="/molecules">Les molécules</Link>
</li>
<li className="mb-2">
<Link href="/concentres">Les concentrés</Link>
</li>
</ul> </ul>
</div> </div>
<div className="col-6 col-lg-2 mb-3"> <div className="col-6 col-lg-2 mb-3">
<h5>Professionels</h5> <h5>Professionels</h5>
<ul className="list-unstyled"> <ul className="list-unstyled">
<li className="mb-2"><Link href="/catalogue_ad_astra_2025.pdf" target="_blank" rel="noopener">Catalogue B2B</Link> </li> <li className="mb-2">
<li className="mb-2"><Link href="/pro/lien2" target="_blank" rel="noopener">Lien 2</Link> </li> <Link href="/catalogue_ad_astra_2025.pdf" target="_blank" rel="noopener">
<li className="mb-2"><Link href="/pro/lien3" target="_blank" rel="noopener">Lien 3</Link></li> Catalogue B2B
<li className="mb-2"><Link href="/pro/lien4" target="_blank" rel="noopener">Lien 4</Link></li> </Link>{" "}
<li className="mb-2"> <Link href="/pro/lien5" target="_blank" rel="noopener">Lien 5</Link> </li> </li>
<li className="mb-2">
<Link href="/pro/lien2" target="_blank" rel="noopener">
Lien 2
</Link>{" "}
</li>
<li className="mb-2">
<Link href="/pro/lien3" target="_blank" rel="noopener">
Lien 3
</Link>
</li>
<li className="mb-2">
<Link href="/pro/lien4" target="_blank" rel="noopener">
Lien 4
</Link>
</li>
<li className="mb-2">
{" "}
<Link href="/pro/lien5" target="_blank" rel="noopener">
Lien 5
</Link>{" "}
</li>
</ul> </ul>
</div> </div>
<div className="col-6 col-lg-2 mb-3"> <div className="col-6 col-lg-2 mb-3">
<h5>Contact</h5> <h5>Contact</h5>
<ul className="list-unstyled"> <ul className="list-unstyled">
<li className="mb-2"><Link href="/contact" target="_blank" rel="noopener">Lien 1</Link> </li> <li className="mb-2">
<li className="mb-2"><Link href="/mentions-legales" target="_blank" rel="noopener">Lien 2</Link> </li> <Link href="/contact" target="_blank" rel="noopener">
<li className="mb-2"><Link href="/produits" target="_blank" rel="noopener">Lien 3</Link> </li> Lien 1
<li className="mb-2"><Link href="/produits" target="_blank" rel="noopener">Lien 4</Link></li> </Link>{" "}
<li className="mb-2"><Link href="/produits" target="_blank" rel="noopener">Lien 5</Link> </li> </li>
<li className="mb-2">
<Link href="/mentions-legales" target="_blank" rel="noopener">
Lien 2
</Link>{" "}
</li>
<li className="mb-2">
<Link href="/produits" target="_blank" rel="noopener">
Lien 3
</Link>{" "}
</li>
<li className="mb-2">
<Link href="/produits" target="_blank" rel="noopener">
Lien 4
</Link>
</li>
<li className="mb-2">
<Link href="/produits" target="_blank" rel="noopener">
Lien 5
</Link>{" "}
</li>
</ul> </ul>
</div> </div>
</div> </div>
@@ -1,5 +1,6 @@
import { ArticlePreview } from "@/utils/types/models"; import Image from "next/image";
import Link from "next/link"; import Link from "next/link";
import { ArticlePreview } from "@/utils/types/models";
import { Tag } from "../tag"; import { Tag } from "../tag";
import { FavoriteButton } from "../favoriteButton"; import { FavoriteButton } from "../favoriteButton";
@@ -13,7 +14,7 @@ export const ArticleCard = ({ article }: Props) => {
return ( return (
<div className="article-preview"> <div className="article-preview">
<div className="article-meta"> <div className="article-meta">
<Link href={`/profile/${author.username}`}>{author.image && <img src={author.image} alt="" />}</Link> <Link href={`/profile/${author.username}`}>{author.image && <Image src={author.image} alt="" />}</Link>
<div className="info"> <div className="info">
<Link href={`/profile/${author.username}`} className="author"> <Link href={`/profile/${author.username}`} className="author">
{author.username} {author.username}