-
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.
chore: numerous changes were made and a new section in Book.tsx was a…
…dded
- Loading branch information
Showing
12 changed files
with
178 additions
and
51 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,16 @@ | ||
name: Links (Fail Fast) | ||
|
||
on: | ||
push: | ||
pull_request: | ||
|
||
jobs: | ||
linkChecker: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Link Checker | ||
uses: lycheeverse/[email protected] | ||
with: | ||
fail: true |
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import React from 'react'; | ||
import { Flex, useColorModeValue } from '@chakra-ui/react'; | ||
|
||
export function ContainerRCard({ children }: { children: React.ReactNode }) { | ||
const colorCard = useColorModeValue('gray.900', 'gray.100'); | ||
|
||
return ( | ||
<> | ||
<Flex flexWrap={{ base: 'wrap', xl: 'nowrap' }} color={colorCard}> | ||
{children} | ||
</Flex> | ||
</> | ||
); | ||
} |
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,38 @@ | ||
import React from 'react'; | ||
|
||
import { RelatedCard } from './RelatedCard'; | ||
import { ContainerRCard } from './ContainerRCard'; | ||
import { CardType, ReleatedBooksType } from '../types'; | ||
import { useMoreBooks } from '../../hooks/querys'; | ||
import { useRefetchLocation } from '../../hooks/useRefetchLocation'; | ||
|
||
export default function MoreBooks({ currentBookId }: ReleatedBooksType) { | ||
const { data, refetch } = useMoreBooks(); | ||
const moreBooks = useRefetchLocation(currentBookId, data, refetch); | ||
|
||
// const moreBooks = data.filter((book: any) => { | ||
// if (book.pathUrl === currentBookId) { | ||
// refetch(); | ||
// } | ||
|
||
// return book.pathUrl !== currentBookId; | ||
// }); | ||
|
||
return ( | ||
<> | ||
<ContainerRCard> | ||
{moreBooks.map(({ id, title, authors, pathUrl }: CardType) => ( | ||
<React.Fragment key={id}> | ||
<RelatedCard | ||
id={id} | ||
title={title} | ||
authors={authors} | ||
pathUrl={pathUrl} | ||
refetchQueries={refetch} | ||
/> | ||
</React.Fragment> | ||
))} | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import React from 'react'; | ||
|
||
import { RelatedCard } from './RelatedCard'; | ||
import { ContainerRCard } from './ContainerRCard'; | ||
import { CardType, ReleatedBooksType } from '../types'; | ||
import { useRelatedBooks } from '../../hooks/querys'; | ||
import { useRefetchLocation } from '../../hooks/useRefetchLocation'; | ||
|
||
export default function RelatedBooks({ currentBookId, id }: ReleatedBooksType) { | ||
const { data, refetch } = useRelatedBooks(id); | ||
const relatedBooks = useRefetchLocation(currentBookId, data, refetch); | ||
|
||
return ( | ||
<> | ||
<ContainerRCard> | ||
{relatedBooks.map(({ id, title, authors, pathUrl }: CardType) => ( | ||
<React.Fragment key={id}> | ||
<RelatedCard | ||
id={id} | ||
title={title} | ||
authors={authors} | ||
pathUrl={pathUrl} | ||
refetchQueries={refetch} | ||
/> | ||
</React.Fragment> | ||
))} | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { useState, useEffect } from 'react'; | ||
import { useLocation } from 'react-router-dom'; | ||
|
||
export function useRefetchLocation(currentBookId, data, refetch) { | ||
const location = useLocation(); | ||
const [previousPathname, setPreviousPathname] = useState(location.pathname); | ||
const [relatedBooks, setRelatedBooks] = useState([]); | ||
|
||
useEffect(() => { | ||
const filteredBooks = data.filter((book) => { | ||
return book.pathUrl !== currentBookId; | ||
}); | ||
|
||
setRelatedBooks(filteredBooks); | ||
|
||
if (location.pathname !== previousPathname) { | ||
refetch(); | ||
setPreviousPathname(location.pathname); | ||
} | ||
}, [data, currentBookId, location.pathname, refetch, previousPathname]); | ||
|
||
return relatedBooks; | ||
} |
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
80be1f0
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-git-main-franqsanz.vercel.app
xbu-franqsanz.vercel.app
xbu.vercel.app