Skip to content

Commit 5af0db7

Browse files
committed
add edit button to cat list
1 parent 741350f commit 5af0db7

2 files changed

Lines changed: 17 additions & 9 deletions

File tree

src/Components/CatCard.tsx

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,31 @@
11
import React from 'react';
22
import CatFromAxios from '../Interfaces/CatFromAxios';
33
import Card from './Styling/Card';
4+
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
5+
import { faPenToSquare } from '@fortawesome/free-solid-svg-icons';
46

57
interface Props {
68
cat: CatFromAxios;
79
setSelectedCat: React.Dispatch<React.SetStateAction<CatFromAxios | null>>;
810
}
911

10-
export default function CatCard({ cat }: Props) {
12+
export default function CatCard({ cat, setSelectedCat }: Props) {
1113
return (
1214
<Card heading={cat.name}>
13-
<div className="flex justify-between">
14-
<img src={cat.picture_url ?? ''} alt={cat.name} className="w-20" />
15+
<div className="flex justify-between h-20">
16+
<img src={cat.picture_url ?? ''} alt={cat.name} className="w-20 h-20" />
1517
<div>
1618
<p>Level: {cat.battle_profile.level.toString()}</p>
1719
<p>XP: {cat.battle_profile.xp.toString()}</p>
1820
</div>
1921
<p>{cat.description ?? 'A good kitty'}</p>
22+
<FontAwesomeIcon
23+
className="h-full"
24+
icon={faPenToSquare}
25+
onClick={() => {
26+
setSelectedCat(cat);
27+
}}
28+
/>
2029
</div>
2130
</Card>
2231
);

src/Components/MyClowder.tsx

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,11 @@ export default function MyClowder() {
2222
}
2323
}, [userId]);
2424

25-
return (
25+
return selectedCat ? (
26+
<ModalPopover>
27+
<CatProfile></CatProfile>
28+
</ModalPopover>
29+
) : (
2630
<>
2731
<H2>My Clowder</H2>
2832
<ul>
@@ -32,11 +36,6 @@ export default function MyClowder() {
3236
</li>
3337
))}
3438
</ul>
35-
{selectedCat && (
36-
<ModalPopover>
37-
<CatProfile></CatProfile>
38-
</ModalPopover>
39-
)}
4039
</>
4140
);
4241
}

0 commit comments

Comments
 (0)