Skip to content

Commit

Permalink
fix(client): lint and user experience
Browse files Browse the repository at this point in the history
  • Loading branch information
lareii committed Sep 10, 2024
1 parent c39b33b commit 2e14f87
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 8 deletions.
2 changes: 1 addition & 1 deletion client/app/(auth)/login/page.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Link from 'next/link';
import { useRouter } from 'next/navigation';
import { useState } from 'react';
import { zodResolver } from '@hookform/resolvers/zod';
import { set, useForm } from 'react-hook-form';
import { useForm } from 'react-hook-form';
import { z } from 'zod';
import { LoaderCircle } from 'lucide-react';
import { Button } from '@/components/ui/button';
Expand Down
2 changes: 1 addition & 1 deletion client/app/app/explore/layout.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import LayoutContent from "@/app/app/explore/layout-content";
import LayoutContent from '@/app/app/explore/layout-content';

export const metadata = {
title: 'keşfet'
Expand Down
19 changes: 14 additions & 5 deletions client/components/app/Post/List.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export default function PostList({ fetchPosts }) {
const [posts, setPosts] = useState([]);
const [offset, setOffset] = useState(10);
const [hasMorePost, setHasMorePost] = useState(true);
const [loading, setLoading] = useState(false);
const { toast } = useToast();

const handleDelete = (postId) => {
Expand Down Expand Up @@ -42,6 +43,7 @@ export default function PostList({ fetchPosts }) {

useEffect(() => {
const fetchInitialPosts = async () => {
setLoading(true);
const response = await fetchPosts(0);

if (!response) {
Expand All @@ -62,14 +64,19 @@ export default function PostList({ fetchPosts }) {
setPosts(initialPosts);
setHasMorePost(false);
}

setLoading(false);
};

fetchInitialPosts();
}, [fetchPosts, toast]);

return (
<div className='flex flex-col gap-2'>
{posts.length > 0 ? (
{loading && (
<LoaderCircle className='mt-1 w-4 h-4 animate-spin self-center' />
)}
{!loading && posts.length > 0 ? (
<>
{posts.map((post) => (
<Post key={post.id} post={post} onDelete={handleDelete} />
Expand All @@ -81,10 +88,12 @@ export default function PostList({ fetchPosts }) {
)}
</>
) : (
<div className='flex flex-col items-center justify-center text-sm'>
buralar şimdilik sessiz.
</div>
!loading && (
<div className='flex flex-col items-center justify-center text-sm'>
buralar şimdilik sessiz.
</div>
)
)}
</div>
);
}
}
10 changes: 9 additions & 1 deletion client/components/app/User/List.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,14 @@ export default function UserList({ fetchUsers }) {

return (
<div className='flex flex-col gap-2'>
{/* {users.map((user, index) => (
<Card key={user.id} index={index} user={user} />
))}
{hasMoreUser && (
<Button onClick={loadMoreUsers} className='w-full'>
daha fazla göster
</Button>
)} */}
{users.length > 0 ? (
<>
{users.map((user, index) => (
Expand All @@ -80,7 +88,7 @@ export default function UserList({ fetchUsers }) {
)}
</>
) : (
<LoaderCircle className='mt-3 w-4 h-4 animate-spin self-center' />
<LoaderCircle className='mt-1 w-4 h-4 animate-spin self-center' />
)}
</div>
);
Expand Down

0 comments on commit 2e14f87

Please sign in to comment.