Fix MiniPhotos component to link to the current users profile if index > 0

This commit is contained in:
Alex Erdei 2025-05-06 13:05:08 +01:00
parent eb70197adb
commit 52f8bcbff2
1 changed files with 69 additions and 58 deletions

View File

@ -15,7 +15,16 @@ const MiniPhotos = (props) => {
const NUMBER_OF_PHOTOS = 9;
const photosLink = `/fakebook/${user.lastname}.${user.firstname}/Photos`;
/* ---------- FIX: build unique slug ----------------------------- */
const slugBase = `${user.lastname}.${user.firstname}`;
const userSlug =
user.index && user.index > 0 ? `${slugBase}.${user.index}` : slugBase;
const photosLink = `/fakebook/${userSlug}/Photos`;
/* ---------------------------------------------------------------- */
function handleClick() {
handleClickLink(
@ -29,7 +38,7 @@ const MiniPhotos = (props) => {
<Card {...rest}>
<Card.Body>
<Card.Title>
<Link to={photosLink} className="text-body" onClick={handleClick}>
<Link to={photosLink} className='text-body' onClick={handleClick}>
<b>Photos</b>
</Link>
</Card.Title>
@ -41,24 +50,26 @@ const MiniPhotos = (props) => {
<Col
key={index}
xs={4}
className="m-0"
className='m-0'
style={{
paddingLeft: "3px",
paddingRight: "3px",
paddingTop: "0",
paddingBottom: "0",
}}>
}}
>
<Link
to={`/fakebook/photo/${userID}/${index}`}
className="text-body"
className='text-body'
onClick={handleClick}
tabIndex="-1">
tabIndex='-1'
>
<ResponsiveImage
photo={photo}
userID={userID}
index={index}
width="100%"
height="100%"
width='100%'
height='100%'
/>
</Link>
</Col>