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) 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; }