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 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() { function handleClick() {
handleClickLink( handleClickLink(
@ -29,7 +38,7 @@ const MiniPhotos = (props) => {
<Card {...rest}> <Card {...rest}>
<Card.Body> <Card.Body>
<Card.Title> <Card.Title>
<Link to={photosLink} className="text-body" onClick={handleClick}> <Link to={photosLink} className='text-body' onClick={handleClick}>
<b>Photos</b> <b>Photos</b>
</Link> </Link>
</Card.Title> </Card.Title>
@ -41,24 +50,26 @@ const MiniPhotos = (props) => {
<Col <Col
key={index} key={index}
xs={4} xs={4}
className="m-0" className='m-0'
style={{ style={{
paddingLeft: "3px", paddingLeft: "3px",
paddingRight: "3px", paddingRight: "3px",
paddingTop: "0", paddingTop: "0",
paddingBottom: "0", paddingBottom: "0",
}}> }}
>
<Link <Link
to={`/fakebook/photo/${userID}/${index}`} to={`/fakebook/photo/${userID}/${index}`}
className="text-body" className='text-body'
onClick={handleClick} onClick={handleClick}
tabIndex="-1"> tabIndex='-1'
>
<ResponsiveImage <ResponsiveImage
photo={photo} photo={photo}
userID={userID} userID={userID}
index={index} index={index}
width="100%" width='100%'
height="100%" height='100%'
/> />
</Link> </Link>
</Col> </Col>