UPDATE: User page allows for profile image upload if on their own profile
This commit is contained in:
24
frontend/src/hooks/useSameUser.ts
Normal file
24
frontend/src/hooks/useSameUser.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import { useEffect, useState } from "react"
|
||||
|
||||
export function useSameUser({ username }: { username: string | undefined }) {
|
||||
const [isSame, setIsSame] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
const fetchStatus = async () => {
|
||||
try {
|
||||
const response = await fetch(`/api/user/same/${username}`);
|
||||
if (!response.ok) {
|
||||
throw new Error("Failed to validate user");
|
||||
}
|
||||
const data = await response.json();
|
||||
setIsSame(data.same);
|
||||
} catch (error) {
|
||||
console.error("Error:", error);
|
||||
}
|
||||
};
|
||||
|
||||
fetchStatus();
|
||||
}, []);
|
||||
|
||||
return isSame;
|
||||
}
|
||||
Reference in New Issue
Block a user