From 38a92a2a90dd0789a029eb379536dcb2bb46e934 Mon Sep 17 00:00:00 2001 From: MartinBraquet Date: Tue, 29 Jul 2025 11:33:52 +0200 Subject: [PATCH] Use Google Image by default --- app/complete-profile/page.tsx | 15 ++++++++++++--- app/layout.tsx | 30 ++++++++++++++++-------------- app/profiles/[id]/page.tsx | 21 +++++++++++++-------- app/register/page.tsx | 21 +++++++++++++-------- next.config.ts | 5 +++++ 5 files changed, 59 insertions(+), 33 deletions(-) diff --git a/app/complete-profile/page.tsx b/app/complete-profile/page.tsx index fa057f23..5404a19b 100644 --- a/app/complete-profile/page.tsx +++ b/app/complete-profile/page.tsx @@ -1,6 +1,6 @@ 'use client'; -import { useState, useRef, ChangeEvent } from 'react'; +import { useState, useRef, ChangeEvent, useEffect } from 'react'; import { useRouter } from 'next/navigation'; import { useSession } from 'next-auth/react'; import Image from 'next/image'; @@ -47,7 +47,8 @@ export default function CompleteProfile() { if (!response.ok) { const errorData = await response.json(); - throw new Error(errorData.error || 'Failed to upload image'); + setError(errorData.error || 'Failed to upload image'); + return; } const { url, key } = await response.json(); @@ -90,7 +91,8 @@ export default function CompleteProfile() { if (!response.ok) { const errorData = await response.json(); - throw new Error(errorData.error || 'Failed to update profile'); + setError(errorData.error || 'Failed to update profile'); + return } // Update the session to reflect the changes @@ -106,6 +108,13 @@ export default function CompleteProfile() { } }; + useEffect(() => { + const img = session?.user?.image; + if (img) { + setImage(img); + } + }, [session]); + return (
diff --git a/app/layout.tsx b/app/layout.tsx index 95986bff..d3810822 100644 --- a/app/layout.tsx +++ b/app/layout.tsx @@ -2,27 +2,29 @@ import "./globals.css"; import Header from "./Header"; import Providers from "./providers"; +import {Metadata} from "next"; -export const metadata = { +export const metadata: Metadata = { title: "BayesBond", description: "A bonding platform for rational thinkers", }; -export default function RootLayout({ - children, -}: { - children: React.ReactNode; -}) { +export default function RootLayout( + { + children, + }: { + children: React.ReactNode; + }) { return ( - - -
-
-
{children}
-
-
- + + +
+
+
{children}
+
+
+ ); } diff --git a/app/profiles/[id]/page.tsx b/app/profiles/[id]/page.tsx index 6c58beef..ce50c1c5 100644 --- a/app/profiles/[id]/page.tsx +++ b/app/profiles/[id]/page.tsx @@ -28,16 +28,21 @@ export default function Post() { } const data = await response.json(); setProfile(data); - console.log(`Data image: ${data.image}`) + const img = data.image; + console.log(`Data image: ${img}`) // If user has an image key, fetch the image - if (data.image) { - const imageResponse = await fetch(`/api/download?key=${data.image}`); - console.log(`imageResponse: ${imageResponse}`) - if (imageResponse.ok) { - const imageBlob = await imageResponse.json(); - const imageUrl = imageBlob['url']; - setImage(imageUrl); + if (img) { + if (img.startsWith('http')) { + setImage(img); + } else { + const imageResponse = await fetch(`/api/download?key=${img}`); + console.log(`imageResponse: ${imageResponse}`) + if (imageResponse.ok) { + const imageBlob = await imageResponse.json(); + const imageUrl = imageBlob['url']; + setImage(imageUrl); + } } } } catch (error) { diff --git a/app/register/page.tsx b/app/register/page.tsx index 0637ed4f..2916de73 100644 --- a/app/register/page.tsx +++ b/app/register/page.tsx @@ -38,6 +38,11 @@ function RegisterComponent() { }; async function handleSubmit(event: React.FormEvent) { + function handleError(error: unknown) { + console.error("Registration error:", error); + setError(error instanceof Error ? error.message : "Registration failed"); + } + try { event.preventDefault(); setIsLoading(true); @@ -50,7 +55,7 @@ function RegisterComponent() { // Basic validation if (!email || !password || !name) { - throw new Error("All fields are required"); + handleError("All fields are required"); } const res = await fetch("/api/auth/signup", { @@ -61,7 +66,7 @@ function RegisterComponent() { const data = await res.json(); if (!res.ok) { - throw new Error(data.error || "Registration failed"); + handleError(data.error || "Registration failed"); } // Show a success message with email verification notice @@ -76,15 +81,14 @@ function RegisterComponent() { }); if (response?.error) { - console.error("Sign-in error:", response.error); - throw new Error("Failed to sign in after registration"); + handleError("Failed to sign in after registration"); } redirect() } catch (error) { - console.error("Registration error:", error); - setError(error instanceof Error ? error.message : "Registration failed"); + handleError(error); + } finally { setIsLoading(false); } } @@ -140,8 +144,9 @@ function RegisterComponent() {

- The project is still in development, you can still sign up if you want to test it, but your account - may be deleted at any time. To get release updates, fill in this form. + The project is still in development. You can sign up if you want to test it, but your account + may be deleted at any time. To get release updates, fill in this form.

Create your account diff --git a/next.config.ts b/next.config.ts index f92ea0d4..da3856ec 100644 --- a/next.config.ts +++ b/next.config.ts @@ -8,6 +8,11 @@ const nextConfig: NextConfig = { hostname: 'bayesbond.s3.eu-north-1.amazonaws.com', pathname: '/**', // allow all paths }, + { + protocol: 'https', + hostname: 'lh3.googleusercontent.com', + pathname: '/**', // allow all paths + }, ], }, };