From 6220c7b9bde6d5889b4b82ed53eafac46dc7cae0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucas=20Per=C3=B4nico=20Barbotin?= Date: Thu, 14 Dec 2023 13:08:03 -0300 Subject: [PATCH 1/3] Corrigindo erro de charLimit --- src/components/UniversiForm/UniversiForm.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/components/UniversiForm/UniversiForm.tsx b/src/components/UniversiForm/UniversiForm.tsx index 12d6889d..5521db9a 100644 --- a/src/components/UniversiForm/UniversiForm.tsx +++ b/src/components/UniversiForm/UniversiForm.tsx @@ -160,7 +160,9 @@ export function UniversiForm(props : formProps){ function getCharLimit(object : FormObject){ - if(object.type == FormInputs.TEXT) + if(object.charLimit) + return object.charLimit; + else if(object.type == FormInputs.TEXT) return MAX_TEXT_LENGTH; else if(object.type == FormInputs.LONG_TEXT) return MAX_LONG_TEXT_LENGTH From ceda19dae24573d4cba705ad157ecd0a83a105dc Mon Sep 17 00:00:00 2001 From: 710lucas Date: Thu, 14 Dec 2023 13:27:37 -0300 Subject: [PATCH 2/3] Ajustando charLimit --- src/components/UniversiForm/UniversiForm.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/components/UniversiForm/UniversiForm.tsx b/src/components/UniversiForm/UniversiForm.tsx index 12d6889d..2c131779 100644 --- a/src/components/UniversiForm/UniversiForm.tsx +++ b/src/components/UniversiForm/UniversiForm.tsx @@ -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) From 36bb2b27259c9c97f53397da75466268c7244db6 Mon Sep 17 00:00:00 2001 From: 710lucas Date: Thu, 14 Dec 2023 13:27:56 -0300 Subject: [PATCH 3/3] =?UTF-8?q?Adicionando=20edi=C3=A7=C3=A3o=20de=20post?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Group/GroupTabs/GroupFeed/GroupFeed.tsx | 4 +++- src/services/UniversimeApi/Feed.ts | 21 +++++++++++++------ 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/src/pages/Group/GroupTabs/GroupFeed/GroupFeed.tsx b/src/pages/Group/GroupTabs/GroupFeed/GroupFeed.tsx index 7a4e7e39..75efaa4b 100644 --- a/src/pages/Group/GroupTabs/GroupFeed/GroupFeed.tsx +++ b/src/pages/Group/GroupTabs/GroupFeed/GroupFeed.tsx @@ -104,9 +104,11 @@ export function GroupFeed(){ charLimit: 3000, value: groupContext.editPost ? groupContext.editPost.content : "" ,validation: new ValidationComposite().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} + requisition={groupContext.editPost ? UniversimeApi.Feed.editGroupPost : UniversimeApi.Feed.createGroupPost} callback={groupContext.refreshData} /> : diff --git a/src/services/UniversimeApi/Feed.ts b/src/services/UniversimeApi/Feed.ts index 7d5e9c12..c99efb98 100644 --- a/src/services/UniversimeApi/Feed.ts +++ b/src/services/UniversimeApi/Feed.ts @@ -3,8 +3,8 @@ import { api } from "./api"; import {GroupPost} from "@/types/Feed" export type CreateGroupPost_RequestDTO = { - content: string; - groupId : string; + content : string; + groupId : string; authorId : string; }; @@ -12,11 +12,16 @@ 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; export type GetGroupPostsResponseDTO = ApiResponse<{posts: GroupPost[]}>; @@ -26,10 +31,14 @@ export async function getGroupPosts(body : GetGroupPost_RequestDTO): Promise { - return await (await api.post(`/feed/groups/${body.groupId}/posts`, body)).data; + return (await api.post(`/feed/groups/${body.groupId}/posts`, body)).data; +} + +export async function editGroupPost(body : EditGroupPost_RequestDTO) : Promise> { + return (await api.put>(`/feed/groups/${body.groupId}/posts/${body.postId}`, body)).data; } -export async function deleteGroupPost(body: DeleteGroup_RequestDTO): Promise> { +export async function deleteGroupPost(body: DeleteGroupPost_RequestDTO): Promise> { const response = await api.delete>(`/feed/groups/${body.groupId}/posts/${body.postId}`); return response.data; }