use ComponentWrapper in UsersPage

This commit is contained in:
e560248
2025-04-08 14:35:30 +02:00
parent d5c52968a6
commit 554f14c8d9
4 changed files with 19 additions and 10 deletions

View File

@@ -2,17 +2,20 @@ import './ComponentWrapper.css'
interface ComponentWrapperProps { interface ComponentWrapperProps {
title?: string title?: string
description?: string
children: React.ReactNode children: React.ReactNode
} }
export default function ComponentWrapper({ export default function ComponentWrapper({
children, children,
title, title,
description,
}: ComponentWrapperProps): React.ReactElement { }: ComponentWrapperProps): React.ReactElement {
console.log('ComponentWrapper rendered:', title) console.log('ComponentWrapper rendered:', title)
return ( return (
<div className="component-wrapper"> <section className="component-wrapper">
{title && <h2>{title}</h2>} {title && <h2>{title}</h2>}
{description && <p>{description}</p>}
<div className="component-content">{children}</div> <div className="component-content">{children}</div>
</div> </section>
) )
} }

View File

@@ -57,8 +57,6 @@ export default function UserEffect() {
return ( return (
<section> <section>
<h2>users Effect Exercise</h2>
{userId === 0 && <p>Please select a user</p>} {userId === 0 && <p>Please select a user</p>}
{loading || userId === 0 ? ( {loading || userId === 0 ? (
<p>Loading...</p> <p>Loading...</p>

View File

@@ -21,7 +21,6 @@ export function UserOverview() {
} }
return ( return (
<div> <div>
<h2>User Overview</h2>
<ul> <ul>
{data.map( {data.map(
(user: { (user: {

View File

@@ -1,13 +1,22 @@
import ComponentWrapper from '../common/components/ComponentWrapper/ComponentWrapper'
import UserEffect from '../common/components/exercises/UserEffect' import UserEffect from '../common/components/exercises/UserEffect'
import { UserOverview } from '../common/components/exercises/UserOverview' import { UserOverview } from '../common/components/exercises/UserOverview'
import Heading from '../common/components/globals/Heading'
export default function UsersPage() { export default function UsersPage() {
return ( return (
<div> <div style={{ display: 'flex', flexDirection: 'column', gap: '2rem' }}>
<Heading title="Benutzer" /> <ComponentWrapper
title="Benutzer"
description="Load User with useEffect Hook"
>
<UserEffect /> <UserEffect />
</ComponentWrapper>
<ComponentWrapper
title="User Overview"
description="Load User List with useFetch Hook & use MeadiaQuery Hook"
>
<UserOverview /> <UserOverview />
</ComponentWrapper>
</div> </div>
) )
} }