diff --git a/libs/api/rating/data-access/src/lib/api-manager-rating.service.ts b/libs/api/rating/data-access/src/lib/api-manager-rating.service.ts index 24cbc1ec..bee285ca 100644 --- a/libs/api/rating/data-access/src/lib/api-manager-rating.service.ts +++ b/libs/api/rating/data-access/src/lib/api-manager-rating.service.ts @@ -1,4 +1,5 @@ import { ApiCoreService } from '@deanslist-platform/api-core-data-access' +import { ProjectStatus } from '@deanslist-platform/sdk' import { Injectable } from '@nestjs/common' import { ManagerCreateRatingInput } from './dto/manager-create-rating.input' import { ManagerUpdateRatingInput } from './dto/manager-update-rating.input' @@ -8,7 +9,15 @@ export class ApiManagerRatingService { constructor(private readonly core: ApiCoreService) {} async createRating(userId: string, input: ManagerCreateRatingInput) { - await this.ensureCommentProjectManager(userId, input.commentId) + const comment = await this.ensureCommentProjectManager(userId, input.commentId) + + if (!comment) { + throw new Error(`Comment not found`) + } + + if (comment.review.project.status !== ProjectStatus.Closed) { + throw new Error('You can only rate closed projects') + } return this.core.data.rating.create({ data: { ...input, authorId: userId } }) } diff --git a/libs/web/comment/feature/src/lib/manager-comment-list.feature.tsx b/libs/web/comment/feature/src/lib/manager-comment-list.feature.tsx index cb744651..3efc3503 100644 --- a/libs/web/comment/feature/src/lib/manager-comment-list.feature.tsx +++ b/libs/web/comment/feature/src/lib/manager-comment-list.feature.tsx @@ -3,7 +3,7 @@ import { ManagerCommentUiTimeline } from '@deanslist-platform/web-comment-ui' import { CoreUiDebugModal, CoreUiSearchField } from '@deanslist-platform/web-core-ui' import { useManagerRating } from '@deanslist-platform/web-rating-data-access' import { Group } from '@mantine/core' -import { UiInfo, UiLoader, UiStack } from '@pubkey-ui/core' +import { UiGroup, UiInfo, UiLoader, UiStack } from '@pubkey-ui/core' export function ManagerCommentListFeature({ projectId }: { projectId: string }) { const { items, query, setSearch } = useManagerFindManyComment({ @@ -14,10 +14,13 @@ export function ManagerCommentListFeature({ projectId }: { projectId: string }) return ( - - - - + +
+ + + + + {query.isLoading ? ( diff --git a/libs/web/comment/ui/src/lib/comment-ui-comment.tsx b/libs/web/comment/ui/src/lib/comment-ui-comment.tsx index 6c880de9..58a390a6 100644 --- a/libs/web/comment/ui/src/lib/comment-ui-comment.tsx +++ b/libs/web/comment/ui/src/lib/comment-ui-comment.tsx @@ -28,7 +28,7 @@ export function CommentUiComment({ - + {comment.author.username} diff --git a/libs/web/comment/ui/src/lib/manager-comment-ui-timeline-item.tsx b/libs/web/comment/ui/src/lib/manager-comment-ui-timeline-item.tsx index c0137df3..7cc2170d 100644 --- a/libs/web/comment/ui/src/lib/manager-comment-ui-timeline-item.tsx +++ b/libs/web/comment/ui/src/lib/manager-comment-ui-timeline-item.tsx @@ -1,10 +1,12 @@ import { Comment, ManagerCreateRatingInput, ManagerUpdateRatingInput } from '@deanslist-platform/sdk' -import { CoreUiDebugModal } from '@deanslist-platform/web-core-ui' -import { Button, Collapse, Group, Rating as MantineRating } from '@mantine/core' -import { useDisclosure } from '@mantine/hooks' -import { UiGroup, UiStack } from '@pubkey-ui/core' -import { IconMessage } from '@tabler/icons-react' +import { CoreUiDivider } from '@deanslist-platform/web-core-ui' +import { ActionIcon, Button, Group, Rating as MantineRating } from '@mantine/core' +import { UiStack } from '@pubkey-ui/core' +import { IconArrowsMaximize, IconArrowsMinimize, IconExternalLink } from '@tabler/icons-react' +import React, { useState } from 'react' +import { Link } from 'react-router-dom' import { CommentUiComment } from './comment-ui-comment' +import { CommentUiDetailsPopover } from './comment-ui-details-popover' import { ManagerCommentUiRating } from './manager-comment-ui-rating' export function ManagerCommentUiTimelineItem({ @@ -18,51 +20,55 @@ export function ManagerCommentUiTimelineItem({ deleteRating: (ratingId: string) => Promise updateRating: (ratingId: string, res: ManagerUpdateRatingInput) => Promise }) { - const viewUrl = comment.review?.viewUrl ?? null - const [opened, { toggle }] = useDisclosure(false) + const [showReplies, setShowReplies] = useState(false) return ( - - + + + + + {comment?.review?.viewUrl ? ( + + + + ) : null} + + } + /> + + + + + + + {showReplies && comment.children?.length ? ( - - - - - - - - - - -
- - - {comment.children?.length ? ( - - {comment.children.map((child) => ( - - ))} + {comment.children.map((child) => ( + + + + + - ) : null} - - - } - /> + ))} + + ) : null} + + + ) } diff --git a/libs/web/comment/ui/src/lib/manager-comment-ui-timeline.tsx b/libs/web/comment/ui/src/lib/manager-comment-ui-timeline.tsx index 2143c3fa..be435e0f 100644 --- a/libs/web/comment/ui/src/lib/manager-comment-ui-timeline.tsx +++ b/libs/web/comment/ui/src/lib/manager-comment-ui-timeline.tsx @@ -1,5 +1,7 @@ import { Comment, ManagerCreateRatingInput, ManagerUpdateRatingInput } from '@deanslist-platform/sdk' +import { CoreUiDivider } from '@deanslist-platform/web-core-ui' import { UiStack } from '@pubkey-ui/core' +import React from 'react' import { ManagerCommentUiTimelineItem } from './manager-comment-ui-timeline-item' export function ManagerCommentUiTimeline({ @@ -16,13 +18,16 @@ export function ManagerCommentUiTimeline({ return ( {comments.map((comment) => ( - + + + + ))} ) diff --git a/libs/web/comment/ui/src/lib/manager-rating-ui-form.tsx b/libs/web/comment/ui/src/lib/manager-rating-ui-form.tsx index d0813421..ca031b96 100644 --- a/libs/web/comment/ui/src/lib/manager-rating-ui-form.tsx +++ b/libs/web/comment/ui/src/lib/manager-rating-ui-form.tsx @@ -1,4 +1,5 @@ import { User } from '@deanslist-platform/sdk' +import { cardGradient } from '@deanslist-platform/web-core-ui' import { UserUiAvatar } from '@deanslist-platform/web-user-ui' import { ActionIcon, Flex, Rating as MantineRating, Textarea } from '@mantine/core' import { useForm } from '@mantine/form' @@ -32,8 +33,8 @@ export function ManagerRatingUiForm({ > {author ? :
} -