.
This commit is contained in:
@@ -5,6 +5,7 @@ import { useRouter } from 'next/navigation';
|
||||
import { createBlogPost, updateBlogPost } from '@/app/actions/blog';
|
||||
import { Loader2, ArrowLeft, Save } from 'lucide-react';
|
||||
import Link from 'next/link';
|
||||
import { toast } from 'react-hot-toast';
|
||||
|
||||
interface Props {
|
||||
initialData?: {
|
||||
@@ -38,10 +39,11 @@ export default function BlogForm({ initialData }: Props) {
|
||||
: await createBlogPost(data);
|
||||
|
||||
if (result.success) {
|
||||
toast.success(initialData ? "Article mis à jour" : "Article publié avec succès");
|
||||
router.push('/blog');
|
||||
router.refresh();
|
||||
} else {
|
||||
alert(result.error);
|
||||
toast.error(result.error || "Une erreur est survenue");
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user