Skip to content

Commit

Permalink
Merge branch 'main' into change#309/mudanças-em-css
Browse files Browse the repository at this point in the history
  • Loading branch information
710lucas authored Dec 16, 2023
2 parents f626995 + 21b97b8 commit 9618ba5
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 11 deletions.
4 changes: 3 additions & 1 deletion src/components/UniversiForm/UniversiForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,9 @@ export function UniversiForm(props : formProps){



function getCharLimit(object : FormObject){
function getCharLimit(object : FormObjectText){
if(object.charLimit)
return object.charLimit;
if(object.type == FormInputs.TEXT)
return MAX_TEXT_LENGTH;
else if(object.type == FormInputs.LONG_TEXT)
Expand Down
1 change: 1 addition & 0 deletions src/pages/Group/GroupTabs/GroupFeed/GroupFeed.less
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
width: 100%;
justify-content: space-between;
margin-top: 1rem;

.group-name {
color: inherit;
text-decoration: none;
Expand Down
31 changes: 27 additions & 4 deletions src/pages/Group/GroupTabs/GroupFeed/GroupFeed.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ export function GroupFeed(){
]

function handleDeletePost(post: GroupPost){
console.log(post)
UniversimeApi.Feed.deleteGroupPost({postId: post.postId, groupId: post.groupId});
groupContext?.refreshData();
}
Expand Down Expand Up @@ -104,10 +103,12 @@ export function GroupFeed(){
charLimit: 3000,
value: groupContext.editPost ? groupContext.editPost.content : ""
,validation: new ValidationComposite<string>().addValidation(new RequiredValidation()).addValidation(new TextValidation())
}, {
DTOName : "postId", label : "", type : FormInputs.HIDDEN, value : groupContext.editPost?.postId
}
]}
requisition={groupContext.editPost ? UniversimeApi.Feed.createGroupPost : UniversimeApi.Feed.createGroupPost}
callback={() =>{groupContext.refreshData()}}
requisition={groupContext.editPost ? UniversimeApi.Feed.editGroupPost : UniversimeApi.Feed.createGroupPost}
callback={() => {groupContext.refreshData()}}
/>
:
<></>
Expand Down Expand Up @@ -165,8 +166,30 @@ export function GroupFeed(){

<div className="info">
<p className="feed-description">{post.content}</p>
{ !hasAvailableOption(OPTIONS_DEFINITION) || !canSeeMenu(post) ? null :
<DropdownMenu.Root>
<DropdownMenu.Trigger asChild>
<button className="options-button">
<i className="bi bi-three-dots-vertical" />
</button>
</DropdownMenu.Trigger>

<DropdownMenu.Content className="options" side="left">
{ OPTIONS_DEFINITION.map(def => {
if(def.text == "Editar publicação" && post.author?.id == groupContext?.loggedData.profile.id)
return renderOption(post, def)
else if(def.text == "Editar publicação")
return null
else
return renderOption(post, def)

}) }
<DropdownMenu.Arrow className="options-arrow" height=".5rem" width="1rem" />
</DropdownMenu.Content>
</DropdownMenu.Root>
}
</div>
</div>
)
}
}
}
22 changes: 16 additions & 6 deletions src/services/UniversimeApi/Feed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,26 @@ import { api } from "./api";
import {GroupPost} from "@/types/Feed"

export type CreateGroupPost_RequestDTO = {
content: string;
groupId : string;
content : string;
groupId : string;
authorId : string;
};

export type GetGroupPost_RequestDTO = {
groupId : string;
}

export type DeleteGroup_RequestDTO = {
postId : string;

export type DeleteGroupPost_RequestDTO = {
postId : string;
groupId : string;
}

export type EditGroupPost_RequestDTO = {
content : string;
postId : string;
groupId : string;
}

export type CreateGroupPostResponseDTO = ApiResponse<GroupPost>;
export type GetGroupPostsResponseDTO = ApiResponse<{posts: GroupPost[]}>;
Expand All @@ -26,10 +32,14 @@ export async function getGroupPosts(body : GetGroupPost_RequestDTO): Promise<Get
}

export async function createGroupPost(body: CreateGroupPost_RequestDTO): Promise<CreateGroupPostResponseDTO> {
return await (await api.post<CreateGroupPostResponseDTO>(`/feed/groups/${body.groupId}/posts`, body)).data;
return (await api.post<CreateGroupPostResponseDTO>(`/feed/groups/${body.groupId}/posts`, body)).data;
}

export async function editGroupPost(body : EditGroupPost_RequestDTO) : Promise<ApiResponse<string>> {
return (await api.put<ApiResponse<string>>(`/feed/groups/${body.groupId}/posts/${body.postId}`, body)).data;
}

export async function deleteGroupPost(body: DeleteGroup_RequestDTO): Promise<ApiResponse<string>> {
export async function deleteGroupPost(body: DeleteGroupPost_RequestDTO): Promise<ApiResponse<string>> {
const response = await api.delete<ApiResponse<string>>(`/feed/groups/${body.groupId}/posts/${body.postId}`);
return response.data;
}

0 comments on commit 9618ba5

Please sign in to comment.