Skip to content

Commit

Permalink
fix: add no posts case
Browse files Browse the repository at this point in the history
  • Loading branch information
ValeryVerkhoturov committed Jun 30, 2023
1 parent 7ed4f8d commit c85d98d
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 20 deletions.
Binary file added public/assets/illustrations/basket.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
55 changes: 35 additions & 20 deletions src/components/posts/my-posts-list/my-posts-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { useState } from 'react'
import { formatDate } from '@/lib/format-date'
import Link from 'next/link'
import { Campus } from '@/lib/campus'
import Image from 'next/image'

interface MyPostsListProps {
reason: PostItemReason
Expand Down Expand Up @@ -41,28 +42,42 @@ export default function MyPostsList(props: MyPostsListProps) {
<ul role='list' className='divide-y divide-gray-100'>
{myPostsListQuery.isLoading &&
Array.from(Array(5).keys()).map((index) => <MyPostSkeleton key={index} />)}
{myPosts.map((myPost, index) => (
<Link href={myPost.id} key={index}>
<li className='flex justify-between gap-x-6 py-5'>
<div className='min-w-0'>
<p className='text-sm font-semibold leading-6 text-gray-900'>{myPost.name}</p>
<p className='mt-1 truncate text-xs leading-5 text-gray-500'>
{myPost.description}
</p>
</div>
<div className='hidden sm:flex sm:flex-row sm:items-center sm:gap-x-4'>
<div className='flex flex-col items-end'>
<p className='text-sm leading-6 text-gray-900'>{Campus[myPost.campus]}</p>
<p className='mt-1 text-xs leading-5 text-gray-500'>
{formatDate(myPost.created.toString())}{' '}
{formatDate(myPost.expires.toString())}
{!myPostsListQuery.isLoading && myPosts.length === 0 && (
<div className='flex h-110 flex-col items-center justify-center text-center font-medium text-gray-700 lg:h-130'>
<Image
src='/assets/illustrations/basket.png'
alt=''
width={200}
height={200}
priority={false}
/>
Постов нет
</div>
)}
{!myPostsListQuery.isLoading &&
myPosts.length > 0 &&
myPosts.map((myPost, index) => (
<Link href={myPost.id} key={index}>
<li className='flex justify-between gap-x-6 py-5'>
<div className='min-w-0'>
<p className='text-sm font-semibold leading-6 text-gray-900'>{myPost.name}</p>
<p className='mt-1 truncate text-xs leading-5 text-gray-500'>
{myPost.description}
</p>
</div>
<ChevronRightIcon className='h-5 w-5 text-gray-500' />
</div>
</li>
</Link>
))}
<div className='hidden sm:flex sm:flex-row sm:items-center sm:gap-x-4'>
<div className='flex flex-col items-end'>
<p className='text-sm leading-6 text-gray-900'>{Campus[myPost.campus]}</p>
<p className='mt-1 text-xs leading-5 text-gray-500'>
{formatDate(myPost.created.toString())}{' '}
{formatDate(myPost.expires.toString())}
</p>
</div>
<ChevronRightIcon className='h-5 w-5 text-gray-500' />
</div>
</li>
</Link>
))}
</ul>
</Window>
)
Expand Down

0 comments on commit c85d98d

Please sign in to comment.