-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #54 from JimTheCat/CU-8696hrm29_Create-profile-pag…
…e_Patryk-Kosiski Cu 8696hrm29 create profile page patryk kosiski
- Loading branch information
Showing
19 changed files
with
313 additions
and
38 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
11 changes: 11 additions & 0 deletions
11
frontend/src/Components/Cards/ProfileAboutMe/ProfileAboutMe.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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import {Card, Text} from "@mantine/core"; | ||
import {InnerHtmlHandler} from "../../InnerHtmlHandler/InnerHtmlHandler.tsx"; | ||
|
||
export const ProfileAboutMe = (props: { htmlContent: string }) => { | ||
return ( | ||
<Card shadow="sm" padding="lg" radius="md" w={500} withBorder> | ||
<Text size={"lg"}>O mnie</Text> | ||
<InnerHtmlHandler innerHtml={props.htmlContent}/> | ||
</Card> | ||
); | ||
} |
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './ProfileAboutMe' |
31 changes: 31 additions & 0 deletions
31
frontend/src/Components/Cards/ProfileFriends/ProfileFriends.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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import {Card, Grid, Group, Image, Text, UnstyledButton} from "@mantine/core"; | ||
import {DummyFriendsType} from "../../../Services/Constants/DummyUser.tsx"; | ||
import {useNavigate} from "react-router-dom"; | ||
|
||
export const ProfileFriends = (props: { friends: DummyFriendsType }) => { | ||
|
||
const navigate = useNavigate(); | ||
|
||
return ( | ||
<Card shadow="sm" px="lg" pt={"lg"} radius="md" w={400} withBorder> | ||
<Group justify={"space-between"} mb={15}> | ||
<Text size={"lg"}>Friends</Text> | ||
<UnstyledButton onClick={() => navigate("https://www.google.com")} c="dimmed"> | ||
Wyświetl wszystko | ||
</UnstyledButton> | ||
</Group> | ||
|
||
<Grid gutter={"xs"} align={"center"}> | ||
{props.friends.friendsDetails!.map((friend, index) => { | ||
return ( | ||
<Grid.Col span={4}> | ||
<Image key={index} src={friend.profilePicture} alt={"Photo " + index} w={"auto"} h={100} radius={180} | ||
fit={"contain"}/> | ||
</Grid.Col> | ||
); | ||
})} | ||
</Grid> | ||
|
||
</Card> | ||
); | ||
} |
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './ProfileFriends.tsx' |
30 changes: 30 additions & 0 deletions
30
frontend/src/Components/Cards/ProfileMultimedia/ProfileMultimedia.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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import {Card, Grid, Group, Image, Text, UnstyledButton} from "@mantine/core"; | ||
import {Multimedia} from "../../../Services/Constants/DummyMultimedia.tsx"; | ||
import {useNavigate} from "react-router-dom"; | ||
|
||
export const ProfileMultimedia = (props: { multimedia: Multimedia[] }) => { | ||
|
||
const navigate = useNavigate(); | ||
|
||
return ( | ||
<Card shadow="sm" px="lg" pt={"lg"} radius="md" w={400} withBorder> | ||
<Group justify={"space-between"} mb={15}> | ||
<Text size={"lg"}>Multimedia</Text> | ||
<UnstyledButton onClick={() => navigate("https://www.google.com")} c="dimmed"> | ||
Wyświetl wszystko | ||
</UnstyledButton> | ||
</Group> | ||
|
||
<Grid gutter={"xs"} align={"center"}> | ||
{props.multimedia.map((media, index) => { | ||
return ( | ||
<Grid.Col span={4}> | ||
<Image key={index} src={media.url} alt={media.type} w={"auto"} h={100} fit={"contain"}/> | ||
</Grid.Col> | ||
); | ||
})} | ||
</Grid> | ||
|
||
</Card> | ||
); | ||
} |
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './ProfileMultimedia' |
53 changes: 53 additions & 0 deletions
53
frontend/src/Components/Cards/ProfileTop/CardProfileTop.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 |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import {Box, Card, Group, Image, Skeleton, Stack, Text} from "@mantine/core"; | ||
import {DummyUserType} from "../../../Services/Constants/DummyUser.tsx"; | ||
import {useState} from "react"; | ||
|
||
|
||
export const CardProfileTop = (props: { userDetails: DummyUserType }) => { | ||
|
||
const [isProfilePictureLoaded, setIsProfilePictureLoaded] = useState(false); | ||
|
||
return ( | ||
<Card shadow="sm" padding="lg" radius="md" w={"fit-content"} withBorder> | ||
<Card.Section withBorder w={500}> | ||
<Image h={150} fit={"cover"} | ||
src={"https://c4.wallpaperflare.com/wallpaper/264/666/478/3-316-16-9-aspect-ratio-s-sfw-wallpaper-preview.jpg"}/> | ||
</Card.Section> | ||
|
||
<Box pos={"relative"} top={-35}> | ||
<Group> | ||
<Box> | ||
{!isProfilePictureLoaded && ( | ||
<Skeleton | ||
circle | ||
height={120} | ||
/> | ||
)} | ||
<Image | ||
src={props.userDetails.profilePicture} | ||
w={"auto"} | ||
h={120} | ||
fit={"cover"} | ||
onLoad={() => setIsProfilePictureLoaded(true)} | ||
radius={180} | ||
bd={"2px solid dimmed"} | ||
display={isProfilePictureLoaded ? "block" : "none"} | ||
/> | ||
</Box> | ||
<Stack justify="flex-end" gap={0} mt={"lg"}> | ||
<Group justify={"center"} gap={"xs"} align={"baseline"}> | ||
<Text size={"xl"}>{props.userDetails.name} {props.userDetails.surname}</Text> | ||
<Text size={"sm"} c="dimmed">{props.userDetails.pronouns}</Text> | ||
</Group> | ||
<Text size={"md"} c="dimmed">{props.userDetails.tag}</Text> | ||
</Stack> | ||
</Group> | ||
|
||
<Stack justify={"flex-start"} gap={0} mt={'md'}> | ||
<Text>Dołączył/a: {props.userDetails.joiningDate}</Text> | ||
<Text>Znajomi: {props.userDetails.friends?.totalFriends}</Text> | ||
</Stack> | ||
</Box> | ||
</Card> | ||
); | ||
} |
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from "./CardProfileTop" |
22 changes: 22 additions & 0 deletions
22
frontend/src/Components/InnerHtmlHandler/InnerHtmlHandler.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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import {TypographyStylesProvider} from "@mantine/core"; | ||
import DOMPurify from 'dompurify'; | ||
|
||
export const InnerHtmlHandler = (props: { innerHtml: string }) => { | ||
|
||
//TODO: Define allowed tags and attributes for DOMPurify sanitizer | ||
// const allowedArgs = { | ||
// ALLOWED_TAGS: ['b', 'i', 'em', 'strong', 'a', 'p', 'ul', 'li', 'br'], | ||
// ALLOWED_ATTR: ['href', 'title'], | ||
// } | ||
|
||
// Validate innerHtml to prevent XSS | ||
const sanitizedHtml = DOMPurify.sanitize(props.innerHtml); | ||
|
||
return ( | ||
<TypographyStylesProvider> | ||
<div | ||
dangerouslySetInnerHTML={{__html: sanitizedHtml}} | ||
/> | ||
</TypographyStylesProvider> | ||
); | ||
} |
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,39 +1,23 @@ | ||
import {ActionIcon, AppShell, Group, MantineColor, Title, useMantineColorScheme} from "@mantine/core"; | ||
import {IconMoonStars, IconSun} from '@tabler/icons-react'; | ||
import {Outlet, useNavigate} from "react-router-dom"; | ||
import {AppShell, Skeleton} from "@mantine/core"; | ||
import {Outlet} from "react-router-dom"; | ||
|
||
export const Layout = () => { | ||
|
||
const navigate = useNavigate(); | ||
const { colorScheme, toggleColorScheme } = useMantineColorScheme(); | ||
const dark = colorScheme === 'dark'; | ||
|
||
return ( | ||
<AppShell | ||
header={{ | ||
height: 70, | ||
}} | ||
navbar={{width: 300, breakpoint: 'xs'}} | ||
> | ||
<AppShell.Header> | ||
<Group justify={"space-between"}> | ||
<Title | ||
order={2} | ||
onClick={() => { | ||
navigate("/") | ||
}} | ||
style={{cursor: 'pointer'}}> | ||
Reimbursement Calculation App</Title> | ||
<ActionIcon | ||
variant="outline" | ||
color={dark ? "yellow" as MantineColor : "blue" as MantineColor} // I don't know what happened here but works ¯\_(ツ)_/¯ | ||
onClick={() => toggleColorScheme()} | ||
title="Toggle color scheme" | ||
> | ||
{dark ? <IconSun size={18}/> : <IconMoonStars size={18}/>} | ||
</ActionIcon> | ||
</Group> | ||
</AppShell.Header> | ||
<Outlet/> | ||
{/*TODO: Modify a navbar*/} | ||
<AppShell.Navbar p="md"> | ||
Navbar | ||
{Array(15) | ||
.fill(0) | ||
.map((_, index) => ( | ||
<Skeleton key={index} h={28} mt="sm" animate={false}/> | ||
))} | ||
</AppShell.Navbar> | ||
<AppShell.Main> | ||
<Outlet/> | ||
</AppShell.Main> | ||
</AppShell> | ||
); | ||
} |
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,9 @@ | ||
import {Box, Title} from "@mantine/core"; | ||
|
||
export const MainPage = () => { | ||
return ( | ||
<div> | ||
<h1>Main Page</h1> | ||
</div> | ||
<Box p={"md"}> | ||
<Title order={1}>Main page</Title> | ||
</Box> | ||
) | ||
} |
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 |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import {useParams} from "react-router-dom"; | ||
import {DummyUser} from "../../Services/Constants/DummyUser.tsx"; | ||
import {CardProfileTop} from "../../Components/Cards/ProfileTop"; | ||
import {Box, Group, Stack} from "@mantine/core"; | ||
import {ProfileAboutMe} from "../../Components/Cards/ProfileAboutMe"; | ||
import {ProfileMultimedia} from "../../Components/Cards/ProfileMultimedia"; | ||
import {DummyMultimedia} from "../../Services/Constants/DummyMultimedia.tsx"; | ||
import {ProfileFriends} from "../../Components/Cards/ProfileFriends"; | ||
|
||
export const Profile = () => { | ||
|
||
const {userTag} = useParams(); | ||
|
||
if (DummyUser && DummyUser.tag === userTag) { | ||
return ( | ||
<Box px={"xl"} py={"xs"}> | ||
<Group align={"flex-start"} justify={"center"} gap={70}> | ||
<Stack> | ||
<CardProfileTop userDetails={DummyUser}/> | ||
<ProfileAboutMe htmlContent={DummyUser.profileDetails ? DummyUser.profileDetails : ""}/> | ||
|
||
{/*TODO: Implement post map*/} | ||
{/*Here should be post map*/} | ||
</Stack> | ||
<Stack> | ||
<ProfileMultimedia multimedia={DummyMultimedia}/> | ||
<ProfileFriends friends={DummyUser.friends!}/> | ||
</Stack> | ||
</Group> | ||
</Box> | ||
); | ||
} | ||
|
||
return ( | ||
<> | ||
Undefined | ||
</> | ||
); | ||
} |
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './Profile' |
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
Oops, something went wrong.