diff --git a/src/webapp/features/cards/components/addCardDrawer/AddCardDrawer.tsx b/src/webapp/features/cards/components/addCardDrawer/AddCardDrawer.tsx index 58a43381..1b9bf1bf 100644 --- a/src/webapp/features/cards/components/addCardDrawer/AddCardDrawer.tsx +++ b/src/webapp/features/cards/components/addCardDrawer/AddCardDrawer.tsx @@ -22,7 +22,7 @@ import { DEFAULT_OVERLAY_PROPS } from '@/styles/overlays'; interface Props { isOpen: boolean; onClose: () => void; - selectedCollection?: { id: string; name: string; cardCount: number }; + selectedCollection?: SelectableCollectionItem; } export default function AddCardDrawer(props: Props) { diff --git a/src/webapp/features/collections/components/addCardToModal/AddCardToModal.tsx b/src/webapp/features/cards/components/addCardToModal/AddCardToModal.tsx similarity index 94% rename from src/webapp/features/collections/components/addCardToModal/AddCardToModal.tsx rename to src/webapp/features/cards/components/addCardToModal/AddCardToModal.tsx index 0bc876eb..b6b4d1ae 100644 --- a/src/webapp/features/collections/components/addCardToModal/AddCardToModal.tsx +++ b/src/webapp/features/cards/components/addCardToModal/AddCardToModal.tsx @@ -1,5 +1,5 @@ import { UrlCardView } from '@/api-client/types'; -import useCollectionSearch from '../../lib/queries/useCollectionSearch'; +import useCollectionSearch from '@/features/collections/lib/queries/useCollectionSearch'; import { DEFAULT_OVERLAY_PROPS } from '@/styles/overlays'; import { Group, @@ -18,12 +18,12 @@ import { useDebouncedValue } from '@mantine/hooks'; import { Fragment, useState } from 'react'; import { IoSearch } from 'react-icons/io5'; import { BiPlus } from 'react-icons/bi'; -import useCollections from '../../lib/queries/useCollections'; +import useCollections from '../../../collections/lib/queries/useCollections'; import useCard from '@/features/cards/lib/queries/useGetCard'; import { notifications } from '@mantine/notifications'; -import CollectionSelectorError from '../collectionSelector/Error.CollectionSelector'; -import CollectionSelectorItemList from '../collectionSelectorItemList/CollectionSelectorItemList'; -import CreateCollectionDrawer from '../createCollectionDrawer/CreateCollectionDrawer'; +import CollectionSelectorError from '../../../collections/components/collectionSelector/Error.CollectionSelector'; +import CollectionSelectorItemList from '../../../collections/components/collectionSelectorItemList/CollectionSelectorItemList'; +import CreateCollectionDrawer from '../../../collections/components/createCollectionDrawer/CreateCollectionDrawer'; import CardToBeAddedPreview from './CardToBeAddedPreview'; import useAddCardToLibrary from '@/features/cards/lib/mutations/useAddCardToLibrary'; import useGetLibrariesForCard from '@/features/cards/lib/mutations/useGetLibrariesForcard'; @@ -51,12 +51,12 @@ export default function AddCardToModal(props: Props) { const card = useCard({ id: props.cardId }); const { data, error } = useCollections(); const [selectedCollections, setSelectedCollections] = useState< - { id: string; name: string; cardCount: number }[] + SelectableCollectionItem[] >([]); const handleCollectionChange = ( checked: boolean, - item: { id: string; name: string; cardCount: number }, + item: SelectableCollectionItem, ) => { if (checked) { if (!selectedCollections.some((col) => col.id === item.id)) { diff --git a/src/webapp/features/collections/components/addCardToModal/CardToBeAddedPreview.tsx b/src/webapp/features/cards/components/addCardToModal/CardToBeAddedPreview.tsx similarity index 100% rename from src/webapp/features/collections/components/addCardToModal/CardToBeAddedPreview.tsx rename to src/webapp/features/cards/components/addCardToModal/CardToBeAddedPreview.tsx diff --git a/src/webapp/features/cards/components/urlCardActions/UrlCardActions.tsx b/src/webapp/features/cards/components/urlCardActions/UrlCardActions.tsx index 4989e7c5..e0c167e7 100644 --- a/src/webapp/features/cards/components/urlCardActions/UrlCardActions.tsx +++ b/src/webapp/features/cards/components/urlCardActions/UrlCardActions.tsx @@ -10,7 +10,7 @@ import { BsThreeDots, BsTrash2Fill } from 'react-icons/bs'; import { LuUnplug } from 'react-icons/lu'; import RemoveCardFromCollectionModal from '../removeCardFromCollectionModal/RemoveCardFromCollectionModal'; import RemoveCardFromLibraryModal from '../removeCardFromLibraryModal/RemoveCardFromLibraryModal'; -import AddCardToModal from '@/features/collections/components/addCardToModal/AddCardToModal'; +import AddCardToModal from '@/features/cards/components/addCardToModal/AddCardToModal'; import { useAuth } from '@/hooks/useAuth'; interface Props { diff --git a/src/webapp/features/collections/components/addToCollectionModal/AddToCollectionModal.tsx b/src/webapp/features/collections/components/addToCollectionModal/AddToCollectionModal.tsx index 9fed88b9..fb1159c2 100644 --- a/src/webapp/features/collections/components/addToCollectionModal/AddToCollectionModal.tsx +++ b/src/webapp/features/collections/components/addToCollectionModal/AddToCollectionModal.tsx @@ -20,12 +20,12 @@ import { IoSearch } from 'react-icons/io5'; import { BiPlus } from 'react-icons/bi'; import useCollections from '../../lib/queries/useCollections'; import useCard from '@/features/cards/lib/queries/useGetCard'; -import useAddCardToCollection from '../../lib/mutations/useAddCardToCollection'; +import useAddCardToCollection from '@/features/collections/lib/mutations/useAddCardToCollection'; import { notifications } from '@mantine/notifications'; import CollectionSelectorError from '../collectionSelector/Error.CollectionSelector'; +import CardToBeAddedPreview from './CardToBeAddedPreview'; import CollectionSelectorItemList from '../collectionSelectorItemList/CollectionSelectorItemList'; import CreateCollectionDrawer from '../createCollectionDrawer/CreateCollectionDrawer'; -import CardToBeAddedPreview from './CardToBeAddedPreview'; interface Props { isOpen: boolean; @@ -45,12 +45,12 @@ export default function AddToCollectionModal(props: Props) { const card = useCard({ id: props.cardId }); const { data, error } = useCollections(); const [selectedCollections, setSelectedCollections] = useState< - { id: string; name: string; cardCount: number }[] + SelectableCollectionItem[] >([]); const handleCollectionChange = ( checked: boolean, - item: { id: string; name: string; cardCount: number }, + item: SelectableCollectionItem, ) => { if (checked) { if (!selectedCollections.some((col) => col.id === item.id)) { diff --git a/src/webapp/features/collections/components/collectionSelector/CollectionSelector.tsx b/src/webapp/features/collections/components/collectionSelector/CollectionSelector.tsx index f0233d5c..5ff57e6a 100644 --- a/src/webapp/features/collections/components/collectionSelector/CollectionSelector.tsx +++ b/src/webapp/features/collections/components/collectionSelector/CollectionSelector.tsx @@ -19,7 +19,7 @@ import { useDebouncedValue } from '@mantine/hooks'; import useCollections from '../../lib/queries/useCollections'; import useCollectionSearch from '../../lib/queries/useCollectionSearch'; import CollectionSelectorItemList from '../collectionSelectorItemList/CollectionSelectorItemList'; -import CreateCollectionDrawer from '../createCollectionDrawer/CreateCollectionDrawer'; +import CreateCollectionDrawer from '@/features/collections/components/createCollectionDrawer/CreateCollectionDrawer'; import CollectionSelectorError from './Error.CollectionSelector'; import { BiPlus } from 'react-icons/bi'; import { IoSearch } from 'react-icons/io5'; @@ -28,9 +28,9 @@ import { DEFAULT_OVERLAY_PROPS } from '@/styles/overlays'; interface Props { isOpen: boolean; onClose: () => void; - selectedCollections: { id: string; name: string; cardCount: number }[]; + selectedCollections: SelectableCollectionItem[]; onSelectedCollectionsChange: ( - collectionIds: { id: string; name: string; cardCount: number }[], + collectionIds: SelectableCollectionItem[], ) => void; } @@ -43,7 +43,7 @@ export default function CollectionSelector(props: Props) { const handleCollectionChange = ( checked: boolean, - item: { id: string; name: string; cardCount: number }, + item: SelectableCollectionItem, ) => { if (checked) { if (!props.selectedCollections.some((col) => col.id === item.id)) { diff --git a/src/webapp/features/collections/components/collectionSelectorItem/CollectionSelectorItem.tsx b/src/webapp/features/collections/components/collectionSelectorItem/CollectionSelectorItem.tsx index 98a53a8f..a400df65 100644 --- a/src/webapp/features/collections/components/collectionSelectorItem/CollectionSelectorItem.tsx +++ b/src/webapp/features/collections/components/collectionSelectorItem/CollectionSelectorItem.tsx @@ -1,4 +1,10 @@ -import { CheckboxCard, CheckboxIndicator, Group, Text } from '@mantine/core'; +import { + CheckboxCard, + CheckboxIndicator, + Group, + Text, + Tooltip, +} from '@mantine/core'; import classes from './CollectionSelectorItem.module.css'; interface Props { @@ -6,47 +12,49 @@ interface Props { name: string; checked: boolean; cardCount: number; - onChange: ( - checked: boolean, - item: { id: string; name: string; cardCount: number }, - ) => void; + onChange: (checked: boolean, item: SelectableCollectionItem) => void; disabled?: boolean; } export default function CollectionSelectorItem(props: Props) { return ( - - props.onChange(checked, { - id: props.value, - name: props.name, - cardCount: props.cardCount, - }) - } + - - - - {props.name} - - · - - {props.cardCount} {props.cardCount === 1 ? 'card' : 'cards'} - + + props.onChange(checked, { + id: props.value, + name: props.name, + cardCount: props.cardCount, + }) + } + > + + + + {props.name} + + · + + {props.cardCount} {props.cardCount === 1 ? 'card' : 'cards'} + + + - - - + + ); } diff --git a/src/webapp/features/collections/types/index.ts b/src/webapp/features/collections/types/index.ts new file mode 100644 index 00000000..65ae958a --- /dev/null +++ b/src/webapp/features/collections/types/index.ts @@ -0,0 +1,5 @@ +interface SelectableCollectionItem { + id: string; + name: string; + cardCount: number; +}