Skip to content

Commit

Permalink
Refactor profile page by extracting BuildsList component for improved…
Browse files Browse the repository at this point in the history
… readability and maintainability
  • Loading branch information
Bolado committed Nov 16, 2024
1 parent 6a055b0 commit 5dce9bd
Showing 1 changed file with 19 additions and 15 deletions.
34 changes: 19 additions & 15 deletions frontend/src/pages/profile.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,28 @@ const Profile = () => {
<div className="max-w-7xl mx-auto">
<h2 className="cinzel text-4xl text-center my-8">Your Builds</h2>
<ul>
{builds.map((build) => {
// deserialize the build object
const b = deserializeBuildState(build.build);
return (
<li
className="p-2 m-2 hover:bg-blue-500/30 rounded-md"
key={build._id}
>
<Link to={`/build/${build._id}`}>
<h3 className="cinzel text-xl font-bold mr-4 ">{b.name}</h3>
<h3 className="text-md mr-4">Monster: {b.monster.name}</h3>
</Link>
</li>
);
})}
<BuildsList builds={builds} />
</ul>
</div>
);
};

const BuildsList = ({ builds }) => {
return builds.map((build, i) => {
// deserialize the build object
const b = deserializeBuildState(build.build);
return (
<li
className={`p-2 m-2 hover:bg-slate-500/30 rounded-md bg-slate-500/10 `}
key={build._id}
>
<Link to={`/build/${build._id}`}>
<h3 className="cinzel text-xl font-bold mr-4 ">{b.name}</h3>
<h3 className="text-md mr-4">Monster: {b.monster.name}</h3>
</Link>
</li>
);
});
};

export default Profile;

0 comments on commit 5dce9bd

Please sign in to comment.