.
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");
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
import { useTransition } from 'react';
|
||||
import { deleteBlogPost } from '@/app/actions/blog';
|
||||
import { Trash2, Loader2 } from 'lucide-react';
|
||||
import { toast } from 'react-hot-toast';
|
||||
|
||||
export default function DeleteBlogButton({ id }: { id: string }) {
|
||||
const [isPending, startTransition] = useTransition();
|
||||
@@ -11,7 +12,11 @@ export default function DeleteBlogButton({ id }: { id: string }) {
|
||||
if (confirm("Supprimer cet article ?")) {
|
||||
startTransition(async () => {
|
||||
const result = await deleteBlogPost(id);
|
||||
if (!result.success) alert(result.error);
|
||||
if (result.success) {
|
||||
toast.success("Article supprimé");
|
||||
} else {
|
||||
toast.error(result.error || "Erreur lors de la suppression");
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
import { useTransition } from 'react';
|
||||
import { deleteComment } from '@/app/actions/comment';
|
||||
import { Trash2, Loader2 } from 'lucide-react';
|
||||
import { toast } from 'react-hot-toast';
|
||||
|
||||
interface Props {
|
||||
id: string;
|
||||
@@ -15,8 +16,10 @@ export default function DeleteCommentButton({ id }: Props) {
|
||||
if (confirm("Êtes-vous sûr de vouloir supprimer ce commentaire ?")) {
|
||||
startTransition(async () => {
|
||||
const result = await deleteComment(id);
|
||||
if (!result.success) {
|
||||
alert(result.error);
|
||||
if (result.success) {
|
||||
toast.success("Commentaire supprimé");
|
||||
} else {
|
||||
toast.error(result.error || "Erreur lors de la suppression");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
import { useTransition } from 'react';
|
||||
import { deleteInterview } from '@/app/actions/interview';
|
||||
import { Trash2, Loader2 } from 'lucide-react';
|
||||
import { toast } from 'react-hot-toast';
|
||||
|
||||
export default function DeleteInterviewButton({ id }: { id: string }) {
|
||||
const [isPending, startTransition] = useTransition();
|
||||
@@ -11,7 +12,11 @@ export default function DeleteInterviewButton({ id }: { id: string }) {
|
||||
if (confirm("Supprimer cette interview ?")) {
|
||||
startTransition(async () => {
|
||||
const result = await deleteInterview(id);
|
||||
if (!result.success) alert(result.error);
|
||||
if (result.success) {
|
||||
toast.success("Interview supprimée");
|
||||
} else {
|
||||
toast.error(result.error || "Erreur lors de la suppression");
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
import { useState, useTransition } from 'react';
|
||||
import { setFeaturedBusiness, removeFeaturedBusiness } from '@/app/actions/business';
|
||||
import { Star, X, Loader2, Save } from 'lucide-react';
|
||||
import { toast } from 'react-hot-toast';
|
||||
|
||||
interface Props {
|
||||
business: {
|
||||
@@ -31,9 +32,10 @@ export default function FeaturedModal({ business }: Props) {
|
||||
startTransition(async () => {
|
||||
const result = await setFeaturedBusiness(business.id, data);
|
||||
if (result.success) {
|
||||
toast.success("Entrepreneur du mois mis à jour !");
|
||||
setIsOpen(false);
|
||||
} else {
|
||||
alert(result.error);
|
||||
toast.error(result.error || "Une erreur est survenue");
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -42,7 +44,12 @@ export default function FeaturedModal({ business }: Props) {
|
||||
if (confirm("Retirer cet entrepreneur du titre 'Entrepreneur du mois' ?")) {
|
||||
startTransition(async () => {
|
||||
const result = await removeFeaturedBusiness(business.id);
|
||||
if (result.success) setIsOpen(false);
|
||||
if (result.success) {
|
||||
toast.success("Titre révoqué");
|
||||
setIsOpen(false);
|
||||
} else {
|
||||
toast.error(result.error);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
@@ -6,6 +6,7 @@ import { createInterview, updateInterview } from '@/app/actions/interview';
|
||||
import { Loader2, ArrowLeft, Save, Video, FileText } from 'lucide-react';
|
||||
import Link from 'next/link';
|
||||
import { InterviewType } from '@prisma/client';
|
||||
import { toast } from 'react-hot-toast';
|
||||
|
||||
interface Props {
|
||||
initialData?: any;
|
||||
@@ -37,10 +38,11 @@ export default function InterviewForm({ initialData }: Props) {
|
||||
: await createInterview(data);
|
||||
|
||||
if (result.success) {
|
||||
toast.success(initialData ? "Interview mise à jour" : "Interview créée avec succès");
|
||||
router.push('/blog');
|
||||
router.refresh();
|
||||
} else {
|
||||
alert(result.error);
|
||||
toast.error(result.error || "Une erreur est survenue");
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
import { useTransition } from 'react';
|
||||
import { toggleVerification } from '@/app/actions/business';
|
||||
import { CheckCircle, XCircle, Loader2 } from 'lucide-react';
|
||||
import { toast } from 'react-hot-toast';
|
||||
|
||||
interface Props {
|
||||
id: string;
|
||||
@@ -15,8 +16,10 @@ export default function ToggleVerifyButton({ id, verified }: Props) {
|
||||
const handleToggle = () => {
|
||||
startTransition(async () => {
|
||||
const result = await toggleVerification(id, verified);
|
||||
if (!result.success) {
|
||||
alert(result.error);
|
||||
if (result.success) {
|
||||
toast.success(verified ? "Vérification révoquée" : "Entreprise validée");
|
||||
} else {
|
||||
toast.error(result.error || "Une erreur est survenue");
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user