From a25bb7791c62365100293c6994f6ab58e3f7d05a Mon Sep 17 00:00:00 2001 From: Diego Alzate Date: Fri, 2 Aug 2024 14:22:50 +0100 Subject: [PATCH 1/3] fix comments api call --- packages/api/src/postComment.ts | 4 ++-- packages/api/src/types/Comments.ts | 4 ++-- packages/berlin/src/pages/Comments.tsx | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/api/src/postComment.ts b/packages/api/src/postComment.ts index e7693bc5..73764c89 100644 --- a/packages/api/src/postComment.ts +++ b/packages/api/src/postComment.ts @@ -1,7 +1,7 @@ import { ApiRequest, PostCommentRequest, PostCommentResponse } from './types'; export async function postComment({ - questionOptionId, + optionId, value, serverUrl, }: ApiRequest): Promise { @@ -12,7 +12,7 @@ export async function postComment({ headers: { 'Content-type': 'application/json', }, - body: JSON.stringify({ value, questionOptionId }), + body: JSON.stringify({ value, optionId }), }); if (!response.ok) { diff --git a/packages/api/src/types/Comments.ts b/packages/api/src/types/Comments.ts index ae006265..e8b931bb 100644 --- a/packages/api/src/types/Comments.ts +++ b/packages/api/src/types/Comments.ts @@ -4,7 +4,7 @@ export type Comment = { updatedAt: Date; userId: string | null; value: string; - questionOptionId: string | null; + optionId: string | null; }; export type GetCommentsRequest = { @@ -22,7 +22,7 @@ export type GetCommentsResponse = (Comment & { export type PostCommentRequest = { value: string; - questionOptionId: string; + optionId: string; }; export type DeleteCommentRequest = { diff --git a/packages/berlin/src/pages/Comments.tsx b/packages/berlin/src/pages/Comments.tsx index 2b221805..b8ad5fb2 100644 --- a/packages/berlin/src/pages/Comments.tsx +++ b/packages/berlin/src/pages/Comments.tsx @@ -89,7 +89,7 @@ function Comments() { const handlePostComment = () => { if (optionId && comment) { mutateComments({ - questionOptionId: optionId, + optionId: optionId, value: comment, serverUrl: import.meta.env.VITE_SERVER_URL, }); From d7f14ee30bfc170c784de4e752c6a7e00fa3cb83 Mon Sep 17 00:00:00 2001 From: Diego Alzate Date: Fri, 2 Aug 2024 14:25:15 +0100 Subject: [PATCH 2/3] fix fetch user options api call --- packages/api/src/types/Options.ts | 4 ++-- packages/api/src/types/UserOptions.ts | 4 ++-- packages/berlin/src/pages/Account.tsx | 2 +- packages/berlin/src/pages/Comments.tsx | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/api/src/types/Options.ts b/packages/api/src/types/Options.ts index 8c0dbfe6..e13b8cdf 100644 --- a/packages/api/src/types/Options.ts +++ b/packages/api/src/types/Options.ts @@ -3,9 +3,9 @@ export type Option = { createdAt: string; updatedAt: string; questionId: string; - optionTitle: string; + title: string; userId?: string; - optionSubTitle?: string; + subTitle?: string; accepted: boolean; data: unknown; fundingRequest: string; diff --git a/packages/api/src/types/UserOptions.ts b/packages/api/src/types/UserOptions.ts index 6208f635..f6afb6f9 100644 --- a/packages/api/src/types/UserOptions.ts +++ b/packages/api/src/types/UserOptions.ts @@ -5,8 +5,8 @@ export type GetUserOptionsResponse = { userId: string | null; registrationId: string | null; questionId: string; - optionTitle: string; - optionSubTitle: string | null; + title: string; + subTitle: string | null; accepted: boolean | null; voteScore: string; fundingRequest: string | null; diff --git a/packages/berlin/src/pages/Account.tsx b/packages/berlin/src/pages/Account.tsx index 782a522d..f6e51c37 100644 --- a/packages/berlin/src/pages/Account.tsx +++ b/packages/berlin/src/pages/Account.tsx @@ -141,7 +141,7 @@ function AccountHub({ user }: { user: GetUserResponse | null | undefined }) { key={option.id} to={`/events/${cycles.find((c) => c.data?.id === option.question.cycleId)?.data?.eventId}/cycles/${option.question.cycleId}/options/${option.id}`} > - - {option.optionTitle} + - {option.title} ))} diff --git a/packages/berlin/src/pages/Comments.tsx b/packages/berlin/src/pages/Comments.tsx index b8ad5fb2..813b9e3a 100644 --- a/packages/berlin/src/pages/Comments.tsx +++ b/packages/berlin/src/pages/Comments.tsx @@ -105,8 +105,8 @@ function Comments() { - {option?.optionTitle} - {option?.optionSubTitle} + {option?.title} + {option?.subTitle} Lead author: {optionUsers?.user?.firstName} {optionUsers?.user?.lastName} {coauthors && coauthors.length > 0 && ( From f09a841763a94f7919d30c0a2e535d044e3ce91e Mon Sep 17 00:00:00 2001 From: Diego Alzate Date: Fri, 2 Aug 2024 14:25:55 +0100 Subject: [PATCH 3/3] remove commented code in comments page --- packages/berlin/src/pages/Comments.tsx | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/packages/berlin/src/pages/Comments.tsx b/packages/berlin/src/pages/Comments.tsx index 813b9e3a..607b45c3 100644 --- a/packages/berlin/src/pages/Comments.tsx +++ b/packages/berlin/src/pages/Comments.tsx @@ -7,17 +7,6 @@ import { useMemo, useState } from 'react'; // API import { fetchOption, fetchComments, postComment, fetchOptionUsers } from 'api'; -// Hooks -// import useUser from '../hooks/useUser'; - -// Utils -// import { -// handleSaveVotes, -// handleAvailableHearts, -// handleLocalUnVote, -// handleLocalVote, -// } from '../utils/voting'; - // Components import { Body } from '../components/typography/Body.styled'; import { Bold } from '../components/typography/Bold.styled'; @@ -31,9 +20,6 @@ import CommentsColumns from '../components/columns/comments-columns'; import CommentsTable from '../components/tables/comment-table'; import Icon from '../components/icon'; import Textarea from '../components/textarea'; -// import { INITIAL_HEARTS } from '../utils/constants'; - -// type LocalUserVotes = { optionId: string; numOfVotes: number }[]; function Comments() { const queryClient = useQueryClient();