From 6579b8eec6481aac48204a83fb9f05d57269784f Mon Sep 17 00:00:00 2001
From: camilovegag
Date: Wed, 15 May 2024 12:13:05 -0500
Subject: [PATCH] Add author and co authors & update type
---
packages/api/src/types/OptionUsersType.ts | 22 +++++++++++++++-----
packages/berlin/src/pages/Comments.tsx | 25 +++++++++++++----------
2 files changed, 31 insertions(+), 16 deletions(-)
diff --git a/packages/api/src/types/OptionUsersType.ts b/packages/api/src/types/OptionUsersType.ts
index 8c5a2fa9..b2d844a4 100644
--- a/packages/api/src/types/OptionUsersType.ts
+++ b/packages/api/src/types/OptionUsersType.ts
@@ -1,11 +1,23 @@
-import { GetGroupsResponse } from './GroupType';
-import { GetUserResponse } from './UserType';
-
export type GetOptionUsersResponse = {
optionId: string;
registrationId: string | null;
userId: string | null;
- user: GetUserResponse | null;
+ user: {
+ id: string;
+ username: string;
+ firstName: string;
+ lastName: string;
+ } | null;
groupId: string | null;
- group: GetGroupsResponse | null;
+ group: {
+ id: null;
+ users:
+ | {
+ id: string;
+ username: string;
+ firstName: string;
+ lastName: string;
+ }[]
+ | null;
+ } | null;
};
diff --git a/packages/berlin/src/pages/Comments.tsx b/packages/berlin/src/pages/Comments.tsx
index d0541b95..31611a1c 100644
--- a/packages/berlin/src/pages/Comments.tsx
+++ b/packages/berlin/src/pages/Comments.tsx
@@ -11,7 +11,7 @@ import {
fetchUserVotes,
fetchComments,
postComment,
- // fetchOptionUsers,
+ fetchOptionUsers,
} from 'api';
// Hooks
@@ -66,11 +66,11 @@ function Comments() {
retry: false,
});
- // const { data: optionUsers } = useQuery({
- // queryKey: ['optionUsers', optionId],
- // queryFn: () => fetchOptionUsers(optionId || ''),
- // enabled: !!optionId,
- // });
+ const { data: optionUsers } = useQuery({
+ queryKey: ['optionUsers', optionId],
+ queryFn: () => fetchOptionUsers(optionId || ''),
+ enabled: !!optionId,
+ });
const { data: comments } = useQuery({
queryKey: ['comments', optionId],
@@ -183,12 +183,15 @@ function Comments() {
{option?.optionTitle}
{option?.optionSubTitle}
- {/*
- Lead author: {option?.user} [// TODO]
-
- Co-authors: [// TODO]
- */}
+ Lead author: {optionUsers?.user?.firstName} {optionUsers?.user?.lastName}
+
+ Co-authors:{' '}
+ {optionUsers.group.users.map((user) => `${(user.firstName, user.lastName)}`)}
+