mirror of
https://github.com/i701/sarlink-portal.git
synced 2025-02-22 16:22:00 +00:00
- Added new PaymentPage component for processing payments and displaying devices to pay. - Introduced DeviceDetails component for viewing individual device information. - Implemented PriceCalculator component for calculating costs based on user input. - Integrated Jotai for state management across components, including device cart functionality. - Updated layout to include Jotai Provider for state management. - Enhanced DevicesTable with AddDevicesToCartButton for adding devices to the cart. - Refactored sidebar to include a link to the new Price Calculator page. - Updated Prisma schema to include Payment and BillFormula models for better data handling. - Added new UI components for device cart management and drawer functionality. - Improved overall user experience with responsive design adjustments and new UI elements.
82 lines
1.9 KiB
TypeScript
82 lines
1.9 KiB
TypeScript
import { faker } from "@faker-js/faker";
|
|
import { PrismaClient } from "@prisma/client";
|
|
|
|
const prisma = new PrismaClient();
|
|
|
|
const DEFAULT_ISLANDS = ["Dharanboodhoo", "Feeali", "Nilandhoo", "Magoodhoo"];
|
|
|
|
async function main() {
|
|
await prisma.user.upsert({
|
|
where: {
|
|
phoneNumber: "+9607780588",
|
|
},
|
|
update: {},
|
|
create: {
|
|
name: "Admin",
|
|
email: "admin@sarlink.net",
|
|
emailVerified: true,
|
|
firstPaymentDone: true,
|
|
verified: true,
|
|
address: "Dharanboodhoo",
|
|
id_card: "A265117",
|
|
dob: new Date("1990-01-01"),
|
|
phoneNumber: "+9607780588",
|
|
phoneNumberVerified: true,
|
|
role: "ADMIN",
|
|
},
|
|
});
|
|
const users = Array.from({ length: 25 }, () => ({
|
|
name: `${faker.person.fullName().split(" ")[1]} House-${crypto
|
|
.randomUUID()
|
|
.slice(0, 5)}`,
|
|
email: faker.internet.email(),
|
|
emailVerified: false,
|
|
firstPaymentDone: false,
|
|
verified: false,
|
|
address: faker.location.streetAddress(),
|
|
id_card: `A${Math.round(Math.random() * 999999)}`,
|
|
dob: faker.date.between({
|
|
from: "1900-01-01",
|
|
to: "2000-01-01",
|
|
}),
|
|
phoneNumber: String(faker.number.int({ min: 7000000, max: 9999999 })),
|
|
phoneNumberVerified: false,
|
|
role: "USER",
|
|
}));
|
|
|
|
const seedUsers = await Promise.all(
|
|
users.map((user) => prisma.user.create({ data: user })),
|
|
);
|
|
|
|
const FAKE_DEVICES = Array.from({ length: 25 }, () => ({
|
|
name: faker.commerce.productName(),
|
|
mac: faker.internet.mac(),
|
|
userId: seedUsers[Math.floor(Math.random() * seedUsers.length)].id,
|
|
}));
|
|
|
|
await prisma.device.createMany({
|
|
data: FAKE_DEVICES,
|
|
});
|
|
const FAAFU_ATOLL = await prisma.atoll.create({
|
|
data: {
|
|
name: "F",
|
|
},
|
|
});
|
|
|
|
const islands = DEFAULT_ISLANDS.map((name) => ({
|
|
name,
|
|
atollId: FAAFU_ATOLL.id,
|
|
}));
|
|
await prisma.island.createMany({
|
|
data: islands,
|
|
});
|
|
}
|
|
|
|
main()
|
|
.then(() => prisma.$disconnect())
|
|
.catch(async (e) => {
|
|
console.error(e);
|
|
await prisma.$disconnect();
|
|
process.exit(1);
|
|
});
|