This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const mysql = require('mysql2/promise'); | |
| // Create a connection pool | |
| const pool = mysql.createPool({ | |
| host: process.env.DB_HOST || 'localhost', | |
| user: process.env.DB_USER || 'root', | |
| password: process.env.DB_PASSWORD || '', | |
| database: process.env.DB_NAME || 'team_management', | |
| waitForConnections: true, | |
| connectionLimit: 10, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| "use client"; // Error components must be Client Components | |
| import { useRouter } from "next/navigation"; | |
| export default function NotFound({ error, reset }) { | |
| const router = useRouter(); | |
| return ( | |
| <div className="flex flex-col justify-center items-center text-center w-full h-svh"> | |
| <h2 className="mb-10 text-red-500 text-6xl">Page Not-Found !</h2> | |
| <button | |
| className="mb-24 w-auto bg-green-500 text-white rounded-md py-2 px-4 hover:bg-green-600" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| "use client"; // Error components must be Client Components | |
| import { useRouter } from "next/navigation"; | |
| import { useEffect } from "react"; | |
| export default function Error({ error, reset }) { | |
| const router = useRouter(); | |
| useEffect(() => { | |
| // Log the error to an error reporting service | |
| console.error(error); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export default function getDate(value, type, inMS) { | |
| if (!type) { | |
| return value; | |
| } | |
| if (!inMS) { | |
| value = value * 1000; | |
| } | |
| const date = new Date(value); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let didInit = false; | |
| function App() { | |
| useEffect(() => { | |
| if (!didInit) { | |
| didInit = true; | |
| // ✅ Only runs once per app load | |
| loadDataFromLocalStorage(); | |
| checkAuthToken(); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| useEffect(() => { | |
| let ignore = false; | |
| async function startFetching() { | |
| const json = await fetchTodos(userId); | |
| if (!ignore) { | |
| setTodos(json); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| "Create arrow function with arguments": { | |
| "prefix": "fa", | |
| "body": [ | |
| "const $1 = ($2) => {", | |
| " $3", | |
| "}" | |
| ], | |
| "description": "Create a arrow function with cursor on arguments/params" | |
| }, | |
| "Create inline arrow function": { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * React Or Nextjs Install All Pakagese , | |
| * npm install or yarn add @react-three/drei @react-three/fiber | |
| * copy all of file [ .jsx / .tsx ] | |
| * then use this component main layout / main file top... | |
| */ | |
| "use client"; | |
| import { PointMaterial, Points } from "@react-three/drei"; | |
| import { Canvas, useFrame } from "@react-three/fiber"; |