feat: add home featured toggle, improve account deletion UI, and update business schema and database configuration.
This commit is contained in:
@@ -24,21 +24,24 @@ export async function setFeaturedBusiness(id: string, data: {
|
||||
keyMetric: string;
|
||||
}) {
|
||||
try {
|
||||
// 1. Reset all others (we only want one entrepreneur of the month)
|
||||
// 1. Réinitialiser les autres pour n'avoir qu'une seule Tête d'affiche Afroshine active
|
||||
await prisma.business.updateMany({
|
||||
where: { isFeatured: true },
|
||||
data: { isFeatured: false },
|
||||
});
|
||||
|
||||
// 2. Set the new one
|
||||
// 2. Mettre à jour l'entreprise choisie
|
||||
await prisma.business.update({
|
||||
where: { id },
|
||||
data: {
|
||||
isFeatured: true,
|
||||
...data,
|
||||
founderName: data.founderName || null,
|
||||
founderImageUrl: data.founderImageUrl || null,
|
||||
keyMetric: data.keyMetric || null,
|
||||
},
|
||||
});
|
||||
|
||||
revalidatePath("/users");
|
||||
revalidatePath("/entrepreneurs");
|
||||
revalidatePath("/dashboard");
|
||||
return { success: true };
|
||||
@@ -48,12 +51,28 @@ export async function setFeaturedBusiness(id: string, data: {
|
||||
}
|
||||
}
|
||||
|
||||
export async function toggleHomeFeatured(id: string, currentStatus: boolean) {
|
||||
try {
|
||||
await prisma.business.update({
|
||||
where: { id },
|
||||
data: { isHomeFeatured: !currentStatus },
|
||||
});
|
||||
revalidatePath("/users");
|
||||
revalidatePath("/");
|
||||
return { success: true };
|
||||
} catch (error) {
|
||||
console.error("Failed to toggle home featured:", error);
|
||||
return { success: false, error: "Erreur lors de la mise à jour de la mise à la une" };
|
||||
}
|
||||
}
|
||||
|
||||
export async function removeFeaturedBusiness(id: string) {
|
||||
try {
|
||||
await prisma.business.update({
|
||||
where: { id },
|
||||
data: { isFeatured: false },
|
||||
});
|
||||
revalidatePath("/users");
|
||||
revalidatePath("/entrepreneurs");
|
||||
return { success: true };
|
||||
} catch (error) {
|
||||
|
||||
Reference in New Issue
Block a user