Skip to content

Commit

Permalink
Fix(JSX) Added props for checked
Browse files Browse the repository at this point in the history
  • Loading branch information
ViktorSvertoka committed Oct 12, 2023
1 parent 6d3eed8 commit 0eb1418
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/components/CarItem/CarItem.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,11 @@ export default function CarItem({ data, favoritesCars, setFavoritesCars }) {
return (
<Wrapper>
<ImageWrap>
<HeartIcon id={data.id} toggleFavorite={toggleFavorite} />
<HeartIcon
id={data.id}
toggleFavorite={toggleFavorite}
isFavorite={isCarInFavorites}
/>
<Image src={data.img} alt="Car" />
</ImageWrap>
<TitleWrap>
Expand Down
3 changes: 2 additions & 1 deletion src/components/HeartIcon/HeartIcon.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@ import Checkbox from '@mui/material/Checkbox';
import { HeartFill, HeartStroke, HeartWrap } from './HeartIcon.styled';
const label = { inputProps: { 'aria-label': 'Checkbox demo' } };

export default function HeartIcon({ toggleFavorite, id }) {
export default function HeartIcon({ toggleFavorite, id, isFavorite }) {
return (
<HeartWrap>
<Checkbox
{...label}
icon={<HeartStroke />}
checkedIcon={<HeartFill />}
onChange={() => toggleFavorite(id)}
checked={isFavorite}
/>
</HeartWrap>
);
Expand Down

0 comments on commit 0eb1418

Please sign in to comment.