Merge github.com:Hestia-Homes/assessment-model into feature/make_button_for_create_a_real_survey

This commit is contained in:
Jun-te Kim 2025-10-17 16:00:20 +00:00
commit cbd4218df9
3 changed files with 22 additions and 8 deletions

View file

@ -105,7 +105,6 @@ export const AuthOptions: NextAuthOptions = {
async signIn({ user, account }) {
try {
if (!user?.email) return false;
const normalisedEmail = user.email.toLowerCase();
// Fetch the user (NextAuth will have created them already if new)
@ -121,6 +120,7 @@ export const AuthOptions: NextAuthOptions = {
// Link OAuth ID if missing (helps for older accounts)
if (account && !dbUser.oauthId) {
console.log("Linking OAuth ID for user:", normalisedEmail);
const provider = account.provider as OauthProvider;
await db
.update(users)
@ -137,7 +137,6 @@ export const AuthOptions: NextAuthOptions = {
// Pass bigint ID into NextAuth session/jwt
user.dbId = dbUser.id.toString();
user.onboarded = dbUser.onboarded ?? false;
return true;
} catch (error) {
console.error("Error during sign-in:", error);
@ -166,6 +165,10 @@ export const AuthOptions: NextAuthOptions = {
token.onboarded = existing.onboarded;
}
}
if (userFromLogin?.dbId) {
token.dbId = userFromLogin.dbId;
}
return token;
},

View file

@ -4,26 +4,25 @@ import { AuthOptions } from "@/app/api/auth/[...nextauth]/route";
import { getServerSession } from "next-auth";
import { redirect } from "next/navigation";
const Home = async () => {
const user = await getServerSession(AuthOptions);
if (!user?.user) {
console.error("User not found");
redirect("/");
}
const portfolios = await getPortfolios(user.user.dbId);
return (
<>
<div className="flex justify-center">
<h1 className="text-3xl font-bold mt-3 mb-5 text-gray-700"> Your Portfolios </h1>
<h1 className="text-3xl font-bold mt-3 mb-5 text-gray-700">
{" "}
Your Portfolios{" "}
</h1>
</div>
<div className="px-5">
<CardTiles Portfolios={portfolios} />
<CardTiles Portfolios={portfolios} />
</div>
</>
);

View file

@ -0,0 +1,12 @@
export default function RemoteAssessmentPage() {
return (
<div className="max-w-3xl mx-auto p-4">
<h1 className="text-2xl font-bold mb-4">Remote Assessment</h1>
<p className="mb-6">
Welcome to the Remote Assessment page. Here you can start your remote
assessment process.
</p>
{/* Additional content and components for remote assessment can be added here */}
</div>
);
}