Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat#297/criar feed para grupo #304

Merged
merged 26 commits into from
Dec 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
f243236
change: create ProfileClass implementing Profile
NiiMiyo Nov 28, 2023
94b9b52
change: ProfileClass setters
NiiMiyo Nov 28, 2023
8ebf492
change: profileUtils functions as ProfileClass Methods
NiiMiyo Nov 28, 2023
fd36cbe
change: imageUrl returns default when null
NiiMiyo Nov 29, 2023
d2bb7a3
change: creationDate as Date instead of string
NiiMiyo Nov 29, 2023
cd22433
change: GENDER_OPTIONS instead of GenderOptions
NiiMiyo Dec 2, 2023
4b8479f
change: use new GENDER_OPTIONS
NiiMiyo Dec 2, 2023
9a12b5a
change: use ProfileClass on RolesPage
NiiMiyo Dec 2, 2023
54794dc
change: use ProfileClass on ProfilePage
NiiMiyo Dec 2, 2023
451b7b3
change: ProfileClass on ProfileSettings
NiiMiyo Dec 2, 2023
1cb7aef
change: use ProfileClass on ProfileLastRecommendations
NiiMiyo Dec 2, 2023
e6a96fe
change: use ProfileClass on ProfileBio
NiiMiyo Dec 2, 2023
949a8ab
change: use ProfileClass on GroupContext
NiiMiyo Dec 2, 2023
0190028
change: use ProfileClass on GroupPeople
NiiMiyo Dec 2, 2023
0c60c4c
change: use ProfileClass on ManageProfile
NiiMiyo Dec 2, 2023
7f38dcd
change: use ProfileClass on AuthContext
NiiMiyo Dec 2, 2023
4aebbf9
change: delete profileUtils.ts
NiiMiyo Dec 2, 2023
bde3813
parte inicial
KassioL2L Dec 6, 2023
6294ca0
Requisções de Feed
710lucas Dec 8, 2023
f23e631
Finalização
710lucas Dec 8, 2023
74b2c18
alteração CSS
710lucas Dec 8, 2023
5bb55bc
Merge pull request #303 from universi-me/change#290/criar-profile-class
710lucas Dec 9, 2023
343a953
Merge branch 'feat#297/criar-feed-para-grupo' of https://github.com/u…
710lucas Dec 9, 2023
522208a
Implementando profileClass
710lucas Dec 9, 2023
d38d787
tirando console.log
KassioL2L Dec 12, 2023
d5c52ad
Ajeitando indentação
710lucas Dec 12, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions src/components/ProfileInfo/ProfileBio/ProfileBio.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { Link } from 'react-router-dom';

import { ProfileImage } from '@/components/ProfileImage/ProfileImage';
import { getFullName, getProfileImageUrl } from '@/utils/profileUtils';
import { ICON_EDIT_WHITE } from '@/utils/assets';
import { groupBannerUrl } from '@/utils/apiUtils';

import type { Profile } from '@/types/Profile';
import { type Profile, ProfileClass } from '@/types/Profile';
import { TypeLinkToBootstrapIcon, type Link as Link_API } from '@/types/Link';
import type { Group } from '@/types/Group';
import './ProfileBio.less';
Expand All @@ -26,6 +25,8 @@
? { backgroundImage: `url(${groupBannerUrl(props.organization)})` }
: { backgroundColor: "var(--primary-color)" }

const profile = new ProfileClass(props.profile);

Check warning on line 28 in src/components/ProfileInfo/ProfileBio/ProfileBio.tsx

View check run for this annotation

Codecov / codecov/patch

src/components/ProfileInfo/ProfileBio/ProfileBio.tsx#L28

Added line #L28 was not covered by tests

