feat: Add NoteForm, ProjectForm, and ProjectTaskForm components

- Implemented NoteForm for adding notes to projects.
- Created ProjectForm for managing project details with contract selection.
- Developed ProjectTaskForm for adding tasks to projects, supporting both templates and custom tasks.

feat: Add ProjectTasksSection component

- Introduced ProjectTasksSection to display and manage tasks for a specific project.
- Includes functionality for adding, updating, and deleting tasks.

feat: Create TaskTemplateForm for managing task templates

- Added TaskTemplateForm for creating new task templates with required wait days.

feat: Implement UI components

- Created reusable UI components: Badge, Button, Card, Input, Loading, Navigation.
- Enhanced user experience with consistent styling and functionality.

feat: Set up database and queries

- Initialized SQLite database with tables for contracts, projects, tasks, project tasks, and notes.
- Implemented queries for managing contracts, projects, tasks, and notes.

chore: Add error handling and loading states

- Improved error handling in forms and data fetching.
- Added loading states for better user feedback during data operations.
This commit is contained in:
Chop
2025-06-02 22:07:05 +02:00
parent aa1eb99ce9
commit d0586f2876
43 changed files with 3272 additions and 137 deletions

View File

@@ -0,0 +1,41 @@
"use client";
const Badge = ({
children,
variant = "default",
size = "sm",
className = "",
}) => {
const variants = {
default: "bg-gray-100 text-gray-800",
primary: "bg-blue-100 text-blue-800",
success: "bg-green-100 text-green-800",
warning: "bg-yellow-100 text-yellow-800",
danger: "bg-red-100 text-red-800",
urgent: "bg-red-500 text-white",
high: "bg-orange-500 text-white",
normal: "bg-blue-500 text-white",
low: "bg-gray-500 text-white",
};
const sizes = {
xs: "px-2 py-0.5 text-xs",
sm: "px-2.5 py-0.5 text-xs",
md: "px-3 py-1 text-sm",
};
return (
<span
className={`
inline-flex items-center rounded-full font-medium
${variants[variant]}
${sizes[size]}
${className}
`}
>
{children}
</span>
);
};
export default Badge;

View File

@@ -0,0 +1,54 @@
"use client";
import { forwardRef } from "react";
const buttonVariants = {
primary: "bg-blue-600 hover:bg-blue-700 text-white",
secondary:
"bg-gray-100 hover:bg-gray-200 text-gray-900 border border-gray-300",
danger: "bg-red-600 hover:bg-red-700 text-white",
success: "bg-green-600 hover:bg-green-700 text-white",
outline: "border border-blue-600 text-blue-600 hover:bg-blue-50",
};
const buttonSizes = {
sm: "px-3 py-1.5 text-sm",
md: "px-4 py-2 text-sm",
lg: "px-6 py-3 text-base",
};
const Button = forwardRef(
(
{
children,
variant = "primary",
size = "md",
disabled = false,
className = "",
...props
},
ref
) => {
return (
<button
ref={ref}
className={`
inline-flex items-center justify-center rounded-lg font-medium transition-colors
focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2
disabled:opacity-50 disabled:cursor-not-allowed
${buttonVariants[variant]}
${buttonSizes[size]}
${className}
`}
disabled={disabled}
{...props}
>
{children}
</button>
);
}
);
Button.displayName = "Button";
export default Button;

42
src/components/ui/Card.js Normal file
View File

@@ -0,0 +1,42 @@
"use client";
import { forwardRef } from "react";
const Card = forwardRef(({ children, className = "", ...props }, ref) => {
return (
<div
ref={ref}
className={`
bg-white rounded-lg border border-gray-200 shadow-sm
${className}
`}
{...props}
>
{children}
</div>
);
});
Card.displayName = "Card";
const CardHeader = ({ children, className = "" }) => {
return (
<div className={`px-6 py-4 border-b border-gray-200 ${className}`}>
{children}
</div>
);
};
const CardContent = ({ children, className = "" }) => {
return <div className={`px-6 py-4 ${className}`}>{children}</div>;
};
const CardFooter = ({ children, className = "" }) => {
return (
<div className={`px-6 py-4 border-t border-gray-200 ${className}`}>
{children}
</div>
);
};
export { Card, CardHeader, CardContent, CardFooter };

104
src/components/ui/Input.js Normal file
View File

