Skip to content

Commit

Permalink
fix: add tooltip to show when a rating was created
Browse files Browse the repository at this point in the history
  • Loading branch information
beeman committed Aug 28, 2024
1 parent 40049dc commit 63bb396
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 60 deletions.
4 changes: 2 additions & 2 deletions libs/web/comment/ui/src/lib/manager-comment-ui-rating.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ export function ManagerCommentUiRating({
author={rating.author}
disabled
content={rating.content}
rating={rating.rating}
rating={rating}
submit={(input) => update(rating.id, input)}
/>
))}
{userRating ? (
<ManagerRatingUiForm
author={user}
content={userRating.content}
rating={userRating.rating}
rating={userRating}
submit={(input) => update(userRating.id, input)}
delete={() => deleteRating(userRating.id)}
/>
Expand Down
19 changes: 12 additions & 7 deletions libs/web/comment/ui/src/lib/manager-rating-ui-form.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import { User } from '@deanslist-platform/sdk'
import { Rating, User } from '@deanslist-platform/sdk'
import { cardGradient, CoreUiRating } from '@deanslist-platform/web-core-ui'
import { UserUiAvatar } from '@deanslist-platform/web-user-ui'
import { ActionIcon, Flex, Textarea } from '@mantine/core'
import { ActionIcon, Box, Flex, Textarea, Tooltip } from '@mantine/core'
import { useForm } from '@mantine/form'
import { IconCheck, IconTrash } from '@tabler/icons-react'

export function ManagerRatingUiForm({
author,
content,
delete: deleteRating,
disabled = false,
rating,
Expand All @@ -16,14 +15,14 @@ export function ManagerRatingUiForm({
author?: User | null
disabled?: boolean
content?: string | null
rating?: number
rating?: Rating
delete?: () => Promise<boolean>
submit: (input: { rating: number; content: string }) => Promise<boolean>
}) {
const form = useForm<{ rating: number; content: string }>({
initialValues: {
content: content ?? '',
rating: rating ?? 0,
content: rating?.content ?? '',
rating: rating?.rating ?? 0,
},
})

Expand All @@ -42,7 +41,13 @@ export function ManagerRatingUiForm({
placeholder="Write a comment about the rating."
{...form.getInputProps('content')}
/>
<CoreUiRating fractions={1} readOnly={disabled} {...form.getInputProps('rating')} />
<Tooltip
label={rating ? `Rating created ${new Date(rating?.createdAt ?? '0').toLocaleString()}` : 'Rate this content'}
>
<Box>
<CoreUiRating fractions={1} readOnly={disabled} {...form.getInputProps('rating')} />
</Box>
</Tooltip>
{disabled ? null : (
<ActionIcon type="submit" disabled={!form.isDirty()}>
<IconCheck size={16} stroke={1.5} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export function useAdminFindOneProject({ projectId }: { projectId: string }) {
.then(async (res) => {
if (res.updated) {
if (toast) {
toastSuccess('Project updated 1')
toastSuccess('Project updated')
}
return res.updated
}
Expand Down
4 changes: 1 addition & 3 deletions libs/web/rating/ui/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
export * from './lib/manager-rating-ui-create-form'
export * from './lib/manager-rating-ui-table'
export * from './lib/manager-rating-ui-update-form'
export * from './lib/admin-rating-ui-table'
export * from './lib/admin-rating-ui-update-form'
export * from './lib/manager-rating-ui-table'
22 changes: 0 additions & 22 deletions libs/web/rating/ui/src/lib/manager-rating-ui-create-form.tsx

This file was deleted.

25 changes: 0 additions & 25 deletions libs/web/rating/ui/src/lib/manager-rating-ui-update-form.tsx

This file was deleted.

0 comments on commit 63bb396

Please sign in to comment.