11import { Response } from '@/lib/api/response' ;
22import { Tag } from '@/lib/db/models/tag' ;
3- import { ActionIcon , Group , Modal , Stack , Text , Title , Tooltip } from '@mantine/core' ;
3+ import { ActionIcon , Group , Modal , Paper , Stack , Text , Title , Tooltip } from '@mantine/core' ;
44import { IconPencil , IconPlus , IconTagOff , IconTags , IconTrashFilled } from '@tabler/icons-react' ;
55import { useRouter } from 'next/router' ;
66import { useEffect , useState } from 'react' ;
@@ -10,6 +10,7 @@ import { fetchApi } from '@/lib/fetchApi';
1010import { showNotification } from '@mantine/notifications' ;
1111import CreateTagModal from './CreateTagModal' ;
1212import EditTagModal from './EditTagModal' ;
13+ import { mutateFiles } from '@/components/file/actions' ;
1314
1415export default function TagsButton ( ) {
1516 const router = useRouter ( ) ;
@@ -40,6 +41,7 @@ export default function TagsButton() {
4041 }
4142
4243 mutate ( ) ;
44+ mutateFiles ( ) ;
4345 } ;
4446
4547 useEffect ( ( ) => {
@@ -77,21 +79,31 @@ export default function TagsButton() {
7779 < TagPill tag = { tag } />
7880
7981 < Text size = 'sm' c = 'dimmed' >
80- { tag . files ! . length } files
82+ { tag . files ! . length } file { tag . files ! . length === 1 ? '' : 's' }
8183 </ Text >
8284 </ Group >
8385
8486 < Group >
85- < ActionIcon variant = 'outline' onClick = { ( ) => setSelectedTag ( tag ) } >
86- < IconPencil size = '1rem' />
87- </ ActionIcon >
87+ < Tooltip label = 'Edit tag' >
88+ < ActionIcon variant = 'outline' onClick = { ( ) => setSelectedTag ( tag ) } >
89+ < IconPencil size = '1rem' />
90+ </ ActionIcon >
91+ </ Tooltip >
8892
89- < ActionIcon variant = 'outline' color = 'red' onClick = { ( ) => handleDelete ( tag ) } >
90- < IconTrashFilled size = '1rem' />
91- </ ActionIcon >
93+ < Tooltip label = 'Delete tag' >
94+ < ActionIcon variant = 'outline' color = 'red' onClick = { ( ) => handleDelete ( tag ) } >
95+ < IconTrashFilled size = '1rem' />
96+ </ ActionIcon >
97+ </ Tooltip >
9298 </ Group >
9399 </ Group >
94100 ) ) }
101+
102+ { tags ?. length === 0 && (
103+ < Paper withBorder px = 'sm' py = 'xs' >
104+ No tags. Create one by clicking the plus icon.
105+ </ Paper >
106+ ) }
95107 </ Stack >
96108 </ Modal >
97109
0 commit comments