- Added user tracking features to the projects module, including: - Database schema updates to track project creator and assignee. - API enhancements for user management and project filtering by user. - UI components for user assignment in project forms and listings. - New query functions for retrieving users and filtering projects. - Security integration with role-based access and authentication requirements. chore: Create utility scripts for database checks and project testing - Added scripts to check the structure of the projects table. - Created tests for project creation and user tracking functionality. - Implemented API tests to verify project retrieval and user assignment. fix: Update project creation and update functions to include user tracking - Modified createProject and updateProject functions to handle user IDs for creator and assignee. - Ensured that project updates reflect the correct user assignments and timestamps.
41 lines
1.2 KiB
JavaScript
41 lines
1.2 KiB
JavaScript
import { createProject } from "./src/lib/queries/projects.js";
|
|
import initializeDatabase from "./src/lib/init-db.js";
|
|
|
|
// Initialize database
|
|
initializeDatabase();
|
|
|
|
console.log("Testing createProject function...\n");
|
|
|
|
const testProjectData = {
|
|
contract_id: 1, // Assuming contract 1 exists
|
|
project_name: "Test Project - User Tracking",
|
|
address: "Test Address 123",
|
|
plot: "123/456",
|
|
district: "Test District",
|
|
unit: "Test Unit",
|
|
city: "Test City",
|
|
investment_number: "TEST-2025-001",
|
|
finish_date: "2025-12-31",
|
|
wp: "TEST/2025/001",
|
|
contact: "test@example.com",
|
|
notes: "Test project with user tracking",
|
|
project_type: "design",
|
|
project_status: "registered",
|
|
coordinates: "50.0,20.0",
|
|
assigned_to: "e42a4b036074ff7233942a0728557141", // admin user ID
|
|
};
|
|
|
|
try {
|
|
console.log("Creating test project with admin user as creator...");
|
|
const result = createProject(
|
|
testProjectData,
|
|
"e42a4b036074ff7233942a0728557141"
|
|
);
|
|
console.log("✅ Project created successfully!");
|
|
console.log("Result:", result);
|
|
console.log("Project ID:", result.lastInsertRowid);
|
|
} catch (error) {
|
|
console.error("❌ Error creating project:", error.message);
|
|
console.error("Stack:", error.stack);
|
|
}
|