return (
<div className="profile-bio-component card">

Expand All @@ -42,11 +43,11 @@
</div>

<div className="intro intro-section">
<ProfileImage className="image" imageUrl={getProfileImageUrl(props.profile)} noImageColor="#505050" />
<ProfileImage className="image" imageUrl={profile.imageUrl} noImageColor="#505050" />
{
isOnOwnProfile
? <h2 className="card-heading name">{ getFullName(props.profile) }</h2>
: <Link className="card-heading name" to={linkToOwnProfile}>{ getFullName(props.profile) }</Link>
? <h2 className="card-heading name">{ profile.fullname }</h2>
: <Link className="card-heading name" to={linkToOwnProfile}>{ profile.fullname }</Link>

Check warning on line 50 in src/components/ProfileInfo/ProfileBio/ProfileBio.tsx

View check run for this annotation

Codecov / codecov/patch

src/components/ProfileInfo/ProfileBio/ProfileBio.tsx#L49-L50

Added lines #L49 - L50 were not covered by tests
}
{
props.profile.bio === null || props.profile.bio.length === 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { Link, redirect, useNavigate } from "react-router-dom";
import { ProfileImage } from "@/components/ProfileImage/ProfileImage";
import { AuthContext } from "@/contexts/Auth";
import "./WelcomeUser.less"
import { getProfileImageUrl } from "@/utils/profileUtils";
import * as DropdownMenu from "@radix-ui/react-dropdown-menu"

export function WelcomeUser() {
Expand All @@ -20,7 +19,7 @@ export function WelcomeUser() {

return( !isLogged ? null
:<div className="image-container">
<ProfileImage className="logged-user-image" imageUrl={auth.profile ? getProfileImageUrl(auth.profile) : undefined} noImageColor="var(--card-background-color)" onClick={() => {setProfileClicked(!profileClicked)}}/>
<ProfileImage className="logged-user-image" imageUrl={auth.profile ? auth.profile.imageUrl : undefined} noImageColor="var(--card-background-color)" onClick={() => {setProfileClicked(!profileClicked)}}/>
{
profileClicked
?
Expand Down
10 changes: 5 additions & 5 deletions src/contexts/Auth/AuthContext.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import { createContext } from "react";
import { User } from "@/types/User";
import { Profile } from "@/types/Profile";
import { type ProfileClass } from "@/types/Profile";
import type { Group } from "@/types/Group";

export type AuthContextType = {
user : User | null;
profile: Profile | null;
profile: ProfileClass | null;
organization: Group | null;

signin: (email : string, password: string, recaptchaToken: string | null) => Promise<Profile | null>;
signinGoogle: () => Promise<Profile | null>;
signin: (email : string, password: string, recaptchaToken: string | null) => Promise<ProfileClass | null>;
signinGoogle: () => Promise<ProfileClass | null>;
signout: () => Promise<void>;

updateLoggedUser: () => Promise<Profile | null>;
updateLoggedUser: () => Promise<ProfileClass | null>;
}

export const AuthContext = createContext<AuthContextType>(null!);
10 changes: 7 additions & 3 deletions src/contexts/Auth/AuthProvider.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { ReactNode, useEffect, useState } from "react";
import { AuthContext } from "./AuthContext";
import { Profile } from "@/types/Profile";
import { ProfileClass } from "@/types/Profile";
import { UniversimeApi } from "@/services/UniversimeApi";
import { goTo } from "@/services/routes";
import type { Group } from "@/types/Group";

export const AuthProvider = ({ children }: { children: ReactNode }) => {
const [profile, setProfile] = useState<Profile | null>(null);
const [profile, setProfile] = useState<ProfileClass | null>(null);

Check warning on line 9 in src/contexts/Auth/AuthProvider.tsx

View check run for this annotation

Codecov / codecov/patch

src/contexts/Auth/AuthProvider.tsx#L9

Added line #L9 was not covered by tests
const [organization, setOrganization] = useState<Group | null>(null);
const [finishedLogin, setFinishedLogin] = useState<boolean>(false);
const user = profile?.user ?? null;
Expand Down Expand Up @@ -91,5 +91,9 @@
if(!await UniversimeApi.Auth.validateToken()) {
return null;
}
return (await UniversimeApi.Profile.profile()).body?.profile ?? null;

const responseProfile = (await UniversimeApi.Profile.profile()).body?.profile;

Check warning on line 95 in src/contexts/Auth/AuthProvider.tsx

View check run for this annotation

Codecov / codecov/patch

src/contexts/Auth/AuthProvider.tsx#L95

Added line #L95 was not covered by tests
return responseProfile
? new ProfileClass(responseProfile)
: null;

Check warning on line 98 in src/contexts/Auth/AuthProvider.tsx

View check run for this annotation

Codecov / codecov/patch

src/contexts/Auth/AuthProvider.tsx#L97-L98

Added lines #L97 - L98 were not covered by tests
}
5 changes: 4 additions & 1 deletion src/pages/Group/Group.less
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@
max-width: 1920px;

.tab-item{
border: 1px solid var(--secondary-color);
img{
border: none !important;
}
border: none !important;
padding: 0.8rem;
border-radius: var(--border-radius);
filter: drop-shadow(0px 4px 4px rgba(0, 0, 0, 0.25));
Expand Down
15 changes: 11 additions & 4 deletions src/pages/Group/Group.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,17 @@
import { ProfileInfo } from "@/components/ProfileInfo/ProfileInfo";
import { AuthContext } from "@/contexts/Auth";
import "./Group.less";
import { ProfileClass } from "@/types/Profile";

export function GroupPage() {
const page = useLoaderData() as GroupPageLoaderResponse;
const authContext = useContext(AuthContext);
const [currentTab, setCurrentTab] = useState<AvailableTabs>("contents");
const [currentTab, setCurrentTab] = useState<AvailableTabs>("feed");

Check warning on line 13 in src/pages/Group/Group.tsx

View check run for this annotation

Codecov / codecov/patch

src/pages/Group/Group.tsx#L13

Added line #L13 was not covered by tests

const [context, setContext] = useState(makeContext(page));
useEffect(() => {
setContext(makeContext(page));
setCurrentTab("contents");
setCurrentTab("feed");

Check warning on line 18 in src/pages/Group/Group.tsx

View check run for this annotation

Codecov / codecov/patch

src/pages/Group/Group.tsx#L18

Added line #L18 was not covered by tests
}, [page]);

if (!page.loggedData || !page.group) {
Expand Down Expand Up @@ -69,14 +70,15 @@

return {
folders: data.folders,
posts: data.posts,
group: data.group!,
loggedData: {
isParticipant: data.loggedData?.isParticipant!,
profile: data.loggedData?.profile!,
profile: new ProfileClass(data.loggedData?.profile!),
links: data.loggedData?.links ?? [],
groups: data.loggedData?.groups ?? [],
},
participants: data.participants,
participants: data.participants.map(ProfileClass.new),
subgroups: data.subGroups,

currentContent: undefined,
Expand All @@ -99,6 +101,11 @@
setContext({...this, editGroup: c});
},

editPost: undefined,
setEditPost(c){
setContext({...this, editPost: c})

Check warning on line 106 in src/pages/Group/Group.tsx

View check run for this annotation

Codecov / codecov/patch

src/pages/Group/Group.tsx#L105-L106

Added lines #L105 - L106 were not covered by tests
},

refreshData: refreshGroupData,
};
}
Expand Down
17 changes: 14 additions & 3 deletions src/pages/Group/GroupContext.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
import { createContext } from "react";
import { Group } from "@/types/Group";
import { Profile } from "@/types/Profile";
import { type ProfileClass } from "@/types/Profile";
import type { Content, Folder } from "@/types/Capacity";
import { Link } from "@/types/Link";
import { GroupPost } from "@/types/Feed";

export type GroupContextType = null | {
group: Group;
subgroups: Group[];
participants: Profile[];
participants: ProfileClass[];
folders: Folder[];
posts: GroupPost[];

currentContent: Folder | undefined;
setCurrentContent(content: Folder | undefined): any;
Expand Down Expand Up @@ -40,9 +42,18 @@ export type GroupContextType = null | {
editGroup: Group | null | undefined;
setEditGroup(group: Group | null | undefined) : any;

/**
* The post being edited/created.
*
* If `null`, should handle creation of a post. If has a value, should handle
* post edit. If `undefined`, no post is being edited nor created.
*/
editPost: GroupPost | null | undefined;
setEditPost(post: GroupPost | null | undefined) : any;

loggedData: {
isParticipant: boolean;
profile: Profile;
profile: ProfileClass;
links: Link[];
groups: Group[];
};
Expand Down
129 changes: 129 additions & 0 deletions src/pages/Group/GroupTabs/GroupFeed/GroupFeed.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@

@import url(/src/layouts/colors.less);
@import url(/src/layouts/fonts.less);

#group-page #feed {
.feed-list {
.feed-item {
display: flex;
flex-direction: row;
align-items: start;

height: fit-content;

width: 100%;

&:not(:last-of-type) {
margin-bottom: 1.5rem;
}

.feed-image {
@side: 8rem !important;
width: @side;
height: @side;
aspect-ratio: 1;

border-radius: 100%;
object-fit: cover;
}

.info {
margin-left: 3rem;

color: @font-color-v2;
.group-name {
color: inherit;
text-decoration: none;
font-weight: @font-weight-semibold;
font-size: 1.5rem;
}

.group-description {
margin-top: .75rem;
text-align: justify;
}
}
.group-options-button {
margin-right: 1rem;
margin-left: auto;

display: flex;
padding-bottom: 3px;
align-items: center;
justify-content: center;

border: none;
border-radius: 50%;
background-color: transparent;

font-size: 1.5rem;
height: 2rem;
aspect-ratio: 1;

will-change: background-color;
cursor: pointer;

&:hover {
background-color: #C1C1C1;
}
}

.group-options {
background-color: @card-background-color;
border-radius: .625rem;
padding: .25rem .5rem;

min-width: 7rem;

.group-options-arrow {
fill: @card-background-color;
}

.dropdown-options-item {
display: flex;
flex-direction: row;
align-items: center;
width: 100%;

padding: .25rem .5rem;
border-radius: .625rem;

font-size: .9rem;

cursor: pointer;

&:hover {
background-color: @button-hover-color;
outline: none;

&.delete {
background-color: @alert-color;
color: @font-color-v1;
}
}

&[data-disabled] {
color: @font-disabled-color;

&:hover {
background-color: transparent;
}
}

&:not(:last-child) {
margin-bottom: .25rem;
}

.right-slot {
width: fit-content;
margin-left: auto;

&.bi {
font-size: 1.2em;
}
}
}
}
}
}
}
Loading
Loading