Skip to content

Commit 12bac6d

Browse files
committed
Fix spinner
1 parent 1518cd5 commit 12bac6d

File tree

4 files changed

+31
-19
lines changed

4 files changed

+31
-19
lines changed

app/complete-profile/page.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import PromptAnswer from '@/components/ui/PromptAnswer';
1111

1212
import imageCompression from 'browser-image-compression';
1313
import {Item} from '@/lib/client/schema';
14-
import LoadingSpinner from "@/lib/client/LoadingSpinner";
1514
import {fetchFeatures} from "@/lib/client/fetching";
1615

1716

@@ -203,7 +202,12 @@ function RegisterComponent() {
203202
}, [showDropdown]);
204203

205204
if (isLoading) {
206-
return <LoadingSpinner/>
205+
return (
206+
<div className="flex justify-center min-h-screen py-8">
207+
<div data-testid="spinner"
208+
className="animate-spin rounded-full h-12 w-12 border-t-2 border-b-2 border-blue-500"></div>
209+
</div>
210+
)
207211
}
208212

209213
const handleImagesUpload = async (e: ChangeEvent<HTMLInputElement>) => {

app/profiles/page.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use client';
22

33
import Link from "next/link";
4-
import {useCallback, useEffect, useState} from "react";
4+
import React, {useCallback, useEffect, useState} from "react";
55
import LoadingSpinner from "@/lib/client/LoadingSpinner";
66
import {DropdownKey, ProfileData} from "@/lib/client/schema";
77
import {dropdownConfig, ProfileFilters} from "./ProfileFilters";
@@ -219,7 +219,9 @@ export default function ProfilePage() {
219219
<div className="flex-1">
220220
{loading ? (
221221
<div className="flex justify-center py-8">
222-
<LoadingSpinner/>
222+
<div className="flex justify-center min-h-screen py-8">
223+
<div data-testid="spinner" className="animate-spin rounded-full h-12 w-12 border-t-2 border-b-2 border-blue-500"></div>
224+
</div>
223225
</div>
224226
) : error ? (
225227
<div className="flex justify-center py-2">

lib/client/LoadingSpinner.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// For som unknown reasons, the spinner does not render when using LoadingSpinner(), so I copy paste the div block everywhere (TODO)
2+
13
export default function LoadingSpinner() {
24
return (
35
<div className="flex justify-center min-h-screen py-8">

lib/client/profile.tsx

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@
22

33
import Image from "next/image";
44
import {pStyle} from "@/lib/client/constants";
5-
import {useEffect, useState} from "react";
5+
import React, {useEffect, useState} from "react";
66
import {parseImage} from "@/lib/client/media";
7-
import LoadingSpinner from "@/lib/client/LoadingSpinner";
87
import {useRouter} from 'next/navigation';
98

109
interface DeleteProfileButtonProps {
@@ -98,7 +97,12 @@ export function Profile(url: string, header: any = null) {
9897
}, [url]);
9998

10099
if (loading) {
101-
return <LoadingSpinner/>;
100+
return (
101+
<div className="flex justify-center min-h-screen py-8">
102+
<div data-testid="spinner"
103+
className="animate-spin rounded-full h-12 w-12 border-t-2 border-b-2 border-blue-500"></div>
104+
</div>
105+
)
102106
}
103107

104108
if (!userData) {
@@ -161,18 +165,18 @@ export function Profile(url: string, header: any = null) {
161165
<div className="flex-1">
162166
<div className="h-32 w-32 rounded-full border-4 border-white overflow-hidden ">
163167
<a href={image} target="_blank" rel="noopener noreferrer">
164-
<Image
165-
src={image}
166-
alt={userData.name || 'Profile picture'}
167-
className="h-full w-full object-cover"
168-
width={200}
169-
height={200}
170-
// onError={(e) => {
171-
// const target = e.target as HTMLImageElement;
172-
// target.onerror = null;
173-
// target.src = `https://ui-avatars.com/api/?name=${encodeURIComponent(profile.name || 'U')}&background=random`;
174-
// }}
175-
/>
168+
<Image
169+
src={image}
170+
alt={userData.name || 'Profile picture'}
171+
className="h-full w-full object-cover"
172+
width={200}
173+
height={200}
174+
// onError={(e) => {
175+
// const target = e.target as HTMLImageElement;
176+
// target.onerror = null;
177+
// target.src = `https://ui-avatars.com/api/?name=${encodeURIComponent(profile.name || 'U')}&background=random`;
178+
// }}
179+
/>
176180
</a>
177181
</div>
178182
</div>

0 commit comments

Comments
 (0)