Skip to content

Commit 07a194d

Browse files
committed
fix: improve loading state management and enhance layout for Conferences component
1 parent 91309a0 commit 07a194d

1 file changed

Lines changed: 31 additions & 5 deletions

File tree

src/features/conferences/Conferences.tsx

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,45 @@ import { HTFooter } from "@/components/HTFooter";
77

88
export function Conferences() {
99
const [conferences, setConferences] = useState<HTConference[]>([]);
10+
const [loading, setLoading] = useState(true);
1011

1112
useEffect(() => {
1213
document.title = "Conferences · Hacker Tracker";
13-
(async () => setConferences(await getConferences(500)))();
14+
(async () => {
15+
try {
16+
setLoading(true);
17+
const data = await getConferences(500);
18+
setConferences(data ?? []);
19+
} finally {
20+
setLoading(false);
21+
}
22+
})();
1423
}, []);
1524

1625
return (
1726
<>
1827
<HTHeader />
19-
<div className="px-4 sm:px-6 lg:px-10 mt-10">
20-
<h2 className="text-xl font-semibold text-neutral-100">Conferences</h2>
21-
<DisplayConferences conferences={conferences} />
22-
</div>
28+
<main className="px-4 sm:px-6 lg:px-10 mt-10">
29+
<header className="space-y-3 mb-6">
30+
<h1 className="text-xl font-semibold text-neutral-100">
31+
Conferences
32+
</h1>
33+
<div className="h-px bg-gradient-to-r from-transparent via-neutral-800 to-transparent" />
34+
</header>
35+
36+
{loading ? (
37+
<div className="grid items-stretch gap-4 sm:gap-5 grid-cols-1 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4">
38+
{Array.from({ length: 8 }).map((_, i) => (
39+
<div
40+
key={i}
41+
className="h-[116px] rounded-2xl border border-neutral-800 bg-neutral-900/60 animate-pulse"
42+
/>
43+
))}
44+
</div>
45+
) : (
46+
<DisplayConferences conferences={conferences} />
47+
)}
48+
</main>
2349
<HTFooter />
2450
</>
2551
);

0 commit comments

Comments
 (0)