0.1.5
This commit is contained in:
@@ -66,7 +66,7 @@ export default function Chapters({ auth, comic, chapters, histories, offset }) {
|
||||
}
|
||||
|
||||
const ComicChapterLink = (props) => {
|
||||
const isNew = Date.now() - Date.parse(props.datetime_created) < 6.048e+8;
|
||||
const isNew = Date.now() - Date.parse(props.datetime_created) < 6.048e+8; // 1 week
|
||||
const isRead = histories.includes(props.uuid);
|
||||
|
||||
return (
|
||||
@@ -226,7 +226,7 @@ export default function Chapters({ auth, comic, chapters, histories, offset }) {
|
||||
<TabsContent value={ group }>
|
||||
<div
|
||||
className="w-full grid grid-cols-1 md:grid-cols-2 lg:grid-cols-6 2xl:grid-cols-12 gap-1">
|
||||
{ (chapters.total > (chapters.limit + chapters.offset) && chapters.offset > 0) && (
|
||||
{ (chapters.total > chapters.limit && chapters.offset > 0) && (
|
||||
<Button size="sm" variant="outline" asChild>
|
||||
<Link href="?" only={['chapters', 'offset']} headers={{ offset: parseInt(chapters.offset) - chapters.limit }}>
|
||||
<ChevronsLeft /> Prev
|
||||
@@ -236,7 +236,7 @@ export default function Chapters({ auth, comic, chapters, histories, offset }) {
|
||||
{ chapters.list.sort((a, b) => ascending ? (a.index - b.index) : (b.index - a.index)).map(c => (
|
||||
<ComicChapterLink key={ c.uuid } { ...c } />
|
||||
) ) }
|
||||
{ (chapters.total > chapters.limit && chapters.total > chapters.offset) && (
|
||||
{ (chapters.total > (chapters.limit + chapters.offset)) && (
|
||||
<Button size="sm" variant="outline" asChild>
|
||||
<Link href="?" only={['chapters', 'offset']} headers={{ offset: parseInt(chapters.offset) + chapters.limit }}>
|
||||
Next <ChevronsRight />
|
||||
|
||||
@@ -86,7 +86,7 @@ export default function Histories({ auth, histories }) {
|
||||
</Link>
|
||||
</Button>
|
||||
</div>
|
||||
<Table>
|
||||
<Table className="mt-2">
|
||||
<TableHeader>
|
||||
<TableRow>
|
||||
<TableHead>Select</TableHead>
|
||||
@@ -120,22 +120,16 @@ export default function Histories({ auth, histories }) {
|
||||
)) }
|
||||
</TableBody>
|
||||
</Table>
|
||||
<div>
|
||||
<div className="pt-2">
|
||||
<Pagination className="justify-end">
|
||||
<PaginationContent>
|
||||
{ histories.current_page > 1 && (
|
||||
<PaginationItem>
|
||||
<PaginationPrevious href={ histories.prev_page_url } only={['histories']} />
|
||||
{ histories.links.map((h, i) => (
|
||||
<PaginationItem key={ i }>
|
||||
{ h.label.includes('Previous') && <PaginationPrevious href={ h.url } only={['histories']} isActive={ h.active } /> }
|
||||
{ !h.label.includes('Previous') && !h.label.includes('Next') && <PaginationLink href={ h.url } only={['histories']} isActive={ h.active }>{ h.label }</PaginationLink> }
|
||||
{ h.label.includes('Next') && <PaginationNext href={ h.url } only={['histories']} isActive={ h.active } /> }
|
||||
</PaginationItem>
|
||||
) }
|
||||
<PaginationItem>
|
||||
<PaginationLink href="#">{ histories.current_page }</PaginationLink>
|
||||
</PaginationItem>
|
||||
{ histories.current_page < histories.last_page && (
|
||||
<PaginationItem>
|
||||
<PaginationNext href={ histories.next_page_url } only={['histories']} />
|
||||
</PaginationItem>
|
||||
) }
|
||||
) ) }
|
||||
</PaginationContent>
|
||||
</Pagination>
|
||||
</div>
|
||||
|
||||
@@ -67,23 +67,23 @@ export default function Histories({ auth, histories }) {
|
||||
</TableRow>
|
||||
</TableHeader>
|
||||
<TableBody>
|
||||
{ histories.map((comic, i) =>
|
||||
comic.histories.map((record, j) => (
|
||||
<TableRow key={ j }>
|
||||
{ (j === 0) ? <TableCell className="w-[40%]" rowspan={ comic.histories.length }>
|
||||
<Link href={ route('comics.chapters', comic.comic.comic_pathword) }>
|
||||
{ comic.comic.comic_name }
|
||||
</Link>
|
||||
</TableCell> : null }
|
||||
<TableCell>
|
||||
<Link href={ route('comics.read', [comic.comic.comic_pathword, record.chapter_uuid]) }>
|
||||
{ record.chapter_name }
|
||||
</Link>
|
||||
</TableCell>
|
||||
<TableCell>{ record.read_at }</TableCell>
|
||||
</TableRow>
|
||||
) )
|
||||
) }
|
||||
{ histories.map((comic, i) => comic.histories.map((record, j) => (
|
||||
<TableRow key={ j }>
|
||||
{ (j === 0) && <TableCell className="w-[40%]" rowSpan={ comic.histories.length }>
|
||||
<Link href={ route('comics.chapters', comic.comic.comic_pathword) }>
|
||||
{ comic.comic.comic_name }
|
||||
</Link>
|
||||
</TableCell> }
|
||||
<TableCell>
|
||||
<Link href={ route('comics.read', [comic.comic.comic_pathword, record.chapter_uuid]) }>
|
||||
{ record.chapter_name }
|
||||
</Link>
|
||||
</TableCell>
|
||||
<TableCell>
|
||||
{ record.read_at }
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
) ) ) }
|
||||
</TableBody>
|
||||
</Table>
|
||||
</div>
|
||||
|
||||
@@ -14,9 +14,11 @@ export default function Index({ comics, offset, auth }) {
|
||||
|
||||
const url = new URL(window.location); // searchParams
|
||||
|
||||
const [favourites, setFavourites] = useState(auth.user?.favourites ?? []);
|
||||
const [favourites, setFavourites] = useState((auth?.user?.favourites !== null) ? auth.user.favourites : []);
|
||||
const { toast } = useToast();
|
||||
|
||||
const itemsPerPage = 30;
|
||||
|
||||
/**
|
||||
* On click handler for the star
|
||||
* Do posting and make a toast
|
||||
@@ -84,19 +86,21 @@ export default function Index({ comics, offset, auth }) {
|
||||
</Head>
|
||||
<div className="p-3 pt-1 pb-1 flex flex-wrap justify-center" scroll-region="true"
|
||||
style={{ overflowAnchor: "none", height: "calc(100dvh - 90px)", overflowY: "scroll" }}>
|
||||
<div className="grid 2xl:grid-cols-6 xl:grid-cols-4 sm:grid-cols-2 gap-2">
|
||||
<div className="grid 2xl:grid-cols-6 xl:grid-cols-4 grid-cols-2 gap-2">
|
||||
<ComicCards { ...comics } />
|
||||
</div>
|
||||
<Pagination className="justify-end pt-2">
|
||||
<PaginationContent>
|
||||
{ parseInt(offset) !== 0 &&
|
||||
<PaginationItem>
|
||||
<PaginationPrevious href={ `${ url.pathname }?${ url.searchParams }` } only={['comics', 'offset']} headers={{ offset: parseInt(offset) - 30 }} />
|
||||
<PaginationPrevious href={ `${ url.pathname }?${ url.searchParams }` } only={['comics', 'offset']} headers={{ offset: parseInt(offset) - itemsPerPage }} />
|
||||
</PaginationItem>
|
||||
}
|
||||
{ parseInt(comics.total) > parseInt(offset) + itemsPerPage &&
|
||||
<PaginationItem>
|
||||
<PaginationNext href={ `${ url.pathname }?${ url.searchParams }` } only={['comics', 'offset']} headers={{ offset: parseInt(offset) + itemsPerPage }} />
|
||||
</PaginationItem>
|
||||
}
|
||||
<PaginationItem>
|
||||
<PaginationNext href={ `${ url.pathname }?${ url.searchParams }` } only={['comics', 'offset']} headers={{ offset: parseInt(offset) + 30 }} />
|
||||
</PaginationItem>
|
||||
</PaginationContent>
|
||||
</Pagination>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user