mirror of
https://github.com/Radiquum/AniX.git
synced 2025-09-04 05:25:36 +05:00
anix/fix: search in bookmarks, user collections, user favorites, user history
This commit is contained in:
parent
8d2800c2f2
commit
93205fdb4e
6 changed files with 55 additions and 19 deletions
12
app/discover/page.tsx
Normal file
12
app/discover/page.tsx
Normal file
|
@ -0,0 +1,12 @@
|
|||
import { DiscoverPage } from "#/pages/Discover";
|
||||
|
||||
export const metadata = {
|
||||
title: "Обзор",
|
||||
description: "Рекомендации и популярное",
|
||||
};
|
||||
|
||||
export const dynamic = "force-static";
|
||||
|
||||
export default function Discover() {
|
||||
return <DiscoverPage />;
|
||||
}
|
|
@ -82,7 +82,7 @@ export function BookmarksCategoryPage(props: any) {
|
|||
<Spinner />
|
||||
</div>
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
if (error) {
|
||||
return (
|
||||
|
@ -105,7 +105,9 @@ export function BookmarksCategoryPage(props: any) {
|
|||
className="flex-1 max-w-full mx-4"
|
||||
onSubmit={(e) => {
|
||||
e.preventDefault();
|
||||
router.push(`/search?q=${searchVal}&where=list&list=${props.slug}`);
|
||||
router.push(
|
||||
`/search?query=${searchVal}¶ms={"where"%3A"list"%2C"searchBy"%3A"${props.slug}"}`
|
||||
);
|
||||
}}
|
||||
>
|
||||
<label
|
||||
|
|
|
@ -54,7 +54,9 @@ export function CollectionsPage() {
|
|||
className="flex-1 max-w-full mx-4 mb-4"
|
||||
onSubmit={(e) => {
|
||||
e.preventDefault();
|
||||
router.push(`/search?q=${searchVal}&where=collections`);
|
||||
router.push(
|
||||
`/search?query=${searchVal}¶ms={"where"%3A"collections_fav"%2C"searchBy"%3A"none"}`
|
||||
);
|
||||
}}
|
||||
>
|
||||
<label
|
||||
|
|
19
app/pages/Discover.tsx
Normal file
19
app/pages/Discover.tsx
Normal file
|
@ -0,0 +1,19 @@
|
|||
"use client";
|
||||
import { useState, useEffect } from "react";
|
||||
import { useUserStore } from "../store/auth";
|
||||
import { useRouter } from "next/navigation";
|
||||
|
||||
export const DiscoverPage = () => {
|
||||
const token = useUserStore((state) => state.token);
|
||||
const authState = useUserStore((state) => state.state);
|
||||
const router = useRouter();
|
||||
|
||||
useEffect(() => {
|
||||
if (authState === "finished" && !token) {
|
||||
router.push("/login?redirect=/discover");
|
||||
}
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [authState, token]);
|
||||
|
||||
return <></>;
|
||||
};
|
|
@ -69,7 +69,9 @@ export function FavoritesPage() {
|
|||
className="flex-1 max-w-full mx-4 mb-4"
|
||||
onSubmit={(e) => {
|
||||
e.preventDefault();
|
||||
router.push(`/search?q=${searchVal}&where=favorites`);
|
||||
router.push(
|
||||
`/search?query=${searchVal}¶ms={"where"%3A"favorites"%2C"searchBy"%3A"none"}`
|
||||
);
|
||||
}}
|
||||
>
|
||||
<label
|
||||
|
@ -129,9 +131,9 @@ export function FavoritesPage() {
|
|||
<DropdownItem key={index} onClick={() => setSelectedSort(index)}>
|
||||
<span
|
||||
className={`w-6 h-6 iconify ${
|
||||
sort.values[index].value.split("_")[1] == "descending"
|
||||
? sort.descendingIcon
|
||||
: sort.ascendingIcon
|
||||
sort.values[index].value.split("_")[1] == "descending" ?
|
||||
sort.descendingIcon
|
||||
: sort.ascendingIcon
|
||||
}`}
|
||||
></span>
|
||||
{item.name}
|
||||
|
@ -139,18 +141,17 @@ export function FavoritesPage() {
|
|||
))}
|
||||
</Dropdown>
|
||||
</div>
|
||||
{content && content.length > 0 ? (
|
||||
{content && content.length > 0 ?
|
||||
<ReleaseSection content={content} />
|
||||
) : isLoading ? (
|
||||
: isLoading ?
|
||||
<div className="flex flex-col items-center justify-center min-w-full min-h-screen">
|
||||
<Spinner />
|
||||
</div>
|
||||
) : (
|
||||
<div className="flex flex-col items-center justify-center min-w-full gap-4 mt-12 text-xl">
|
||||
: <div className="flex flex-col items-center justify-center min-w-full gap-4 mt-12 text-xl">
|
||||
<span className="w-24 h-24 iconify-color twemoji--broken-heart"></span>
|
||||
<p>В избранном пока ничего нет...</p>
|
||||
</div>
|
||||
)}
|
||||
}
|
||||
{data &&
|
||||
data[data.length - 1].current_page <
|
||||
data[data.length - 1].total_page_count && (
|
||||
|
|
|
@ -10,7 +10,6 @@ import { Button } from "flowbite-react";
|
|||
import { useRouter } from "next/navigation";
|
||||
import { useSWRfetcher } from "#/api/utils";
|
||||
|
||||
|
||||
export function HistoryPage() {
|
||||
const token = useUserStore((state) => state.token);
|
||||
const authState = useUserStore((state) => state.state);
|
||||
|
@ -62,7 +61,9 @@ export function HistoryPage() {
|
|||
className="flex-1 max-w-full mx-4 mb-4"
|
||||
onSubmit={(e) => {
|
||||
e.preventDefault();
|
||||
router.push(`/search?q=${searchVal}&where=history`);
|
||||
router.push(
|
||||
`/search?query=${searchVal}¶ms={"where"%3A"history"%2C"searchBy"%3A"none"}`
|
||||
);
|
||||
}}
|
||||
>
|
||||
<label
|
||||
|
@ -106,7 +107,7 @@ export function HistoryPage() {
|
|||
</button>
|
||||
</div>
|
||||
</form>
|
||||
{content && content.length > 0 ? (
|
||||
{content && content.length > 0 ?
|
||||
<>
|
||||
<ReleaseSection sectionTitle="История" content={content} />
|
||||
{data && data[0].total_count != content.length && (
|
||||
|
@ -122,16 +123,15 @@ export function HistoryPage() {
|
|||
</Button>
|
||||
)}
|
||||
</>
|
||||
) : isLoading ? (
|
||||
: isLoading ?
|
||||
<div className="flex flex-col items-center justify-center min-w-full min-h-[100dvh]">
|
||||
<Spinner />
|
||||
</div>
|
||||
) : (
|
||||
<div className="flex flex-col items-center justify-center min-w-full gap-4 mt-12 text-xl">
|
||||
: <div className="flex flex-col items-center justify-center min-w-full gap-4 mt-12 text-xl">
|
||||
<span className="w-24 h-24 iconify-color twemoji--broken-heart"></span>
|
||||
<p>В истории пока ничего нет...</p>
|
||||
</div>
|
||||
)}
|
||||
}
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue