From 1636f9152b72702f870030ff546f79d99c0c54d7 Mon Sep 17 00:00:00 2001 From: Sonny Date: Tue, 14 Feb 2023 19:29:39 +0100 Subject: [PATCH] Remove: tags --- components/Categories/Categories.tsx | 119 ++++++++++--------- components/Categories/Favorites.tsx | 60 +++++----- components/Categories/SideMenu.tsx | 75 ++++++------ components/FormLayout.tsx | 98 ++++++++-------- components/Links/Links.tsx | 169 ++++++++++++++------------- pages/signin.tsx | 104 +++++++++-------- 6 files changed, 322 insertions(+), 303 deletions(-) diff --git a/components/Categories/Categories.tsx b/components/Categories/Categories.tsx index 25f19ab..614d049 100644 --- a/components/Categories/Categories.tsx +++ b/components/Categories/Categories.tsx @@ -1,67 +1,76 @@ -import LinkTag from 'next/link'; +import LinkTag from "next/link"; -import styles from '../../styles/home/categories.module.scss'; -import { Category } from '../../types'; +import styles from "../../styles/home/categories.module.scss"; +import { Category } from "../../types"; -import EditSVG from '../../public/icons/edit.svg'; -import RemoveSVG from '../../public/icons/remove.svg'; +import EditSVG from "../../public/icons/edit.svg"; +import RemoveSVG from "../../public/icons/remove.svg"; interface CategoriesProps { - categories: Category[]; - categoryActive: Category; - handleSelectCategory: (category: Category) => void; + categories: Category[]; + categoryActive: Category; + handleSelectCategory: (category: Category) => void; } -export default function Categories({ categories, categoryActive, handleSelectCategory }: CategoriesProps) { - return ( -
-

Catégories

-
    - {categories.map((category, key) => ( - - ))} -
-
- ) +export default function Categories({ + categories, + categoryActive, + handleSelectCategory, +}: CategoriesProps) { + return ( +
+

Catégories

+
    + {categories.map((category, key) => ( + + ))} +
+
+ ); } interface CategoryItemProps { - category: Category; - categoryActive: Category; - handleSelectCategory: (category: Category) => void; + category: Category; + categoryActive: Category; + handleSelectCategory: (category: Category) => void; } -function CategoryItem({ category, categoryActive, handleSelectCategory }: CategoryItemProps): JSX.Element { - const className = `${styles['item']} ${category.id === categoryActive.id ? styles['active'] : ''}`; - const onClick = () => handleSelectCategory(category); +function CategoryItem({ + category, + categoryActive, + handleSelectCategory, +}: CategoryItemProps): JSX.Element { + const className = `${styles["item"]} ${ + category.id === categoryActive.id ? styles["active"] : "" + }`; + const onClick = () => handleSelectCategory(category); - return ( -
  • -
    - {category.name} - — {category.links.length} -
    - -
  • - ) + return ( +
  • +
    + {category.name} + — {category.links.length} +
    + +
  • + ); } -function MenuOptions({ id }: { id: number; }): JSX.Element { - return ( -
    - - - - - - - - - - -
    - ) -} \ No newline at end of file +function MenuOptions({ id }: { id: number }): JSX.Element { + return ( +
    + + + + + + +
    + ); +} diff --git a/components/Categories/Favorites.tsx b/components/Categories/Favorites.tsx index f78ca4a..50d247d 100644 --- a/components/Categories/Favorites.tsx +++ b/components/Categories/Favorites.tsx @@ -1,36 +1,36 @@ -import styles from '../../styles/home/categories.module.scss'; -import { Link } from '../../types'; +import LinkTag from "next/link"; -export default function Favorites({ favorites }: { favorites: Link[]; }) { - return ( -
    -

    Favoris

    - -
    - ) +import { Link } from "../../types"; + +import styles from "../../styles/home/categories.module.scss"; + +export default function Favorites({ favorites }: { favorites: Link[] }) { + return ( +
    +

    Favoris

    + +
    + ); } function NoFavLink(): JSX.Element { - return ( -
  • - Aucun favoris -
  • - ) + return
  • Aucun favoris
  • ; } -function LinkFavorite({ link }: { link: Link; }): JSX.Element { - const { name, url, category } = link; - return ( -
  • - - {name} - {category.name} - -
  • - ) -} \ No newline at end of file +function LinkFavorite({ link }: { link: Link }): JSX.Element { + const { name, url, category } = link; + return ( +
  • + + {name} + - {category.name} + +
  • + ); +} diff --git a/components/Categories/SideMenu.tsx b/components/Categories/SideMenu.tsx index 174bb05..26326f0 100644 --- a/components/Categories/SideMenu.tsx +++ b/components/Categories/SideMenu.tsx @@ -1,48 +1,47 @@ -import { Session } from 'next-auth'; -import LinkTag from 'next/link'; +import { Session } from "next-auth"; +import LinkTag from "next/link"; -import Categories from './Categories'; -import Favorites from './Favorites'; -import UserCard from './UserCard'; +import Categories from "./Categories"; +import Favorites from "./Favorites"; +import UserCard from "./UserCard"; -import styles from '../../styles/home/categories.module.scss'; -import { Category, Link } from '../../types'; +import { Category, Link } from "../../types"; + +import styles from "../../styles/home/categories.module.scss"; interface SideMenuProps { - categories: Category[]; - favorites: Link[]; - handleSelectCategory: (category: Category) => void; - categoryActive: Category; - session: Session; + categories: Category[]; + favorites: Link[]; + handleSelectCategory: (category: Category) => void; + categoryActive: Category; + session: Session; } export default function SideMenu({ - categories, - favorites, - handleSelectCategory, - categoryActive, - session + categories, + favorites, + handleSelectCategory, + categoryActive, + session, }: SideMenuProps) { - return (
    - - - - -
    ); + return ( +
    + + + + +
    + ); } function MenuControls() { - return ( -
    - - Créer categorie - - - Créer lien - -
    - ) -} \ No newline at end of file + return ( +
    + Créer categorie + Créer lien +
    + ); +} diff --git a/components/FormLayout.tsx b/components/FormLayout.tsx index 8337ff6..40a44b3 100644 --- a/components/FormLayout.tsx +++ b/components/FormLayout.tsx @@ -1,57 +1,63 @@ -import Head from 'next/head'; -import Link from 'next/link'; +import Head from "next/head"; +import Link from "next/link"; -import MessageManager from './MessageManager'; +import MessageManager from "./MessageManager"; -import styles from '../styles/create.module.scss'; +import styles from "../styles/create.module.scss"; -import { config } from '../config'; +import { config } from "../config"; interface FormProps { - title: string; - errorMessage?: string; - successMessage?: string; - infoMessage?: string; + title: string; + errorMessage?: string; + successMessage?: string; + infoMessage?: string; - canSubmit: boolean; - handleSubmit: (event) => void; + canSubmit: boolean; + handleSubmit: (event) => void; - textBtnConfirm?: string; - classBtnConfirm?: string; + textBtnConfirm?: string; + classBtnConfirm?: string; - children: any; + children: any; } export default function Form({ - title, - errorMessage, - successMessage, - infoMessage, - canSubmit, - handleSubmit, - textBtnConfirm = 'Valider', - classBtnConfirm = '', - children + title, + errorMessage, + successMessage, + infoMessage, + canSubmit, + handleSubmit, + textBtnConfirm = "Valider", + classBtnConfirm = "", + children, }: FormProps) { - return (<> - - {config.siteName} — {title} - -
    -

    {title}

    -
    - {children} - -
    - - ← Revenir à l'accueil - - -
    - ) -} \ No newline at end of file + return ( + <> + + + {config.siteName} — {title} + + +
    +

    {title}

    +
    + {children} + +
    + ← Revenir à l'accueil + +
    + + ); +} diff --git a/components/Links/Links.tsx b/components/Links/Links.tsx index 0340b71..963ffe0 100644 --- a/components/Links/Links.tsx +++ b/components/Links/Links.tsx @@ -1,95 +1,96 @@ -import LinkTag from 'next/link'; +import LinkTag from "next/link"; -import { Category, Link } from '../../types'; +import { Category, Link } from "../../types"; -import EditSVG from '../../public/icons/edit.svg'; -import RemoveSVG from '../../public/icons/remove.svg'; +import EditSVG from "../../public/icons/edit.svg"; +import RemoveSVG from "../../public/icons/remove.svg"; -import styles from '../../styles/home/links.module.scss'; +import styles from "../../styles/home/links.module.scss"; -export default function Links({ category }: { category: Category; }) { - if (category === null) { - return (
    -

    Veuillez séléctionner une categorié

    - - ou en créer une - -
    ) - } - - const { name, links } = category; - if (links.length === 0) { - return (
    -

    Aucun lien pour {category.name}

    - - Créer un lien - -
    ) - } - - return (
    -

    {name} — {links.length}

    - -
    ); -} - -function LinkItem({ link }: { link: Link; }) { - const { id, name, url, category } = link; +export default function Links({ category }: { category: Category }) { + if (category === null) { return ( -
  • - - - {name} — {category.name} - - - -
    - - - - - - - - - - -
    -
  • +
    +

    Veuillez séléctionner une categorié

    + ou en créer une +
    ); + } + + const { name, links } = category; + if (links.length === 0) { + return ( +
    +

    + Aucun lien pour {category.name} +

    + Créer un lien +
    + ); + } + + return ( +
    +

    + {name} + — {links.length} +

    + +
    + ); } -function LinkItemURL({ url }: { url: string; }) { - try { - const { origin, pathname, search } = new URL(url); - let text = ''; +function LinkItem({ link }: { link: Link }) { + const { id, name, url, category } = link; + return ( +
  • + + + {name} + — {category.name} + + + +
    + + + + + + +
    +
  • + ); +} - if (pathname !== '/') { - text += pathname; - } +function LinkItemURL({ url }: { url: string }) { + try { + const { origin, pathname, search } = new URL(url); + let text = ""; - if (search !== '') { - if (text === '') { - text += '/'; - } - text += search; - } - - return ( - - {origin}{text} - - ) - } catch (error) { - console.error('error', error); - return ( - - {url} - - ) + if (pathname !== "/") { + text += pathname; } -} \ No newline at end of file + + if (search !== "") { + if (text === "") { + text += "/"; + } + text += search; + } + + return ( + + {origin} + {text} + + ); + } catch (error) { + console.error("error", error); + return {url}; + } +} diff --git a/pages/signin.tsx b/pages/signin.tsx index b2c447f..bd035ce 100644 --- a/pages/signin.tsx +++ b/pages/signin.tsx @@ -1,58 +1,62 @@ -import { getProviders, signIn, useSession } from 'next-auth/react'; -import { useRouter } from 'next/router'; +import { Provider } from "next-auth/providers"; +import { getProviders, signIn, useSession } from "next-auth/react"; +import Head from "next/head"; +import Link from "next/link"; +import { useRouter } from "next/router"; -import Link from 'next/link'; -import Head from 'next/head'; +import MessageManager from "../components/MessageManager"; +import { config } from "../config"; -import styles from '../styles/login.module.scss'; -import MessageManager from '../components/MessageManager'; +import styles from "../styles/login.module.scss"; -import { config } from '../config'; -import { Provider } from 'next-auth/providers'; +export default function SignIn({ providers }: { providers: Provider[] }) { + const { data: session, status } = useSession(); + const info = useRouter().query?.info as string; + const error = useRouter().query?.error as string; -export default function SignIn({ providers }: { providers: Provider[]; }) { - const { data: session, status } = useSession(); - const info = useRouter().query?.info as string; - const error = useRouter().query?.error as string; + if (status === "loading") { + return ( +
    +

    + Chargement de la session en cours +

    +
    + ); + } - if (status === 'loading') { - return ( -
    -

    Chargement de la session en cours

    -
    - ); - } - - return (<> - - {config.siteName} — Authentification - -
    -
    -

    Se connecter

    - - {session !== null && ()} -
    - {Object.values(providers).map(({ name, id }) => ( - - ))} -
    - - ← Revenir à l'accueil - -
    + return ( + <> + + {config.siteName} — Authentification + +
    +
    +

    Se connecter

    + + {session !== null && ( + + )} +
    + {Object.values(providers).map(({ name, id }) => ( + + ))} +
    + ← Revenir à l'accueil
    - ); +
    + + ); } -export async function getServerSideProps(context) { - const providers = await getProviders(); - return { - props: { providers } - } -} \ No newline at end of file +export async function getServerSideProps() { + const providers = await getProviders(); + return { + props: { providers }, + }; +}