-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: added to see books by the same author in related form
- Loading branch information
Showing
5 changed files
with
98 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import React from 'react'; | ||
import { Box, Text } from '@chakra-ui/react'; | ||
|
||
import { RelatedCard } from './RelatedCard'; | ||
import { ContainerRCard } from './ContainerRCard'; | ||
import { CardType, RelatedBooksType } from '../types'; | ||
import { useMoreBooksAuthors } from '../../hooks/querys'; | ||
import { useRefetchLocation } from '../../hooks/useRefetchLocation'; | ||
|
||
export default function MoreBooksAuthors({ | ||
currentBookId, | ||
id, | ||
}: RelatedBooksType) { | ||
const { data, refetch } = useMoreBooksAuthors(id); | ||
const moreBooksAuthors = useRefetchLocation({ currentBookId, data, refetch }); | ||
let uiCard; | ||
|
||
if (moreBooksAuthors.length > 0) { | ||
uiCard = moreBooksAuthors.map( | ||
({ id, title, authors, pathUrl }: CardType) => ( | ||
<React.Fragment key={id}> | ||
<RelatedCard | ||
title={title} | ||
authors={authors} | ||
pathUrl={pathUrl} | ||
refetchQueries={refetch} | ||
/> | ||
</React.Fragment> | ||
), | ||
); | ||
} else { | ||
uiCard = ( | ||
<Text ml='4' fontStyle='italic' textAlign='center'> | ||
<Box as='span' fontStyle='normal'> | ||
🔍 📚 | ||
</Box>{' '} | ||
No se encontraron más libros del mismo autor. | ||
</Text> | ||
); | ||
} | ||
|
||
return ( | ||
<> | ||
<ContainerRCard>{uiCard}</ContainerRCard> | ||
</> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cd090c5
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
xbu – ./
xbu-franqsanz.vercel.app
xbu-git-main-franqsanz.vercel.app
xbu.vercel.app