feat: improve profile UI/UX and migrate to Mantine modals
This commit is contained in:
@@ -1,49 +1,53 @@
|
||||
import { prisma } from "@/utils/db";
|
||||
|
||||
async function seedAdminUser() {
|
||||
// Load environment variables
|
||||
const adminEmail = process.env.ADMIN_EMAIL;
|
||||
// Load environment variables
|
||||
const adminEmail = process.env.ADMIN_EMAIL;
|
||||
|
||||
if (!adminEmail) {
|
||||
console.log("No ADMIN_EMAIL environment variable found. Skipping admin role assignment.");
|
||||
return;
|
||||
}
|
||||
if (!adminEmail) {
|
||||
console.log(
|
||||
"No ADMIN_EMAIL environment variable found. Skipping admin role assignment.",
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
// Check if admin user already exists
|
||||
const existingUser = await prisma.user.findUnique({
|
||||
where: { email: adminEmail },
|
||||
});
|
||||
try {
|
||||
// Check if admin user already exists
|
||||
const existingUser = await prisma.user.findUnique({
|
||||
where: { email: adminEmail },
|
||||
});
|
||||
|
||||
if (existingUser) {
|
||||
// Update existing user to have admin role if they don't already
|
||||
if (existingUser.role !== "admin") {
|
||||
await prisma.user.update({
|
||||
where: { email: adminEmail },
|
||||
data: { role: "admin" },
|
||||
});
|
||||
console.log(`User with email ${adminEmail} updated to admin role.`);
|
||||
} else {
|
||||
console.log(`User with email ${adminEmail} already has admin role.`);
|
||||
}
|
||||
} else {
|
||||
console.log(`No user found with email ${adminEmail}. Skipping admin role assignment.`);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Error seeding admin user:", error);
|
||||
throw error;
|
||||
}
|
||||
if (existingUser) {
|
||||
// Update existing user to have admin role if they don't already
|
||||
if (existingUser.role !== "admin") {
|
||||
await prisma.user.update({
|
||||
where: { email: adminEmail },
|
||||
data: { role: "admin" },
|
||||
});
|
||||
console.log(`User with email ${adminEmail} updated to admin role.`);
|
||||
} else {
|
||||
console.log(`User with email ${adminEmail} already has admin role.`);
|
||||
}
|
||||
} else {
|
||||
console.log(
|
||||
`No user found with email ${adminEmail}. Skipping admin role assignment.`,
|
||||
);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Error seeding admin user:", error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
async function main() {
|
||||
console.log("Seeding database...");
|
||||
console.log("Seeding database...");
|
||||
|
||||
await seedAdminUser();
|
||||
await seedAdminUser();
|
||||
|
||||
console.log("Database seeding completed.");
|
||||
console.log("Database seeding completed.");
|
||||
}
|
||||
|
||||
main().catch((error) => {
|
||||
console.error("Error during seeding:", error);
|
||||
process.exit(1);
|
||||
});
|
||||
console.error("Error during seeding:", error);
|
||||
process.exit(1);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user