// Components import Head from 'next/head'; import { useRouter } from 'next/router'; // Authentication import { useAuthContext } from '@/contexts/AuthContext'; import Layout from '@/layouts/PlatformLayout'; // Layouts import UserProfile from '@/components/PlatformProfile'; // Get profile data export async function getServerSideProps({ query }: any) { if (!query.username) { return { props: { user: null } }; } const user = await fetch(`${process.env.NEXT_PUBLIC_ROOT_URL}/api/v1/users/${query.username}`, { method: 'GET', headers: { 'Content-Type': 'application/json' } }) .then((res) => res.json()) .then((ret) => { return ret?.user; }); if (user) { return { props: { user } }; } else { return { notFound: true }; } } export default function UserProfileNS({ user }: any) { const { query, push } = useRouter(); const { currentUser } = useAuthContext(); let { username } = query as { username: string }; return ( <>
{user ? ( <> > ) : ( <> > )}