diff --git a/src/database/database.ts b/src/database/database.ts index 2668876..02bed36 100644 --- a/src/database/database.ts +++ b/src/database/database.ts @@ -5,6 +5,8 @@ import { defaultAdminUser } from "./defaultAdminUser"; import { sampleUsers } from "./sampleUsers"; import { samplePermissions } from "./samplePermissions"; import { sampleUserPermissions } from "./sampleUserPermissions"; +import { sampleCustomers } from "./sampleCustomers"; +import { sampleCustomerDependants } from "./sampleCustomerDependants"; import path from "path"; // File path for db.json @@ -29,6 +31,16 @@ export async function initDB() { await db.read(); db.data ||= { customers: [], users: [], customerDependants: [], userPermissions: [], permissions: [] }; + // Initialize customers with sample data + if (db.data.customers.length === 0) { + db.data.customers.push(...sampleCustomers); + } + + // Initialize customer dependants with sample data + if (db.data.customerDependants.length === 0) { + db.data.customerDependants.push(...sampleCustomerDependants); + } + // Initialize users with default admin and sample users if (db.data.users.length === 0) { db.data.users.push(defaultAdminUser); @@ -59,6 +71,12 @@ export async function resetDB() { permissions: [], }; + // Initialize customers with sample data + db.data.customers.push(...sampleCustomers); + + // Initialize customer dependants with sample data + db.data.customerDependants.push(...sampleCustomerDependants); + // Initialize users with default admin and sample users db.data.users.push(defaultAdminUser); db.data.users.push(...sampleUsers); diff --git a/src/database/db.json b/src/database/db.json index 4848bf9..8361ed9 100644 --- a/src/database/db.json +++ b/src/database/db.json @@ -2,21 +2,48 @@ "customers": [ { "id": 1, - "firstNameEn": "Đỗ", - "lastNameEn": "Tùng", - "email": "dothanhtung196@gmail.com", - "mobile": "0987417491", - "originAdd1": "1231231231", - "localAdd1": "sdfgsdfg" + "firstNameEn": "John", + "lastNameEn": "Smith", + "email": "john.smith@email.com", + "mobile": "+1-555-0101", + "originAdd1": "123 Main Street, New York, NY 10001, USA", + "localAdd1": "456 Oak Avenue, Tokyo, Japan 150-0001" }, { "id": 2, - "firstNameEn": "Đỗ", - "lastNameEn": "Tùng", - "email": "dothanhtung196@gmail.com", - "mobile": "0987417491", - "originAdd1": "1231231231", - "localAdd1": "sdfgsdfg" + "firstNameEn": "Sarah", + "lastNameEn": "Johnson", + "email": "sarah.johnson@email.com", + "mobile": "+1-555-0102", + "originAdd1": "789 Pine Road, Los Angeles, CA 90210, USA", + "localAdd1": "321 Sakura Street, Osaka, Japan 530-0001" + }, + { + "id": 3, + "firstNameEn": "Michael", + "lastNameEn": "Brown", + "email": "michael.brown@email.com", + "mobile": "+44-20-7946-0958", + "originAdd1": "42 Victoria Street, London, UK SW1H 0TL", + "localAdd1": "789 Shibuya Crossing, Tokyo, Japan 150-0002" + }, + { + "id": 4, + "firstNameEn": "Emily", + "lastNameEn": "Davis", + "email": "emily.davis@email.com", + "mobile": "+61-2-9876-5432", + "originAdd1": "15 Collins Street, Melbourne, VIC 3000, Australia", + "localAdd1": "654 Namba District, Osaka, Japan 542-0076" + }, + { + "id": 5, + "firstNameEn": "David", + "lastNameEn": "Wilson", + "email": "david.wilson@email.com", + "mobile": "+1-416-555-0199", + "originAdd1": "100 Queen Street West, Toronto, ON M5H 2N2, Canada", + "localAdd1": "987 Ginza District, Tokyo, Japan 104-0061" } ], "users": [ @@ -118,18 +145,84 @@ "lastName": "Rodriguez", "password": "password123", "isDeleted": false - }, - { - "id": 12, - "username": "tungdt", - "email": "dothanhtung196@gmail.com", - "firstName": "Đỗ", - "lastName": "Tùng", - "password": "123456", - "isDeleted": false } ], "userPermissions": [ + { + "id": 1, + "userId": 1, + "permissionId": 1 + }, + { + "id": 2, + "userId": 1, + "permissionId": 2 + }, + { + "id": 3, + "userId": 1, + "permissionId": 3 + }, + { + "id": 4, + "userId": 1, + "permissionId": 4 + }, + { + "id": 5, + "userId": 1, + "permissionId": 5 + }, + { + "id": 6, + "userId": 1, + "permissionId": 6 + }, + { + "id": 7, + "userId": 1, + "permissionId": 7 + }, + { + "id": 8, + "userId": 1, + "permissionId": 8 + }, + { + "id": 9, + "userId": 1, + "permissionId": 9 + }, + { + "id": 10, + "userId": 1, + "permissionId": 10 + }, + { + "id": 11, + "userId": 1, + "permissionId": 11 + }, + { + "id": 12, + "userId": 1, + "permissionId": 12 + }, + { + "id": 13, + "userId": 1, + "permissionId": 13 + }, + { + "id": 14, + "userId": 1, + "permissionId": 14 + }, + { + "id": 15, + "userId": 1, + "permissionId": 15 + }, { "id": 16, "userId": 2, @@ -344,81 +437,6 @@ "id": 58, "userId": 11, "permissionId": 12 - }, - { - "id": 59, - "userId": 1, - "permissionId": 1 - }, - { - "id": 60, - "userId": 1, - "permissionId": 2 - }, - { - "id": 61, - "userId": 1, - "permissionId": 4 - }, - { - "id": 62, - "userId": 1, - "permissionId": 5 - }, - { - "id": 63, - "userId": 1, - "permissionId": 6 - }, - { - "id": 64, - "userId": 1, - "permissionId": 7 - }, - { - "id": 65, - "userId": 1, - "permissionId": 8 - }, - { - "id": 66, - "userId": 1, - "permissionId": 9 - }, - { - "id": 67, - "userId": 1, - "permissionId": 10 - }, - { - "id": 68, - "userId": 1, - "permissionId": 11 - }, - { - "id": 69, - "userId": 1, - "permissionId": 12 - }, - { - "id": 70, - "userId": 1, - "permissionId": 13 - }, - { - "id": 71, - "userId": 1, - "permissionId": 14 - }, - { - "id": 72, - "userId": 1, - "permissionId": 15 - }, - { - "id": 73, - "userId": 1, - "permissionId": 3 } ], "permissions": [ @@ -514,35 +532,95 @@ } ], "customerDependants": [ - { - "id": 2, - "custId": 2, - "firstNameEn": "Đỗ", - "lastNameEn": "Tùng", - "email": "dothanhtung196@gmail.com", - "mobile": "0987417491", - "originAdd1": "1231231231", - "localAdd1": "sdfgsdfg" - }, { "id": 1, "custId": 1, - "firstNameEn": "Đỗ", - "lastNameEn": "Tùng", - "originAdd1": "1231231231", - "localAdd1": "sdfgsdfg", - "email": "dothanhtung196@gmail.com", - "mobile": "0987417491" + "firstNameEn": "Jane", + "lastNameEn": "Smith", + "email": "jane.smith@email.com", + "mobile": "+1-555-0111", + "originAdd1": "123 Main Street, New York, NY 10001, USA", + "localAdd1": "456 Oak Avenue, Tokyo, Japan 150-0001" }, { - "id": 1751854039116, + "id": 2, "custId": 1, - "firstNameEn": "Đỗ", - "lastNameEn": "Thanh Tùng", - "originAdd1": "123", - "localAdd1": "111", - "email": "dothanhtung196@gmail.com", - "mobile": "0987417491" + "firstNameEn": "Tommy", + "lastNameEn": "Smith", + "email": "tommy.smith@email.com", + "mobile": "+1-555-0112", + "originAdd1": "123 Main Street, New York, NY 10001, USA", + "localAdd1": "456 Oak Avenue, Tokyo, Japan 150-0001" + }, + { + "id": 3, + "custId": 2, + "firstNameEn": "Mark", + "lastNameEn": "Johnson", + "email": "mark.johnson@email.com", + "mobile": "+1-555-0121", + "originAdd1": "789 Pine Road, Los Angeles, CA 90210, USA", + "localAdd1": "321 Sakura Street, Osaka, Japan 530-0001" + }, + { + "id": 4, + "custId": 2, + "firstNameEn": "Lisa", + "lastNameEn": "Johnson", + "email": "lisa.johnson@email.com", + "mobile": "+1-555-0122", + "originAdd1": "789 Pine Road, Los Angeles, CA 90210, USA", + "localAdd1": "321 Sakura Street, Osaka, Japan 530-0001" + }, + { + "id": 5, + "custId": 3, + "firstNameEn": "Anna", + "lastNameEn": "Brown", + "email": "anna.brown@email.com", + "mobile": "+44-20-7946-0959", + "originAdd1": "42 Victoria Street, London, UK SW1H 0TL", + "localAdd1": "789 Shibuya Crossing, Tokyo, Japan 150-0002" + }, + { + "id": 6, + "custId": 4, + "firstNameEn": "James", + "lastNameEn": "Davis", + "email": "james.davis@email.com", + "mobile": "+61-2-9876-5433", + "originAdd1": "15 Collins Street, Melbourne, VIC 3000, Australia", + "localAdd1": "654 Namba District, Osaka, Japan 542-0076" + }, + { + "id": 7, + "custId": 4, + "firstNameEn": "Sophie", + "lastNameEn": "Davis", + "email": "sophie.davis@email.com", + "mobile": "+61-2-9876-5434", + "originAdd1": "15 Collins Street, Melbourne, VIC 3000, Australia", + "localAdd1": "654 Namba District, Osaka, Japan 542-0076" + }, + { + "id": 8, + "custId": 4, + "firstNameEn": "Oliver", + "lastNameEn": "Davis", + "email": "oliver.davis@email.com", + "mobile": "+61-2-9876-5435", + "originAdd1": "15 Collins Street, Melbourne, VIC 3000, Australia", + "localAdd1": "654 Namba District, Osaka, Japan 542-0076" + }, + { + "id": 9, + "custId": 5, + "firstNameEn": "Rachel", + "lastNameEn": "Wilson", + "email": "rachel.wilson@email.com", + "mobile": "+1-416-555-0191", + "originAdd1": "100 Queen Street West, Toronto, ON M5H 2N2, Canada", + "localAdd1": "987 Ginza District, Tokyo, Japan 104-0061" } ] } \ No newline at end of file diff --git a/src/database/sampleCustomerDependants.ts b/src/database/sampleCustomerDependants.ts new file mode 100644 index 0000000..10e8337 --- /dev/null +++ b/src/database/sampleCustomerDependants.ts @@ -0,0 +1,99 @@ +import { CustomerDependant } from "./database.schema"; + +export const sampleCustomerDependants: CustomerDependant[] = [ + // Dependants for John Smith (custId: 1) + { + id: 1, + custId: 1, + firstNameEn: "Jane", + lastNameEn: "Smith", + email: "jane.smith@email.com", + mobile: "+1-555-0111", + originAdd1: "123 Main Street, New York, NY 10001, USA", + localAdd1: "456 Oak Avenue, Tokyo, Japan 150-0001", + }, + { + id: 2, + custId: 1, + firstNameEn: "Tommy", + lastNameEn: "Smith", + email: "tommy.smith@email.com", + mobile: "+1-555-0112", + originAdd1: "123 Main Street, New York, NY 10001, USA", + localAdd1: "456 Oak Avenue, Tokyo, Japan 150-0001", + }, + // Dependants for Sarah Johnson (custId: 2) + { + id: 3, + custId: 2, + firstNameEn: "Mark", + lastNameEn: "Johnson", + email: "mark.johnson@email.com", + mobile: "+1-555-0121", + originAdd1: "789 Pine Road, Los Angeles, CA 90210, USA", + localAdd1: "321 Sakura Street, Osaka, Japan 530-0001", + }, + { + id: 4, + custId: 2, + firstNameEn: "Lisa", + lastNameEn: "Johnson", + email: "lisa.johnson@email.com", + mobile: "+1-555-0122", + originAdd1: "789 Pine Road, Los Angeles, CA 90210, USA", + localAdd1: "321 Sakura Street, Osaka, Japan 530-0001", + }, + // Dependants for Michael Brown (custId: 3) + { + id: 5, + custId: 3, + firstNameEn: "Anna", + lastNameEn: "Brown", + email: "anna.brown@email.com", + mobile: "+44-20-7946-0959", + originAdd1: "42 Victoria Street, London, UK SW1H 0TL", + localAdd1: "789 Shibuya Crossing, Tokyo, Japan 150-0002", + }, + // Dependants for Emily Davis (custId: 4) + { + id: 6, + custId: 4, + firstNameEn: "James", + lastNameEn: "Davis", + email: "james.davis@email.com", + mobile: "+61-2-9876-5433", + originAdd1: "15 Collins Street, Melbourne, VIC 3000, Australia", + localAdd1: "654 Namba District, Osaka, Japan 542-0076", + }, + { + id: 7, + custId: 4, + firstNameEn: "Sophie", + lastNameEn: "Davis", + email: "sophie.davis@email.com", + mobile: "+61-2-9876-5434", + originAdd1: "15 Collins Street, Melbourne, VIC 3000, Australia", + localAdd1: "654 Namba District, Osaka, Japan 542-0076", + }, + { + id: 8, + custId: 4, + firstNameEn: "Oliver", + lastNameEn: "Davis", + email: "oliver.davis@email.com", + mobile: "+61-2-9876-5435", + originAdd1: "15 Collins Street, Melbourne, VIC 3000, Australia", + localAdd1: "654 Namba District, Osaka, Japan 542-0076", + }, + // Dependants for David Wilson (custId: 5) + { + id: 9, + custId: 5, + firstNameEn: "Rachel", + lastNameEn: "Wilson", + email: "rachel.wilson@email.com", + mobile: "+1-416-555-0191", + originAdd1: "100 Queen Street West, Toronto, ON M5H 2N2, Canada", + localAdd1: "987 Ginza District, Tokyo, Japan 104-0061", + }, +]; diff --git a/src/database/sampleCustomers.ts b/src/database/sampleCustomers.ts new file mode 100644 index 0000000..394da42 --- /dev/null +++ b/src/database/sampleCustomers.ts @@ -0,0 +1,49 @@ +import { Customer } from "./database.schema"; + +export const sampleCustomers: Customer[] = [ + { + id: 1, + firstNameEn: "John", + lastNameEn: "Smith", + email: "john.smith@email.com", + mobile: "+1-555-0101", + originAdd1: "123 Main Street, New York, NY 10001, USA", + localAdd1: "456 Oak Avenue, Tokyo, Japan 150-0001", + }, + { + id: 2, + firstNameEn: "Sarah", + lastNameEn: "Johnson", + email: "sarah.johnson@email.com", + mobile: "+1-555-0102", + originAdd1: "789 Pine Road, Los Angeles, CA 90210, USA", + localAdd1: "321 Sakura Street, Osaka, Japan 530-0001", + }, + { + id: 3, + firstNameEn: "Michael", + lastNameEn: "Brown", + email: "michael.brown@email.com", + mobile: "+44-20-7946-0958", + originAdd1: "42 Victoria Street, London, UK SW1H 0TL", + localAdd1: "789 Shibuya Crossing, Tokyo, Japan 150-0002", + }, + { + id: 4, + firstNameEn: "Emily", + lastNameEn: "Davis", + email: "emily.davis@email.com", + mobile: "+61-2-9876-5432", + originAdd1: "15 Collins Street, Melbourne, VIC 3000, Australia", + localAdd1: "654 Namba District, Osaka, Japan 542-0076", + }, + { + id: 5, + firstNameEn: "David", + lastNameEn: "Wilson", + email: "david.wilson@email.com", + mobile: "+1-416-555-0199", + originAdd1: "100 Queen Street West, Toronto, ON M5H 2N2, Canada", + localAdd1: "987 Ginza District, Tokyo, Japan 104-0061", + }, +];