Skip to content

Commit

Permalink
feat(client): improve post component
Browse files Browse the repository at this point in the history
  • Loading branch information
lareii committed Sep 14, 2024
1 parent dac4064 commit 047fa0a
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 21 deletions.
44 changes: 23 additions & 21 deletions client/components/app/Post/Dropdown.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,27 +80,29 @@ export default function Dropdown({ post, setPost, onDelete }) {
</Link>
</DropdownMenuItem>
{(user.id === post.author.id || user.role === 'admin') && (
<>
<DropdownMenuSeparator />
<DropdownMenuItem>
<DialogTrigger className='flex items-center cursor-default'>
<Pencil className='w-4 h-4 mr-2' />
çöpü düzenle
</DialogTrigger>
</DropdownMenuItem>
<DropdownMenuItem
onClick={handleDelete}
disabled={isDeleting}
className='flex items-center text-red-500'
>
{isDeleting ? (
<LoaderCircle className='w-4 h-4 mr-2 animate-spin' />
) : (
<X className='w-4 h-4 mr-2' />
)}
çöpü kaldır
</DropdownMenuItem>
</>
<DropdownMenuSeparator />
)}
{user.id === post.author.id && (
<DropdownMenuItem>
<DialogTrigger className='flex items-center cursor-default'>
<Pencil className='w-4 h-4 mr-2' />
çöpü düzenle
</DialogTrigger>
</DropdownMenuItem>
)}
{(user.id === post.author.id || user.role === 'admin') && (
<DropdownMenuItem
onClick={handleDelete}
disabled={isDeleting}
className='flex items-center text-red-500'
>
{isDeleting ? (
<LoaderCircle className='w-4 h-4 mr-2 animate-spin' />
) : (
<X className='w-4 h-4 mr-2' />
)}
çöpü kaldır
</DropdownMenuItem>
)}
</DropdownMenuContent>
</DropdownMenu>
Expand Down
4 changes: 4 additions & 0 deletions client/components/app/Post/UpdateModal.jsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { useRouter } from 'next/navigation';
import { useState } from 'react';
import { z } from 'zod';
import { zodResolver } from '@hookform/resolvers/zod';
Expand Down Expand Up @@ -30,6 +31,7 @@ const formSchema = z.object({
});

export default function UpdateModal({ post, setPost, setIsOpen }) {
const router = useRouter();
const [isSubmitting, setIsSubmitting] = useState(false);

const { toast } = useToast();
Expand Down Expand Up @@ -67,6 +69,8 @@ export default function UpdateModal({ post, setPost, setIsOpen }) {
description: 'çöp başarıyla düzenlendi.',
duration: 3000
});
router.push(`/app/posts/${post.id}`);
router.refresh();
}

return (
Expand Down
2 changes: 2 additions & 0 deletions client/components/app/Post/index.jsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use client';

import { usePathname } from 'next/navigation';
import { useState } from 'react';
import Markdown from 'react-markdown';
Expand Down

0 comments on commit 047fa0a

Please sign in to comment.