-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
change: show contents tab on profile page
- Loading branch information
Showing
7 changed files
with
57 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 13 additions & 6 deletions
19
src/pages/Profile/ProfileContentItem/ProfileContentItem.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,24 @@ | ||
import { Folder } from "@/types/Capacity"; | ||
import './ProfileContentItem.css' | ||
import { Link } from "react-router-dom"; | ||
import { IMG_DEFAULT_CONTENT } from "@/utils/assets"; | ||
|
||
export function ProfileContentItem({content} : {content : Folder}){ | ||
export type ProfileContentItemProps = { | ||
content: Folder; | ||
}; | ||
|
||
export function ProfileContentItem({content} : Readonly<ProfileContentItemProps>){ | ||
const imageUrl = content.image | ||
? import.meta.env.VITE_UNIVERSIME_API + content.image | ||
: IMG_DEFAULT_CONTENT; | ||
|
||
return( | ||
|
||
<div className="profile-content"> | ||
<Link to={`/capacitacao/folder/${content.id}`}> | ||
<img src={content.image ?? undefined} className="profile-content-thumbnail"/> | ||
</Link> | ||
<Link className="profile-content" to={`/capacitacao/folder/${content.id}`}> | ||
{/* todo: fix content URL */} | ||
<img src={imageUrl} className="profile-content-thumbnail" alt=""/> | ||
<p className="profile-content-title">{content.name}</p> | ||
</div> | ||
</Link> | ||
) | ||
|
||
} |
2 changes: 1 addition & 1 deletion
2
src/pages/Profile/ProfileContentListing/ProfileContentListing.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
.contents{ | ||
display: flex; | ||
flex-wrap: wrap; | ||
margin-top: 2%; | ||
margin-top: .5rem; | ||
gap: 40px; | ||
} | ||
|
||
|
35 changes: 16 additions & 19 deletions
35
src/pages/Profile/ProfileContentListing/ProfileContentListing.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,41 @@ | ||
import { Folder } from "@/types/Capacity"; | ||
import { useEffect, useState, useContext } from "react"; | ||
import { useContext } from "react"; | ||
import { ProfileContentItem } from "../ProfileContentItem/ProfileContentItem"; | ||
import "./ProfileContentListing.css" | ||
import { ProfileContext } from "../ProfileContext"; | ||
|
||
export function ProfileContentListing({title = "Vídeo"} : {title : string}){ | ||
export function ProfileContentListing(){ | ||
|
||
const profileContext = useContext(ProfileContext); | ||
const [availableContents, setAvailableContents] = useState<Folder[]>([]) | ||
if (profileContext == null) | ||
return null; | ||
|
||
useEffect( () =>{ | ||
setAvailableContents(profileContext?.profileListData.folders ?? []); | ||
}, [title]) | ||
const availableContents = profileContext.profileListData.folders | ||
.slice(0) | ||
.sort((content1, content2) => { | ||
return content1.name.localeCompare(content2.name); | ||
}) | ||
|
||
const isOwnProfile = !!profileContext?.accessingLoggedUser; | ||
const hasOtherProfile = !!profileContext?.profile.firstname; | ||
|
||
const otherProfileText = hasOtherProfile | ||
? `${title} de ${profileContext.profile.firstname}` | ||
: title; | ||
? `Conteúdos de ${profileContext.profile.firstname}` | ||
: "Conteúdos"; | ||
|
||
const tabTitle = isOwnProfile | ||
? `Meus ${title}` | ||
? "Meus Conteúdos" | ||
: otherProfileText; | ||
|
||
return( | ||
<div> | ||
<h1 className="content-name">{tabTitle}</h1> | ||
<div className="contents"> | ||
{ | ||
availableContents.length === 0 ? <p>Nenhum conteúdo no momento</p> : | ||
|
||
availableContents.map((content) =>( | ||
<ProfileContentItem content={content} key={content.id} /> | ||
{ availableContents.length === 0 ? <p>Nenhum conteúdo atribuído no momento.</p> : | ||
availableContents.map(content => ( | ||
<ProfileContentItem content={content} key={content.id} /> | ||
)) | ||
} | ||
</div> | ||
</div> | ||
) | ||
|
||
|
||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters