This commit is contained in:
User
2025-01-18 19:05:23 -05:00
parent 3f282d6ecd
commit 14938f63df
23 changed files with 652 additions and 177 deletions

View File

@@ -12,11 +12,17 @@ import { useToast } from '@/hooks/use-toast.js';
export default function Index({ comics, offset, auth }) {
const url = new URL(window.location); //searchParams
const url = new URL(window.location); // searchParams
const [favourites, setFavourites] = useState(auth.user?.favourites ?? []);
const { toast } = useToast();
/**
* On click handler for the star
* Do posting and make a toast
*
* @param pathword
*/
const favouriteOnClickHandler = (pathword) => {
axios.post(route('comics.postFavourite'), { pathword: pathword }).then(res => {
setFavourites(res.data);
@@ -28,6 +34,12 @@ export default function Index({ comics, offset, auth }) {
});
}
/**
* Generate info card for comics
* @param props
* @returns {JSX.Element}
* @constructor
*/
const ComicCard = (props) => (
<Card>
<CardHeader>
@@ -41,7 +53,9 @@ export default function Index({ comics, offset, auth }) {
</div>
</CardHeader>
<CardContent>
<CardTitle><Link href={ `/comic/${ props.path_word }` }>{ props.name }</Link></CardTitle>
<CardTitle>
<Link href={ `/comic/${ props.path_word }` }>{ props.name }</Link>
</CardTitle>
<CardDescription className="pt-2">
{ props.author && props.author.map(a => (
<Badge className="m-1" key={ a.path_word } variant="outline">
@@ -53,6 +67,12 @@ export default function Index({ comics, offset, auth }) {
</Card>
);
/**
* Loop and return all info cards
* @param comics
* @returns {*}
* @constructor
*/
const ComicCards = (comics) => {
return comics.list.map((comic, i) => <ComicCard key={ i } { ...comic } />);
}