diff --git a/app/routes/profile.tsx b/app/routes/profile.tsx index e284299..2199f9d 100644 --- a/app/routes/profile.tsx +++ b/app/routes/profile.tsx @@ -1,7 +1,7 @@ import { useContext, useState, useEffect } from "react"; import { toast } from "react-hot-toast"; import { useLocalStorage } from "~/hooks/useLocalStorage"; -import { isValidPlayerStats } from "~/utils/utils"; +import { idToColor, isValidPlayerStats } from "~/utils/utils"; import { AuthContext } from "../components/AuthProvider/AuthProvider"; import { updateUsername, @@ -9,8 +9,11 @@ import { importStatsFromLocalStorage, } from "../firebase/utils"; +import { EnvelopeIcon } from "@heroicons/react/20/solid"; + export default function Profile() { const { user, updateUser } = useContext(AuthContext); + const [newUsername, setNewUsername] = useState(""); const [changing, setChanging] = useState(false); const [message, setMessage] = useState(""); @@ -115,67 +118,86 @@ export default function Profile() { } }; + const profile = user + ? { + name: user.username, + email: user.email, + avatar: `https://ui-avatars.com/api/?name=${ + user.username + }&size=20&background=${idToColor(user.uid)}`, // replace with user avatar link if any + backgroundImage: "https://via.placeholder.com/1920x1080", // replace with a user background link if any + } + : null; + if (user) { return ( -
-
-

- Welcome, {user.username}! -

- -
-
- Username: - {user.username} +
+
+ +
+
+
+
+
-
- Email: - {user.email} +
+

+ {profile.name} +

+
+
-
- -
- {!importedDate && localStats && ( -
-

- Import your game stats -

-

- If you've been playing Chessguessr, your stats are saved in - your browser. By importing them, you can keep them safe on - your account and access them on any device. Please note, stats - can be imported only once. -

- -
-

Your Local Stats:

-
    -
  • Games Played: {localStats.gamesPlayed}
  • -
  • Current Streak: {localStats.currentStreak}
  • -
  • Guess distribution:
  • -
      -
    • 1: {localStats.guesses["1"]}
    • -
    • 2: {localStats.guesses["2"]}
    • -
    • 3: {localStats.guesses["3"]}
    • -
    • 4: {localStats.guesses["4"]}
    • -
    • 5: {localStats.guesses["5"]}
    • -
    + {!importedDate && localStats && ( +
    +

    Import your game stats

    +

    + If you've been playing Chessguessr, your stats are saved in your + browser. By importing them, you can keep them safe on your + account and access them on any device. Please note, stats can be + imported only once. +

    + +
    +

    Your Local Stats:

    +
      +
    • Games Played: {localStats.gamesPlayed}
    • +
    • Current Streak: {localStats.currentStreak}
    • +
    • Guess distribution:
    • +
        +
      • 1: {localStats.guesses["1"]}
      • +
      • 2: {localStats.guesses["2"]}
      • +
      • 3: {localStats.guesses["3"]}
      • +
      • 4: {localStats.guesses["4"]}
      • +
      • 5: {localStats.guesses["5"]}
      -
    - -
    - -
    +
- )} -
+ +
+ +
+
+ )} {message && (
diff --git a/package-lock.json b/package-lock.json index c2cb275..886c659 100644 --- a/package-lock.json +++ b/package-lock.json @@ -7,6 +7,7 @@ "dependencies": { "@firebase/auth": "^1.1.0", "@firebase/storage": "^0.11.2", + "@heroicons/react": "^2.0.18", "@react-chess/chessground": "^1.2.4", "@remix-run/node": "^1.5.1", "@remix-run/react": "^1.5.1", @@ -3383,6 +3384,14 @@ "@hapi/hoek": "^9.0.0" } }, + "node_modules/@heroicons/react": { + "version": "2.0.18", + "resolved": "https://registry.npmjs.org/@heroicons/react/-/react-2.0.18.tgz", + "integrity": "sha512-7TyMjRrZZMBPa+/5Y8lN0iyvUU/01PeMGX2+RE7cQWpEUIcb4QotzUObFkJDejj/HUH4qjP/eQ0gzzKs2f+6Yw==", + "peerDependencies": { + "react": ">= 16" + } + }, "node_modules/@humanwhocodes/config-array": { "version": "0.11.8", "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.11.8.tgz", diff --git a/package.json b/package.json index ed613fb..790e7d0 100644 --- a/package.json +++ b/package.json @@ -14,6 +14,7 @@ "dependencies": { "@firebase/auth": "^1.1.0", "@firebase/storage": "^0.11.2", + "@heroicons/react": "^2.0.18", "@react-chess/chessground": "^1.2.4", "@remix-run/node": "^1.5.1", "@remix-run/react": "^1.5.1",