123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123 |
- import prisma from '../../src/prisma/PrismaClient';
- interface VendorInput {
- name: string;
- name_pt: string;
- strengths: string;
- weaknesses: string;
- website: string;
- }
- export async function seedVendors(): Promise<void> {
- try {
- // Cari user dengan username admin1
- const adminUser = await prisma.userKeycloak.findFirst({
- where: {
- id: 'd3dcbbbd-fc92-45cf-9520-d0a6859358f6',
- },
- });
- if (!adminUser) {
- throw new Error('User with username admin1 not found');
- }
- // Daftar vendor
- const vendors: VendorInput[] = [
- {
- name: 'MediSoft SIMRS',
- name_pt: 'PT Medisoft Technology',
- strengths: 'Antarmuka user-friendly, support lengkap untuk modul RS',
- weaknesses: 'Harga relatif tinggi',
- website: 'https://medisoft.co.id',
- },
- {
- name: 'SimRS Platinum',
- name_pt: 'PT Platinum Healthtech',
- strengths: 'Integrasi BPJS dan telemedicine',
- weaknesses: 'Customisasi sulit',
- website: 'https://simrsplatinum.id',
- },
- {
- name: 'Hospicare System',
- name_pt: 'PT Hospicare Nusantara',
- strengths: 'Stabil dan dokumentasi lengkap',
- weaknesses: 'Kurang inovatif',
- website: 'https://hospicare.co.id',
- },
- ];
- // Insert ke database
- for (const vendor of vendors) {
- await prisma.vendor.create({
- data: {
- ...vendor,
- created_by: adminUser.id,
- },
- });
- }
- console.log('✅ Vendor seeded!');
- } catch (error: any) {
- console.error('❌ Error seeding vendor:', error.message);
- }
- }
- seedVendors();
- // const prisma = require('../../src/prisma/PrismaClient.js');
- // async function seedVendors() {
- // try {
- // // cari user role admin
- // const adminUser = await prisma.user.findFirst({
- // where: {
- // username: 'admin1',
- // },
- // });
- // if (!adminUser) {
- // throw new Error('User with role admin not exists');
- // }
- // // Data vendor yang akan dimasukkan
- // const vendors = [
- // {
- // name: 'MediSoft SIMRS',
- // name_pt: 'PT Medisoft Technology',
- // strengths: 'Antarmuka user-friendly, support lengkap untuk modul RS',
- // weaknesses: 'Harga relatif tinggi',
- // website: 'https://medisoft.co.id',
- // },
- // {
- // name: 'SimRS Platinum',
- // name_pt: 'PT Platinum Healthtech',
- // strengths: 'Integrasi BPJS dan telemedicine',
- // weaknesses: 'Customisasi sulit',
- // website: 'https://simrsplatinum.id',
- // },
- // {
- // name: 'Hospicare System',
- // name_pt: 'PT Hospicare Nusantara',
- // strengths: 'Stabil dan dokumentasi lengkap',
- // weaknesses: 'Kurang inovatif',
- // website: 'https://hospicare.co.id',
- // },
- // ];
- // // Insert vendor dengan created_by dari adminUser.id
- // for (const vendor of vendors) {
- // await prisma.vendor.create({
- // data: {
- // ...vendor,
- // created_by: adminUser.id,
- // },
- // });
- // }
- // console.log('✅ Vendor seeded!');
- // } catch (error) {
- // console.error('❌ Error seeding vendor:', error);
- // }
- // }
- // module.exports = { seedVendors };
|