Skip to content

Commit

Permalink
Add author and co authors & update type
Browse files Browse the repository at this point in the history
  • Loading branch information
camilovegag committed May 15, 2024
1 parent 5bf807e commit 6579b8e
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 16 deletions.
22 changes: 17 additions & 5 deletions packages/api/src/types/OptionUsersType.ts
Original file line number Diff line number Diff line change
@@ -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;
};
25 changes: 14 additions & 11 deletions packages/berlin/src/pages/Comments.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
fetchUserVotes,
fetchComments,
postComment,
// fetchOptionUsers,
fetchOptionUsers,
} from 'api';

// Hooks
Expand Down Expand Up @@ -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],
Expand Down Expand Up @@ -183,12 +183,15 @@ function Comments() {
</FlexRow>
<Subtitle>{option?.optionTitle}</Subtitle>
<Body>{option?.optionSubTitle}</Body>
{/* <Body>
<Bold>Lead author: {option?.user}</Bold> [// TODO]
</Body>
<Body>
<Bold>Co-authors:</Bold> [// TODO]
</Body> */}
<Bold>Lead author:</Bold> {optionUsers?.user?.firstName} {optionUsers?.user?.lastName}
</Body>
{optionUsers?.group?.users && (
<Body>
<Bold>Co-authors:</Bold>{' '}
{optionUsers.group.users.map((user) => `${(user.firstName, user.lastName)}`)}
</Body>
)}
</FlexColumn>

<Button onClick={handleSaveVotesWrapper} disabled={!votesAreDifferent}>
Expand Down

0 comments on commit 6579b8e

Please sign in to comment.