@@ -0,0 +1,104 @@
"use client";
import { forwardRef } from "react";
const Input = forwardRef(
({ label, error, className = "", type = "text", ...props }, ref) => {
return (
<div className="space-y-1">
{label && (
<label className="block text-sm font-medium text-gray-700">
{label}
</label>
)}
<input
ref={ref}
type={type}
className={`
w-full px-3 py-2 border border-gray-300 rounded-lg
focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500
disabled:bg-gray-50 disabled:text-gray-500
${
error
? "border-red-300 focus:ring-red-500 focus:border-red-500"
: ""
}
${className}
`}
{...props}
/>
{error && <p className="text-sm text-red-600">{error}</p>}
</div>
);
}
);
Input.displayName = "Input";
const Select = forwardRef(
({ label, error, children, className = "", ...props }, ref) => {
return (
<div className="space-y-1">
{label && (
<label className="block text-sm font-medium text-gray-700">
{label}
</label>
)}
<select
ref={ref}
className={`
w-full px-3 py-2 border border-gray-300 rounded-lg
focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500
disabled:bg-gray-50 disabled:text-gray-500
${
error
? "border-red-300 focus:ring-red-500 focus:border-red-500"
: ""
}
${className}
`}
{...props}
>
{children}
</select>
{error && <p className="text-sm text-red-600">{error}</p>}
</div>
);
}
);
Select.displayName = "Select";
const Textarea = forwardRef(
({ label, error, className = "", ...props }, ref) => {
return (
<div className="space-y-1">
{label && (
<label className="block text-sm font-medium text-gray-700">
{label}
</label>
)}
<textarea
ref={ref}
className={`
w-full px-3 py-2 border border-gray-300 rounded-lg
focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500
disabled:bg-gray-50 disabled:text-gray-500
${
error
? "border-red-300 focus:ring-red-500 focus:border-red-500"
: ""
}
${className}
`}
{...props}
/>
{error && <p className="text-sm text-red-600">{error}</p>}
</div>
);
}
);
Textarea.displayName = "Textarea";
export { Input, Select, Textarea };

View File

@@ -0,0 +1,39 @@
"use client";
const LoadingSpinner = ({ size = "md", className = "" }) => {
const sizes = {
sm: "w-4 h-4",
md: "w-6 h-6",
lg: "w-8 h-8",
xl: "w-12 h-12",
};
return (
<div
className={`animate-spin rounded-full border-2 border-gray-300 border-t-blue-600 ${sizes[size]} ${className}`}
></div>
);
};
const LoadingCard = ({ className = "" }) => (
<div className={`animate-pulse ${className}`}>
<div className="bg-white rounded-lg border border-gray-200 shadow-sm p-6">
<div className="space-y-3">
<div className="h-4 bg-gray-200 rounded w-3/4"></div>
<div className="h-3 bg-gray-200 rounded w-1/2"></div>
<div className="h-3 bg-gray-200 rounded w-2/3"></div>
</div>
</div>
</div>
);
const LoadingList = ({ items = 3, className = "" }) => (
<div className={`space-y-4 ${className}`}>
{Array.from({ length: items }).map((_, index) => (
<LoadingCard key={index} />
))}
</div>
);
export { LoadingSpinner, LoadingCard, LoadingList };
export default LoadingSpinner;

View File

@@ -0,0 +1,52 @@
"use client";
import Link from "next/link";
import { usePathname } from "next/navigation";
const Navigation = () => {
const pathname = usePathname();
const isActive = (path) => {
if (path === "/") return pathname === "/";
return pathname.startsWith(path);
};
const navItems = [
{ href: "/", label: "Dashboard" },
{ href: "/projects", label: "Projects" },
{ href: "/tasks/templates", label: "Task Templates" },
{ href: "/contracts", label: "Contracts" },
];
return (
<nav className="bg-white border-b border-gray-200">
<div className="max-w-6xl mx-auto px-6">
<div className="flex items-center justify-between h-16">
<div className="flex items-center">
<Link href="/" className="text-xl font-bold text-gray-900">
Project Panel
</Link>
</div>
<div className="flex space-x-8">
{navItems.map((item) => (
<Link
key={item.href}
href={item.href}
className={`px-3 py-2 rounded-md text-sm font-medium transition-colors ${
isActive(item.href)
? "bg-blue-100 text-blue-700"
: "text-gray-600 hover:text-gray-900 hover:bg-gray-50"
}`}
>
{item.label}
</Link>
))}
</div>
</div>
</div>
</nav>
);
};
export default Navigation;