diff --git a/src/components/modals/ModalCollectionSelector.tsx b/src/components/modals/ModalCollectionSelector.tsx index a4d9d4d..ac9f047 100644 --- a/src/components/modals/ModalCollectionSelector.tsx +++ b/src/components/modals/ModalCollectionSelector.tsx @@ -3,6 +3,7 @@ import { Box, Button, Checkbox, + Flex, Modal, ModalBody, ModalCloseButton, @@ -119,6 +120,38 @@ export function ModalCollectionSelector({ } } + function renderContent() { + if (isPending) { + return ( + + + + ); + } + + if (!data || data.length === 0) { + return ( + <> + + No hay colecciones disponibles. + Crea una colección primero. + + + ); + } + + return data.map((collection) => ( + handleCheckboxChange(collection.id)} + colorScheme='green' + > + {collection.name} + + )); + } + return ( <> - {isPending ? ( - - - - ) : ( - data?.map((collection) => ( - handleCheckboxChange(collection.id)} - colorScheme='green' - > - {collection.name} - - )) - )} + {renderContent()} + + + ); + + btnOptionsMobile = ( + + + } + size='sm' + /> + + + Editar nombre + + + Eliminar colección + + + + + ); + } + return ( <> @@ -199,44 +248,8 @@ export function CollectionDetail() { Volver - - - - - - - } - size='sm' - /> - - - Editar nombre - - - Eliminar colección - - - - + {btnOptionsDesktop} + {btnOptionsMobile} {asideAndCardsUI} diff --git a/src/services/api.ts b/src/services/api.ts index edeb87f..bfed268 100644 --- a/src/services/api.ts +++ b/src/services/api.ts @@ -130,7 +130,9 @@ async function deleteCollections(id: string | undefined, collectionId: string) { } async function getFindOneCollection(collectionsId: string | undefined) { - return await fetchData(`${API_URL}/users/my-collections/${collectionsId}`); + return await fetchData( + `${API_URL}/users/my-collections/collection/${collectionsId}`, + ); } async function postBook(books: any) {