feat: title cards linked to title pages

This commit is contained in:
nihonium 2025-11-27 10:01:52 +03:00
parent 98178731b9
commit de22dbfb50
Signed by: nihonium
GPG key ID: 0251623741027CFC
4 changed files with 13 additions and 12 deletions

View file

@ -20,7 +20,7 @@ export type OpenAPIConfig = {
}; };
export const OpenAPI: OpenAPIConfig = { export const OpenAPI: OpenAPIConfig = {
BASE: 'http://10.1.0.65:8081/api/v1', BASE: '/api/v1',
VERSION: '1.0.0', VERSION: '1.0.0',
WITH_CREDENTIALS: false, WITH_CREDENTIALS: false,
CREDENTIALS: 'include', CREDENTIALS: 'include',

View file

@ -1 +0,0 @@
@import "tailwindcss";

View file

@ -7,6 +7,7 @@ import { TitleCardSquare } from "../../components/cards/TitleCardSquare";
import { TitleCardHorizontal } from "../../components/cards/TitleCardHorizontal"; import { TitleCardHorizontal } from "../../components/cards/TitleCardHorizontal";
import type { CursorObj, Title, TitleSort } from "../../api"; import type { CursorObj, Title, TitleSort } from "../../api";
import { LayoutSwitch } from "../../components/LayoutSwitch/LayoutSwitch"; import { LayoutSwitch } from "../../components/LayoutSwitch/LayoutSwitch";
import { Link } from "react-router-dom";
const PAGE_SIZE = 10; const PAGE_SIZE = 10;
@ -135,11 +136,11 @@ const handleLoadMore = async () => {
hasMore={!!cursor || nextPage.length > 1} hasMore={!!cursor || nextPage.length > 1}
loadingMore={loadingMore} loadingMore={loadingMore}
onLoadMore={handleLoadMore} onLoadMore={handleLoadMore}
renderItem={(title, layout) => renderItem={(title, layout) => (
layout === "square" <Link to={`/titles/${title.id}`} key={title.id} className="block">
? <TitleCardSquare title={title} /> {layout === "square" ? <TitleCardSquare title={title} /> : <TitleCardHorizontal title={title} />}
: <TitleCardHorizontal title={title} /> </Link>
} )}
/> />
{!cursor && nextPage.length == 0 && ( {!cursor && nextPage.length == 0 && (

View file

@ -9,6 +9,7 @@ import { ListView } from "../../components/ListView/ListView";
import { UserTitleCardSquare } from "../../components/cards/UserTitleCardSquare"; import { UserTitleCardSquare } from "../../components/cards/UserTitleCardSquare";
import { UserTitleCardHorizontal } from "../../components/cards/UserTitleCardHorizontal"; import { UserTitleCardHorizontal } from "../../components/cards/UserTitleCardHorizontal";
import type { User, UserTitle, CursorObj, TitleSort } from "../../api"; import type { User, UserTitle, CursorObj, TitleSort } from "../../api";
import { Link } from "react-router-dom";
const PAGE_SIZE = 10; const PAGE_SIZE = 10;
@ -129,8 +130,6 @@ export default function UserPage({ userId }: UserPageProps) {
setLoadingMore(false); setLoadingMore(false);
}; };
// const getAvatarUrl = (avatarId?: number) => (avatarId ? `/api/images/${avatarId}` : "/default-avatar.png");
return ( return (
<div className="w-full min-h-screen bg-gray-50 p-6 flex flex-col items-center"> <div className="w-full min-h-screen bg-gray-50 p-6 flex flex-col items-center">
@ -166,9 +165,11 @@ export default function UserPage({ userId }: UserPageProps) {
hasMore={!!cursor || nextPage.length > 1} hasMore={!!cursor || nextPage.length > 1}
loadingMore={loadingMore} loadingMore={loadingMore}
onLoadMore={handleLoadMore} onLoadMore={handleLoadMore}
renderItem={(title, layout) => renderItem={(title, layout) => (
layout === "square" ? <UserTitleCardSquare title={title} /> : <UserTitleCardHorizontal title={title} /> <Link to={`/titles/${title.title?.id}`} key={title.title?.id} className="block">
} {layout === "square" ? <UserTitleCardSquare title={title} /> : <UserTitleCardHorizontal title={title} />}
</Link>
)}
/> />
{!cursor && nextPage.length === 0 && ( {!cursor && nextPage.length === 0 && (