diff --git a/nextjs-interface/src/app/ui/dashboard/SeeToken.tsx b/nextjs-interface/src/app/ui/dashboard/SeeToken.tsx index 446e783..56ccbdc 100644 --- a/nextjs-interface/src/app/ui/dashboard/SeeToken.tsx +++ b/nextjs-interface/src/app/ui/dashboard/SeeToken.tsx @@ -1,23 +1,23 @@ -import {Button} from "@/components/ui/button"; -import React, {useState} from "react"; +import { Button } from "@/components/ui/button"; +import React, { useState } from "react"; import ShowToken from "@/app/ui/dashboard/ShowToken"; -export default function SeeToken({ip}: { ip: string }) { - const [showToken, setShowToken] = useState(false); +export default function SeeToken({ ip }: { ip: string }) { + const [showToken, setShowToken] = useState(false); - const toggleToken = () => { - setShowToken(!showToken); - }; + const toggleToken = () => { + setShowToken(!showToken); + }; - return ( -
- - {showToken && } -
- ); + return ( +
+ + {showToken && } +
+ ); } diff --git a/nextjs-interface/src/app/ui/dashboard/ShowToken.tsx b/nextjs-interface/src/app/ui/dashboard/ShowToken.tsx index 56935bd..15d5654 100644 --- a/nextjs-interface/src/app/ui/dashboard/ShowToken.tsx +++ b/nextjs-interface/src/app/ui/dashboard/ShowToken.tsx @@ -1,24 +1,19 @@ -import React, {useEffect} from "react"; +import React, { useEffect } from "react"; -import {copyToClipboard} from "@/lib/utils"; -import {useFetchToken} from "@/lib/data"; +import { copyToClipboard } from "@/lib/utils"; +import { useFetchToken } from "@/lib/data"; -export default function ShowToken({ip}: { ip: string }) { +export default function ShowToken({ ip }: { ip: string }) { + const newToken = useFetchToken(ip); - const newToken = useFetchToken(ip); + useEffect(() => { + copyToClipboard(newToken); + }, [newToken]); - useEffect(() => { - copyToClipboard(newToken); - }, - [newToken] - ); - - return ( -
- Token copié !
- {newToken} -
- ); - - -} \ No newline at end of file + return ( +
+ Token copié !
+ {newToken} +
+ ); +} diff --git a/nextjs-interface/src/lib/utils.ts b/nextjs-interface/src/lib/utils.ts index e8ab50e..17376b4 100644 --- a/nextjs-interface/src/lib/utils.ts +++ b/nextjs-interface/src/lib/utils.ts @@ -1,28 +1,28 @@ -import {type ClassValue, clsx} from "clsx"; -import {twMerge} from "tailwind-merge"; +import { type ClassValue, clsx } from "clsx"; +import { twMerge } from "tailwind-merge"; export function cn(...inputs: ClassValue[]) { - return twMerge(clsx(inputs)); + return twMerge(clsx(inputs)); } // Fonction permettant la copie du Token export const copyToClipboard = (text: string) => { - - if (navigator.clipboard) { - navigator.clipboard.writeText(text).then(() => { - console.log("Token copié dans le presse-papiers"); - }).catch((err) => { - console.error("Erreur lors de la copie du token : ", err); - }); - } else { - console.log("Clipboard inaccessible...") - } - + if (navigator.clipboard) { + navigator.clipboard + .writeText(text) + .then(() => { + console.log("Token copié dans le presse-papiers"); + }) + .catch((err) => { + console.error("Erreur lors de la copie du token : ", err); + }); + } else { + console.log("Clipboard inaccessible..."); + } }; - export function validateIp(ip: string): boolean { - const ipRegex = - /^((25[0-5]|2[0-4]\d|[01]?\d{1,2})\.){3}(25[0-5]|2[0-4]\d|[01]?\d{1,2})$/; - return ipRegex.test(ip); -} \ No newline at end of file + const ipRegex = + /^((25[0-5]|2[0-4]\d|[01]?\d{1,2})\.){3}(25[0-5]|2[0-4]\d|[01]?\d{1,2})$/; + return ipRegex.test(ip); +}