-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add followings feature component for manga and novel
- Loading branch information
Showing
12 changed files
with
232 additions
and
112 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
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
40 changes: 0 additions & 40 deletions
40
src/features/anime/anime-view/followings/followings-modal.tsx
This file was deleted.
Oops, something went wrong.
56 changes: 0 additions & 56 deletions
56
src/features/anime/anime-view/followings/followings.component.tsx
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import Link from 'next/link'; | ||
import { FC } from 'react'; | ||
import MaterialSymbolsStarRounded from '~icons/material-symbols/star-rounded'; | ||
|
||
import P from '@/components/typography/p'; | ||
import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar'; | ||
import { Label } from '@/components/ui/label'; | ||
|
||
import { READ_STATUS } from '@/utils/constants'; | ||
import { cn } from '@/utils/utils'; | ||
|
||
interface Props { | ||
data: { | ||
read: API.Read[]; | ||
} & API.User; | ||
className?: string; | ||
} | ||
|
||
const FollowingReadItem: FC<Props> = ({ data, className }) => { | ||
return ( | ||
<div className={cn('flex items-center gap-4', className)}> | ||
<Avatar className="size-10 rounded-md" asChild> | ||
<Link href={`/u/${data.username}`}> | ||
<AvatarImage | ||
className="size-10 rounded-md" | ||
src={data.avatar} | ||
/> | ||
<AvatarFallback className="size-10 rounded-md" /> | ||
</Link> | ||
</Avatar> | ||
<div className="flex flex-1 flex-col gap-1"> | ||
<Label asChild> | ||
<Link href={`/u/${data.username}`}>{data.username}</Link> | ||
</Label> | ||
|
||
<P className="text-xs text-muted-foreground"> | ||
{READ_STATUS[data.read[0].status].title_ua} | ||
</P> | ||
</div> | ||
{data.read[0].score > 0 && ( | ||
<div className="inline-flex gap-1"> | ||
<Label className="leading-normal"> | ||
{data.read[0].score} | ||
</Label> | ||
<MaterialSymbolsStarRounded /> | ||
</div> | ||
)} | ||
</div> | ||
); | ||
}; | ||
|
||
export default FollowingReadItem; |
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,70 @@ | ||
'use client'; | ||
|
||
import { useParams } from 'next/navigation'; | ||
import { FC } from 'react'; | ||
|
||
import LoadMoreButton from '@/components/load-more-button'; | ||
|
||
import useFollowingReadList from '@/services/hooks/read/use-following-read-list'; | ||
import useFollowingWatchList from '@/services/hooks/watch/use-following-watch-list'; | ||
|
||
import FollowingReadItem from './following-read-item'; | ||
import FollowingWatchItem from './following-watch-item'; | ||
|
||
interface Props { | ||
content_type: API.ContentType; | ||
} | ||
|
||
const FollowingsModal: FC<Props> = ({ content_type }) => { | ||
const params = useParams(); | ||
|
||
const watchListQuery = useFollowingWatchList( | ||
{ | ||
slug: String(params.slug), | ||
}, | ||
{ enabled: content_type === 'anime' }, | ||
); | ||
|
||
const readListQuery = useFollowingReadList( | ||
{ | ||
slug: String(params.slug), | ||
content_type: content_type as 'manga' | 'novel', | ||
}, | ||
{ enabled: content_type !== 'anime' }, | ||
); | ||
|
||
const { list, hasNextPage, isFetchingNextPage, fetchNextPage, ref } = | ||
content_type === 'anime' ? watchListQuery : readListQuery; | ||
|
||
return ( | ||
<div className="h-full w-auto flex-1 overflow-y-scroll"> | ||
{list && | ||
list.map((item) => | ||
'watch' in item ? ( | ||
<FollowingWatchItem | ||
className="px-6 py-4" | ||
data={item} | ||
key={item.reference} | ||
/> | ||
) : ( | ||
<FollowingReadItem | ||
className="px-6 py-4" | ||
data={item} | ||
key={item.reference} | ||
/> | ||
), | ||
)} | ||
{hasNextPage && ( | ||
<div className="px-6"> | ||
<LoadMoreButton | ||
isFetchingNextPage={isFetchingNextPage} | ||
fetchNextPage={fetchNextPage} | ||
ref={ref} | ||
/> | ||
</div> | ||
)} | ||
</div> | ||
); | ||
}; | ||
|
||
export default FollowingsModal; |
Oops, something went wrong.