feat: Implement project search functionality and task management features

- Added search functionality to the Project List page, allowing users to filter projects by name, WP, plot, or investment number.
- Created a new Project Tasks page to manage tasks across all projects, including filtering by status and priority.
- Implemented task status updates and deletion functionality.
- Added a new Task Template Edit page for modifying existing task templates.
- Enhanced Task Template Form to include a description field and loading state during submission.
- Updated UI components for better user experience, including badges for task status and priority.
- Introduced new database queries for managing contracts and projects, including fetching tasks related to projects.
- Added migrations to the database for new columns and improved data handling.
This commit is contained in:
Chop
2025-06-02 23:21:04 +02:00
parent b06aad72b8
commit 35569846bc
24 changed files with 2019 additions and 169 deletions

View File

@@ -0,0 +1,59 @@
import db from "@/lib/db";
import { NextResponse } from "next/server";
export async function GET(req, { params }) {
const { id } = await params;
const contract = db
.prepare(
`
SELECT * FROM contracts
WHERE contract_id = ?
`
)
.get(id);
if (!contract) {
return NextResponse.json({ error: "Contract not found" }, { status: 404 });
}
return NextResponse.json(contract);
}
export async function DELETE(req, { params }) {
const { id } = params;
try {
// Check if there are any projects linked to this contract
const linkedProjects = db
.prepare("SELECT COUNT(*) as count FROM projects WHERE contract_id = ?")
.get(id);
if (linkedProjects.count > 0) {
return NextResponse.json(
{ error: "Nie można usunąć umowy z przypisanymi projektami" },
{ status: 400 }
);
}
// Delete the contract
const result = db
.prepare("DELETE FROM contracts WHERE contract_id = ?")
.run(id);
if (result.changes === 0) {
return NextResponse.json(
{ error: "Contract not found" },
{ status: 404 }
);
}
return NextResponse.json({ success: true });
} catch (error) {
console.error("Error deleting contract:", error);
return NextResponse.json(
{ error: "Internal server error" },
{ status: 500 }
);
}
}