diff --git a/components/ImageWithFallback.tsx b/components/ImageWithFallback.tsx deleted file mode 100644 index 44c6f81..0000000 --- a/components/ImageWithFallback.tsx +++ /dev/null @@ -1,27 +0,0 @@ -import { ReactNode, useState } from "react"; - -type Props = { - src: string; - className: string; - children: ReactNode; -}; - -const ImageWithFallback = ({ src, className, children, ...rest }: Props) => { - const [error, setError] = useState(false); - - return error ? ( - <>{children} - ) : ( - { - setError(true); - }} - /> - ); -}; - -export default ImageWithFallback; diff --git a/components/Modal/Collection/TeamManagement.tsx b/components/Modal/Collection/TeamManagement.tsx index e9e3da5..0cba34d 100644 --- a/components/Modal/Collection/TeamManagement.tsx +++ b/components/Modal/Collection/TeamManagement.tsx @@ -3,16 +3,15 @@ import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { faClose, faPenToSquare, - faUser, faUserPlus, } from "@fortawesome/free-solid-svg-icons"; import useCollectionStore from "@/store/collections"; import { CollectionIncludingMembers, Member } from "@/types/global"; import { useSession } from "next-auth/react"; import addMemberToCollection from "@/lib/client/addMemberToCollection"; -import ImageWithFallback from "../../ImageWithFallback"; import Checkbox from "../../Checkbox"; import SubmitButton from "@/components/SubmitButton"; +import ProfilePhoto from "@/components/ProfilePhoto"; type Props = { toggleCollectionModal: Function; @@ -186,15 +185,7 @@ export default function TeamManagement({ }} />
- -
- -
-
+

{e.user.name} diff --git a/components/Navbar.tsx b/components/Navbar.tsx index 23f3652..e4927c0 100644 --- a/components/Navbar.tsx +++ b/components/Navbar.tsx @@ -16,6 +16,7 @@ import { useRouter } from "next/router"; import Search from "@/components/Search"; import UserSettings from "./Modal/UserSettings"; import useAccountStore from "@/store/account"; +import ProfilePhoto from "./ProfilePhoto"; export default function () { const { account } = useAccountStore(); @@ -71,27 +72,17 @@ export default function () {

setProfileDropdown(!profileDropdown)} id="profile-dropdown" > - {account.profilePic ? ( - - ) : ( - - )} +

diff --git a/components/ProfilePhoto.tsx b/components/ProfilePhoto.tsx index 12f86cb..e319128 100644 --- a/components/ProfilePhoto.tsx +++ b/components/ProfilePhoto.tsx @@ -1,5 +1,4 @@ -import React from "react"; -import ImageWithFallback from "./ImageWithFallback"; +import React, { useEffect, useState } from "react"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { faUser } from "@fortawesome/free-solid-svg-icons"; @@ -9,16 +8,26 @@ type Props = { }; export default function ProfilePhoto({ src, className }: Props) { - return ( - { + console.log(src); + }, []); + + return error || !src ? ( +
-
- -
- + +
+ ) : ( + { + setError(true); + }} + /> ); } diff --git a/components/Search.tsx b/components/Search.tsx index ed5e3ec..f072680 100644 --- a/components/Search.tsx +++ b/components/Search.tsx @@ -34,6 +34,8 @@ export default function Search() { placeholder="Search for Links" value={searchQuery} onChange={(e) => { + e.target.value.includes("%") && + console.log("The search query should not contain '%'."); setSearchQuery(e.target.value.replace("%", "")); }} onKeyDown={(e) => @@ -41,7 +43,7 @@ export default function Search() { router.push("/search/" + encodeURIComponent(searchQuery)) } autoFocus={searchBox} - className="border border-sky-100 rounded-md pl-10 py-2 pr-2 w-44 sm:w-60 focus:border-sky-500 sm:focus:w-80 hover:border-sky-500 duration-100 outline-none" + className="border border-sky-100 rounded-md pl-10 py-2 pr-2 w-44 sm:w-60 focus:border-sky-500 md:focus:w-80 hover:border-sky-500 duration-100 outline-none" />
); diff --git a/components/Sidebar.tsx b/components/Sidebar.tsx index 1487e1a..9e694bb 100644 --- a/components/Sidebar.tsx +++ b/components/Sidebar.tsx @@ -21,7 +21,6 @@ export default function ({ className }: { className?: string }) { const [active, setActive] = useState(""); useEffect(() => { - console.log(window.location.hash); setActive(router.asPath); }, [router, collections]); diff --git a/types/global.ts b/types/global.ts index 4e5c741..900b3e7 100644 --- a/types/global.ts +++ b/types/global.ts @@ -29,7 +29,7 @@ export interface CollectionIncludingMembers } export interface AccountSettings extends User { - profilePic: string | null; + profilePic: string; oldPassword?: string; newPassword?: string; }