Replace demo admins with a single login and drop fake inbox seed.

Only 09128081392 / 123456 remains as admin; remove seeded internal messages and add a reset-admin script for production databases.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-08-09 16:25:37 +03:30
co-authored by Cursor
parent fd187ea2ee
commit 63646b9f01
8 changed files with 64 additions and 114 deletions
+14 -107
View File
@@ -1,4 +1,4 @@
import { PrismaClient, AdminRole, CustomerType, OrderStatus, SettlementType, CheckRegistrationMode, CheckStatus, CashPaymentStatus, ShipmentStatus, NotificationTone } from '@prisma/client';
import { PrismaClient, AdminRole, CustomerType, OrderStatus, SettlementType, CheckRegistrationMode, CheckStatus, CashPaymentStatus, ShipmentStatus } from '@prisma/client';
import * as bcrypt from 'bcryptjs';
const prisma = new PrismaClient();
@@ -25,61 +25,18 @@ async function main() {
await prisma.internalMessage.deleteMany();
await prisma.systemSettings.deleteMany();
const passwordHash = await bcrypt.hash('admin123', 10);
const passwordHash = await bcrypt.hash('123456', 10);
await prisma.adminUser.createMany({
data: [
{
id: 'usr-1',
fullName: 'علی محمدی',
phone: '09121112222',
email: 'admin@fabrictrade.ir',
passwordHash,
role: AdminRole.admin,
isActive: true,
lastLoginAt: new Date('2024-10-25T08:00:00'),
},
{
id: 'usr-2',
fullName: 'سارا احمدی',
phone: '09133334444',
email: 'sales@fabrictrade.ir',
passwordHash,
role: AdminRole.sales,
isActive: true,
lastLoginAt: new Date('2024-10-25T07:45:00'),
},
{
id: 'usr-3',
fullName: 'رضا کریمی',
phone: '09155556666',
email: 'finance@fabrictrade.ir',
passwordHash,
role: AdminRole.finance,
isActive: true,
lastLoginAt: new Date('2024-10-24T17:10:00'),
},
{
id: 'usr-4',
fullName: 'مریم حسینی',
phone: '09177778888',
email: 'warehouse@fabrictrade.ir',
passwordHash,
role: AdminRole.warehouse,
isActive: true,
lastLoginAt: new Date('2024-10-24T14:00:00'),
},
{
id: 'usr-5',
fullName: 'امیر نوری',
phone: '09199990000',
email: 'amir.n@fabrictrade.ir',
passwordHash,
role: AdminRole.sales,
isActive: false,
lastLoginAt: new Date('2024-09-30T11:00:00'),
},
],
await prisma.adminUser.create({
data: {
id: 'usr-1',
fullName: 'مدیر سیستم',
phone: '09128081392',
email: 'admin@parche.ir',
passwordHash,
role: AdminRole.admin,
isActive: true,
},
});
await prisma.company.createMany({
@@ -581,61 +538,11 @@ async function main() {
},
});
await prisma.adminNotification.createMany({
data: [
{
id: 'ntf-1',
title: 'سفارش جدید ثبت شد',
body: 'سفارش ORD-1403-1260 از مشتری پارچه‌سرای نیکو در انتظار بررسی است.',
tone: NotificationTone.info,
link: '/orders',
isRead: false,
sentAt: new Date('2024-10-25T10:05:00'),
},
{
id: 'ntf-2',
title: 'چک در انتظار تأیید',
body: '۳ فقره چک برای سفارش ORD-1403-1254 نیاز به بررسی دارد.',
tone: NotificationTone.warning,
link: '/orders/ord-1/checks',
isRead: false,
sentAt: new Date('2024-10-25T09:50:00'),
},
{
id: 'ntf-3',
title: 'پیش‌فاکتور ارسال شد',
body: 'پیش‌فاکتور سفارش ORD-1403-1252 برای مشتری ارسال گردید.',
tone: NotificationTone.success,
isRead: false,
sentAt: new Date('2024-10-25T09:20:00'),
},
],
});
await prisma.internalMessage.createMany({
data: [
{
id: 'msg-1',
senderName: 'سارا احمدی',
subject: 'هماهنگی ارسال سفارش ORD-1403-1256',
preview: 'لطفاً وضعیت باربری سفارش مشتری پارچه‌سرای نیکو را بررسی کنید.',
sentAt: new Date('2024-10-25T09:15:00'),
isRead: false,
},
{
id: 'msg-2',
senderName: 'رضا کریمی',
subject: 'درخواست اصلاح قیمت',
preview: 'مشتری درخواست تخفیف ۵٪ روی متراژ بالای ۳۰۰۰ متر داده است.',
sentAt: new Date('2024-10-25T08:40:00'),
isRead: false,
},
],
});
// اعلان و پیام داخلی دمو ساخته نمی‌شود؛ فقط رویدادهای واقعی سیستم می‌آیند.
void order1;
console.log('Seed completed successfully.');
console.log('Admin login: 09121112222 / admin123');
console.log('Admin login: 09128081392 / 123456');
console.log('Customer OTP login: 09121234567 / code 1234');
}