Compare commits
8 Commits
mai/pike/p
...
mai/cronus
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ac04930667 | ||
|
|
7c7ae396f4 | ||
|
|
433a0408f2 | ||
|
|
cabea83784 | ||
|
|
8863878b39 | ||
|
|
84b178edbf | ||
|
|
9787450d91 | ||
|
|
1e88dffd82 |
1321
ROADMAP.md
Normal file
1321
ROADMAP.md
Normal file
File diff suppressed because it is too large
Load Diff
@@ -22,6 +22,33 @@ func NewAppointmentHandler(svc *services.AppointmentService) *AppointmentHandler
|
|||||||
return &AppointmentHandler{svc: svc}
|
return &AppointmentHandler{svc: svc}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get handles GET /api/appointments/{id}
|
||||||
|
func (h *AppointmentHandler) Get(w http.ResponseWriter, r *http.Request) {
|
||||||
|
tenantID, ok := auth.TenantFromContext(r.Context())
|
||||||
|
if !ok {
|
||||||
|
writeError(w, http.StatusUnauthorized, "missing tenant")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
id, err := uuid.Parse(r.PathValue("id"))
|
||||||
|
if err != nil {
|
||||||
|
writeError(w, http.StatusBadRequest, "invalid appointment id")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
appt, err := h.svc.GetByID(r.Context(), tenantID, id)
|
||||||
|
if err != nil {
|
||||||
|
if errors.Is(err, sql.ErrNoRows) {
|
||||||
|
writeError(w, http.StatusNotFound, "appointment not found")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
writeError(w, http.StatusInternalServerError, "failed to fetch appointment")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
writeJSON(w, http.StatusOK, appt)
|
||||||
|
}
|
||||||
|
|
||||||
func (h *AppointmentHandler) List(w http.ResponseWriter, r *http.Request) {
|
func (h *AppointmentHandler) List(w http.ResponseWriter, r *http.Request) {
|
||||||
tenantID, ok := auth.TenantFromContext(r.Context())
|
tenantID, ok := auth.TenantFromContext(r.Context())
|
||||||
if !ok {
|
if !ok {
|
||||||
|
|||||||
52
backend/internal/handlers/case_events.go
Normal file
52
backend/internal/handlers/case_events.go
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
package handlers
|
||||||
|
|
||||||
|
import (
|
||||||
|
"database/sql"
|
||||||
|
"errors"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/google/uuid"
|
||||||
|
|
||||||
|
"mgit.msbls.de/m/KanzlAI-mGMT/internal/auth"
|
||||||
|
"mgit.msbls.de/m/KanzlAI-mGMT/internal/models"
|
||||||
|
"github.com/jmoiron/sqlx"
|
||||||
|
)
|
||||||
|
|
||||||
|
type CaseEventHandler struct {
|
||||||
|
db *sqlx.DB
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewCaseEventHandler(db *sqlx.DB) *CaseEventHandler {
|
||||||
|
return &CaseEventHandler{db: db}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get handles GET /api/case-events/{id}
|
||||||
|
func (h *CaseEventHandler) Get(w http.ResponseWriter, r *http.Request) {
|
||||||
|
tenantID, ok := auth.TenantFromContext(r.Context())
|
||||||
|
if !ok {
|
||||||
|
writeError(w, http.StatusUnauthorized, "missing tenant")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
eventID, err := uuid.Parse(r.PathValue("id"))
|
||||||
|
if err != nil {
|
||||||
|
writeError(w, http.StatusBadRequest, "invalid event ID")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
var event models.CaseEvent
|
||||||
|
err = h.db.GetContext(r.Context(), &event,
|
||||||
|
`SELECT id, tenant_id, case_id, event_type, title, description, event_date, created_by, metadata, created_at, updated_at
|
||||||
|
FROM case_events
|
||||||
|
WHERE id = $1 AND tenant_id = $2`, eventID, tenantID)
|
||||||
|
if err != nil {
|
||||||
|
if errors.Is(err, sql.ErrNoRows) {
|
||||||
|
writeError(w, http.StatusNotFound, "case event not found")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
writeError(w, http.StatusInternalServerError, "failed to fetch case event")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
writeJSON(w, http.StatusOK, event)
|
||||||
|
}
|
||||||
@@ -20,6 +20,33 @@ func NewDeadlineHandlers(ds *services.DeadlineService, db *sqlx.DB) *DeadlineHan
|
|||||||
return &DeadlineHandlers{deadlines: ds, db: db}
|
return &DeadlineHandlers{deadlines: ds, db: db}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get handles GET /api/deadlines/{deadlineID}
|
||||||
|
func (h *DeadlineHandlers) Get(w http.ResponseWriter, r *http.Request) {
|
||||||
|
tenantID, err := resolveTenant(r, h.db)
|
||||||
|
if err != nil {
|
||||||
|
handleTenantError(w, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
deadlineID, err := parsePathUUID(r, "deadlineID")
|
||||||
|
if err != nil {
|
||||||
|
writeError(w, http.StatusBadRequest, "invalid deadline ID")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
deadline, err := h.deadlines.GetByID(tenantID, deadlineID)
|
||||||
|
if err != nil {
|
||||||
|
writeError(w, http.StatusInternalServerError, "failed to fetch deadline")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if deadline == nil {
|
||||||
|
writeError(w, http.StatusNotFound, "deadline not found")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
writeJSON(w, http.StatusOK, deadline)
|
||||||
|
}
|
||||||
|
|
||||||
// ListAll handles GET /api/deadlines
|
// ListAll handles GET /api/deadlines
|
||||||
func (h *DeadlineHandlers) ListAll(w http.ResponseWriter, r *http.Request) {
|
func (h *DeadlineHandlers) ListAll(w http.ResponseWriter, r *http.Request) {
|
||||||
tenantID, err := resolveTenant(r, h.db)
|
tenantID, err := resolveTenant(r, h.db)
|
||||||
|
|||||||
159
backend/internal/handlers/notes.go
Normal file
159
backend/internal/handlers/notes.go
Normal file
@@ -0,0 +1,159 @@
|
|||||||
|
package handlers
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/google/uuid"
|
||||||
|
|
||||||
|
"mgit.msbls.de/m/KanzlAI-mGMT/internal/auth"
|
||||||
|
"mgit.msbls.de/m/KanzlAI-mGMT/internal/services"
|
||||||
|
)
|
||||||
|
|
||||||
|
type NoteHandler struct {
|
||||||
|
svc *services.NoteService
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewNoteHandler(svc *services.NoteService) *NoteHandler {
|
||||||
|
return &NoteHandler{svc: svc}
|
||||||
|
}
|
||||||
|
|
||||||
|
// List handles GET /api/notes?{parent_type}_id={id}
|
||||||
|
func (h *NoteHandler) List(w http.ResponseWriter, r *http.Request) {
|
||||||
|
tenantID, ok := auth.TenantFromContext(r.Context())
|
||||||
|
if !ok {
|
||||||
|
writeError(w, http.StatusUnauthorized, "missing tenant")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
parentType, parentID, err := parseNoteParent(r)
|
||||||
|
if err != nil {
|
||||||
|
writeError(w, http.StatusBadRequest, err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
notes, err := h.svc.ListByParent(r.Context(), tenantID, parentType, parentID)
|
||||||
|
if err != nil {
|
||||||
|
writeError(w, http.StatusInternalServerError, "failed to list notes")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
writeJSON(w, http.StatusOK, notes)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create handles POST /api/notes
|
||||||
|
func (h *NoteHandler) Create(w http.ResponseWriter, r *http.Request) {
|
||||||
|
tenantID, ok := auth.TenantFromContext(r.Context())
|
||||||
|
if !ok {
|
||||||
|
writeError(w, http.StatusUnauthorized, "missing tenant")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
userID, _ := auth.UserFromContext(r.Context())
|
||||||
|
|
||||||
|
var input services.CreateNoteInput
|
||||||
|
if err := json.NewDecoder(r.Body).Decode(&input); err != nil {
|
||||||
|
writeError(w, http.StatusBadRequest, "invalid request body")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if input.Content == "" {
|
||||||
|
writeError(w, http.StatusBadRequest, "content is required")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
var createdBy *uuid.UUID
|
||||||
|
if userID != uuid.Nil {
|
||||||
|
createdBy = &userID
|
||||||
|
}
|
||||||
|
|
||||||
|
note, err := h.svc.Create(r.Context(), tenantID, createdBy, input)
|
||||||
|
if err != nil {
|
||||||
|
writeError(w, http.StatusInternalServerError, "failed to create note")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
writeJSON(w, http.StatusCreated, note)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update handles PUT /api/notes/{id}
|
||||||
|
func (h *NoteHandler) Update(w http.ResponseWriter, r *http.Request) {
|
||||||
|
tenantID, ok := auth.TenantFromContext(r.Context())
|
||||||
|
if !ok {
|
||||||
|
writeError(w, http.StatusUnauthorized, "missing tenant")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
noteID, err := uuid.Parse(r.PathValue("id"))
|
||||||
|
if err != nil {
|
||||||
|
writeError(w, http.StatusBadRequest, "invalid note ID")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
var req struct {
|
||||||
|
Content string `json:"content"`
|
||||||
|
}
|
||||||
|
if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
|
||||||
|
writeError(w, http.StatusBadRequest, "invalid request body")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if req.Content == "" {
|
||||||
|
writeError(w, http.StatusBadRequest, "content is required")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
note, err := h.svc.Update(r.Context(), tenantID, noteID, req.Content)
|
||||||
|
if err != nil {
|
||||||
|
writeError(w, http.StatusInternalServerError, "failed to update note")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if note == nil {
|
||||||
|
writeError(w, http.StatusNotFound, "note not found")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
writeJSON(w, http.StatusOK, note)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delete handles DELETE /api/notes/{id}
|
||||||
|
func (h *NoteHandler) Delete(w http.ResponseWriter, r *http.Request) {
|
||||||
|
tenantID, ok := auth.TenantFromContext(r.Context())
|
||||||
|
if !ok {
|
||||||
|
writeError(w, http.StatusUnauthorized, "missing tenant")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
noteID, err := uuid.Parse(r.PathValue("id"))
|
||||||
|
if err != nil {
|
||||||
|
writeError(w, http.StatusBadRequest, "invalid note ID")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := h.svc.Delete(r.Context(), tenantID, noteID); err != nil {
|
||||||
|
writeError(w, http.StatusNotFound, "note not found")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
w.WriteHeader(http.StatusNoContent)
|
||||||
|
}
|
||||||
|
|
||||||
|
// parseNoteParent extracts the parent type and ID from query parameters.
|
||||||
|
func parseNoteParent(r *http.Request) (string, uuid.UUID, error) {
|
||||||
|
params := map[string]string{
|
||||||
|
"case_id": "case",
|
||||||
|
"deadline_id": "deadline",
|
||||||
|
"appointment_id": "appointment",
|
||||||
|
"case_event_id": "case_event",
|
||||||
|
}
|
||||||
|
|
||||||
|
for param, parentType := range params {
|
||||||
|
if v := r.URL.Query().Get(param); v != "" {
|
||||||
|
id, err := uuid.Parse(v)
|
||||||
|
if err != nil {
|
||||||
|
return "", uuid.Nil, fmt.Errorf("invalid %s", param)
|
||||||
|
}
|
||||||
|
return parentType, id, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return "", uuid.Nil, fmt.Errorf("one of case_id, deadline_id, appointment_id, or case_event_id is required")
|
||||||
|
}
|
||||||
20
backend/internal/models/note.go
Normal file
20
backend/internal/models/note.go
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
package models
|
||||||
|
|
||||||
|
import (
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/google/uuid"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Note struct {
|
||||||
|
ID uuid.UUID `db:"id" json:"id"`
|
||||||
|
TenantID uuid.UUID `db:"tenant_id" json:"tenant_id"`
|
||||||
|
CaseID *uuid.UUID `db:"case_id" json:"case_id,omitempty"`
|
||||||
|
DeadlineID *uuid.UUID `db:"deadline_id" json:"deadline_id,omitempty"`
|
||||||
|
AppointmentID *uuid.UUID `db:"appointment_id" json:"appointment_id,omitempty"`
|
||||||
|
CaseEventID *uuid.UUID `db:"case_event_id" json:"case_event_id,omitempty"`
|
||||||
|
Content string `db:"content" json:"content"`
|
||||||
|
CreatedBy *uuid.UUID `db:"created_by" json:"created_by,omitempty"`
|
||||||
|
CreatedAt time.Time `db:"created_at" json:"created_at"`
|
||||||
|
UpdatedAt time.Time `db:"updated_at" json:"updated_at"`
|
||||||
|
}
|
||||||
@@ -40,6 +40,7 @@ func New(db *sqlx.DB, authMW *auth.Middleware, cfg *config.Config, calDAVSvc *se
|
|||||||
// Middleware
|
// Middleware
|
||||||
tenantResolver := auth.NewTenantResolver(tenantSvc)
|
tenantResolver := auth.NewTenantResolver(tenantSvc)
|
||||||
|
|
||||||
|
noteSvc := services.NewNoteService(db)
|
||||||
dashboardSvc := services.NewDashboardService(db)
|
dashboardSvc := services.NewDashboardService(db)
|
||||||
|
|
||||||
// Handlers
|
// Handlers
|
||||||
@@ -51,6 +52,8 @@ func New(db *sqlx.DB, authMW *auth.Middleware, cfg *config.Config, calDAVSvc *se
|
|||||||
ruleH := handlers.NewDeadlineRuleHandlers(deadlineRuleSvc)
|
ruleH := handlers.NewDeadlineRuleHandlers(deadlineRuleSvc)
|
||||||
calcH := handlers.NewCalculateHandlers(calculator, deadlineRuleSvc)
|
calcH := handlers.NewCalculateHandlers(calculator, deadlineRuleSvc)
|
||||||
dashboardH := handlers.NewDashboardHandler(dashboardSvc)
|
dashboardH := handlers.NewDashboardHandler(dashboardSvc)
|
||||||
|
noteH := handlers.NewNoteHandler(noteSvc)
|
||||||
|
eventH := handlers.NewCaseEventHandler(db)
|
||||||
docH := handlers.NewDocumentHandler(documentSvc)
|
docH := handlers.NewDocumentHandler(documentSvc)
|
||||||
|
|
||||||
// Public routes
|
// Public routes
|
||||||
@@ -85,6 +88,7 @@ func New(db *sqlx.DB, authMW *auth.Middleware, cfg *config.Config, calDAVSvc *se
|
|||||||
scoped.HandleFunc("DELETE /api/parties/{partyId}", partyH.Delete)
|
scoped.HandleFunc("DELETE /api/parties/{partyId}", partyH.Delete)
|
||||||
|
|
||||||
// Deadlines
|
// Deadlines
|
||||||
|
scoped.HandleFunc("GET /api/deadlines/{deadlineID}", deadlineH.Get)
|
||||||
scoped.HandleFunc("GET /api/deadlines", deadlineH.ListAll)
|
scoped.HandleFunc("GET /api/deadlines", deadlineH.ListAll)
|
||||||
scoped.HandleFunc("GET /api/cases/{caseID}/deadlines", deadlineH.ListForCase)
|
scoped.HandleFunc("GET /api/cases/{caseID}/deadlines", deadlineH.ListForCase)
|
||||||
scoped.HandleFunc("POST /api/cases/{caseID}/deadlines", deadlineH.Create)
|
scoped.HandleFunc("POST /api/cases/{caseID}/deadlines", deadlineH.Create)
|
||||||
@@ -101,11 +105,21 @@ func New(db *sqlx.DB, authMW *auth.Middleware, cfg *config.Config, calDAVSvc *se
|
|||||||
scoped.HandleFunc("POST /api/deadlines/calculate", calcH.Calculate)
|
scoped.HandleFunc("POST /api/deadlines/calculate", calcH.Calculate)
|
||||||
|
|
||||||
// Appointments
|
// Appointments
|
||||||
|
scoped.HandleFunc("GET /api/appointments/{id}", apptH.Get)
|
||||||
scoped.HandleFunc("GET /api/appointments", apptH.List)
|
scoped.HandleFunc("GET /api/appointments", apptH.List)
|
||||||
scoped.HandleFunc("POST /api/appointments", apptH.Create)
|
scoped.HandleFunc("POST /api/appointments", apptH.Create)
|
||||||
scoped.HandleFunc("PUT /api/appointments/{id}", apptH.Update)
|
scoped.HandleFunc("PUT /api/appointments/{id}", apptH.Update)
|
||||||
scoped.HandleFunc("DELETE /api/appointments/{id}", apptH.Delete)
|
scoped.HandleFunc("DELETE /api/appointments/{id}", apptH.Delete)
|
||||||
|
|
||||||
|
// Case events
|
||||||
|
scoped.HandleFunc("GET /api/case-events/{id}", eventH.Get)
|
||||||
|
|
||||||
|
// Notes
|
||||||
|
scoped.HandleFunc("GET /api/notes", noteH.List)
|
||||||
|
scoped.HandleFunc("POST /api/notes", noteH.Create)
|
||||||
|
scoped.HandleFunc("PUT /api/notes/{id}", noteH.Update)
|
||||||
|
scoped.HandleFunc("DELETE /api/notes/{id}", noteH.Delete)
|
||||||
|
|
||||||
// Dashboard
|
// Dashboard
|
||||||
scoped.HandleFunc("GET /api/dashboard", dashboardH.Get)
|
scoped.HandleFunc("GET /api/dashboard", dashboardH.Get)
|
||||||
|
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ type UpcomingDeadline struct {
|
|||||||
ID uuid.UUID `json:"id" db:"id"`
|
ID uuid.UUID `json:"id" db:"id"`
|
||||||
Title string `json:"title" db:"title"`
|
Title string `json:"title" db:"title"`
|
||||||
DueDate string `json:"due_date" db:"due_date"`
|
DueDate string `json:"due_date" db:"due_date"`
|
||||||
|
CaseID uuid.UUID `json:"case_id" db:"case_id"`
|
||||||
CaseNumber string `json:"case_number" db:"case_number"`
|
CaseNumber string `json:"case_number" db:"case_number"`
|
||||||
CaseTitle string `json:"case_title" db:"case_title"`
|
CaseTitle string `json:"case_title" db:"case_title"`
|
||||||
Status string `json:"status" db:"status"`
|
Status string `json:"status" db:"status"`
|
||||||
@@ -56,8 +57,10 @@ type UpcomingAppointment struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type RecentActivity struct {
|
type RecentActivity struct {
|
||||||
|
ID uuid.UUID `json:"id" db:"id"`
|
||||||
EventType *string `json:"event_type" db:"event_type"`
|
EventType *string `json:"event_type" db:"event_type"`
|
||||||
Title string `json:"title" db:"title"`
|
Title string `json:"title" db:"title"`
|
||||||
|
CaseID uuid.UUID `json:"case_id" db:"case_id"`
|
||||||
CaseNumber string `json:"case_number" db:"case_number"`
|
CaseNumber string `json:"case_number" db:"case_number"`
|
||||||
EventDate *time.Time `json:"event_date" db:"event_date"`
|
EventDate *time.Time `json:"event_date" db:"event_date"`
|
||||||
}
|
}
|
||||||
@@ -109,7 +112,7 @@ func (s *DashboardService) Get(ctx context.Context, tenantID uuid.UUID) (*Dashbo
|
|||||||
|
|
||||||
// Upcoming deadlines (next 7 days)
|
// Upcoming deadlines (next 7 days)
|
||||||
deadlineQuery := `
|
deadlineQuery := `
|
||||||
SELECT d.id, d.title, d.due_date, c.case_number, c.title AS case_title, d.status
|
SELECT d.id, d.title, d.due_date, d.case_id, c.case_number, c.title AS case_title, d.status
|
||||||
FROM deadlines d
|
FROM deadlines d
|
||||||
JOIN cases c ON c.id = d.case_id AND c.tenant_id = d.tenant_id
|
JOIN cases c ON c.id = d.case_id AND c.tenant_id = d.tenant_id
|
||||||
WHERE d.tenant_id = $1 AND d.status = 'pending' AND d.due_date >= $2 AND d.due_date <= $3
|
WHERE d.tenant_id = $1 AND d.status = 'pending' AND d.due_date >= $2 AND d.due_date <= $3
|
||||||
@@ -135,7 +138,7 @@ func (s *DashboardService) Get(ctx context.Context, tenantID uuid.UUID) (*Dashbo
|
|||||||
|
|
||||||
// Recent activity (last 10 case events)
|
// Recent activity (last 10 case events)
|
||||||
activityQuery := `
|
activityQuery := `
|
||||||
SELECT ce.event_type, ce.title, c.case_number, ce.event_date
|
SELECT ce.id, ce.event_type, ce.title, ce.case_id, c.case_number, ce.event_date
|
||||||
FROM case_events ce
|
FROM case_events ce
|
||||||
JOIN cases c ON c.id = ce.case_id AND c.tenant_id = ce.tenant_id
|
JOIN cases c ON c.id = ce.case_id AND c.tenant_id = ce.tenant_id
|
||||||
WHERE ce.tenant_id = $1
|
WHERE ce.tenant_id = $1
|
||||||
|
|||||||
120
backend/internal/services/note_service.go
Normal file
120
backend/internal/services/note_service.go
Normal file
@@ -0,0 +1,120 @@
|
|||||||
|
package services
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"database/sql"
|
||||||
|
"fmt"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/google/uuid"
|
||||||
|
"github.com/jmoiron/sqlx"
|
||||||
|
|
||||||
|
"mgit.msbls.de/m/KanzlAI-mGMT/internal/models"
|
||||||
|
)
|
||||||
|
|
||||||
|
type NoteService struct {
|
||||||
|
db *sqlx.DB
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewNoteService(db *sqlx.DB) *NoteService {
|
||||||
|
return &NoteService{db: db}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListByParent returns all notes for a given parent entity, scoped to tenant.
|
||||||
|
func (s *NoteService) ListByParent(ctx context.Context, tenantID uuid.UUID, parentType string, parentID uuid.UUID) ([]models.Note, error) {
|
||||||
|
col, err := parentColumn(parentType)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
query := fmt.Sprintf(
|
||||||
|
`SELECT id, tenant_id, case_id, deadline_id, appointment_id, case_event_id,
|
||||||
|
content, created_by, created_at, updated_at
|
||||||
|
FROM notes
|
||||||
|
WHERE tenant_id = $1 AND %s = $2
|
||||||
|
ORDER BY created_at DESC`, col)
|
||||||
|
|
||||||
|
var notes []models.Note
|
||||||
|
if err := s.db.SelectContext(ctx, ¬es, query, tenantID, parentID); err != nil {
|
||||||
|
return nil, fmt.Errorf("listing notes by %s: %w", parentType, err)
|
||||||
|
}
|
||||||
|
if notes == nil {
|
||||||
|
notes = []models.Note{}
|
||||||
|
}
|
||||||
|
return notes, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
type CreateNoteInput struct {
|
||||||
|
CaseID *uuid.UUID `json:"case_id,omitempty"`
|
||||||
|
DeadlineID *uuid.UUID `json:"deadline_id,omitempty"`
|
||||||
|
AppointmentID *uuid.UUID `json:"appointment_id,omitempty"`
|
||||||
|
CaseEventID *uuid.UUID `json:"case_event_id,omitempty"`
|
||||||
|
Content string `json:"content"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create inserts a new note.
|
||||||
|
func (s *NoteService) Create(ctx context.Context, tenantID uuid.UUID, createdBy *uuid.UUID, input CreateNoteInput) (*models.Note, error) {
|
||||||
|
id := uuid.New()
|
||||||
|
now := time.Now().UTC()
|
||||||
|
|
||||||
|
query := `INSERT INTO notes (id, tenant_id, case_id, deadline_id, appointment_id, case_event_id, content, created_by, created_at, updated_at)
|
||||||
|
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $9)
|
||||||
|
RETURNING id, tenant_id, case_id, deadline_id, appointment_id, case_event_id, content, created_by, created_at, updated_at`
|
||||||
|
|
||||||
|
var n models.Note
|
||||||
|
err := s.db.GetContext(ctx, &n, query,
|
||||||
|
id, tenantID, input.CaseID, input.DeadlineID, input.AppointmentID, input.CaseEventID,
|
||||||
|
input.Content, createdBy, now)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("creating note: %w", err)
|
||||||
|
}
|
||||||
|
return &n, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update modifies a note's content.
|
||||||
|
func (s *NoteService) Update(ctx context.Context, tenantID, noteID uuid.UUID, content string) (*models.Note, error) {
|
||||||
|
query := `UPDATE notes SET content = $1, updated_at = $2
|
||||||
|
WHERE id = $3 AND tenant_id = $4
|
||||||
|
RETURNING id, tenant_id, case_id, deadline_id, appointment_id, case_event_id, content, created_by, created_at, updated_at`
|
||||||
|
|
||||||
|
var n models.Note
|
||||||
|
err := s.db.GetContext(ctx, &n, query, content, time.Now().UTC(), noteID, tenantID)
|
||||||
|
if err != nil {
|
||||||
|
if err == sql.ErrNoRows {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
return nil, fmt.Errorf("updating note: %w", err)
|
||||||
|
}
|
||||||
|
return &n, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delete removes a note.
|
||||||
|
func (s *NoteService) Delete(ctx context.Context, tenantID, noteID uuid.UUID) error {
|
||||||
|
result, err := s.db.ExecContext(ctx, "DELETE FROM notes WHERE id = $1 AND tenant_id = $2", noteID, tenantID)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("deleting note: %w", err)
|
||||||
|
}
|
||||||
|
rows, err := result.RowsAffected()
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("checking delete result: %w", err)
|
||||||
|
}
|
||||||
|
if rows == 0 {
|
||||||
|
return fmt.Errorf("note not found")
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func parentColumn(parentType string) (string, error) {
|
||||||
|
switch parentType {
|
||||||
|
case "case":
|
||||||
|
return "case_id", nil
|
||||||
|
case "deadline":
|
||||||
|
return "deadline_id", nil
|
||||||
|
case "appointment":
|
||||||
|
return "appointment_id", nil
|
||||||
|
case "case_event":
|
||||||
|
return "case_event_id", nil
|
||||||
|
default:
|
||||||
|
return "", fmt.Errorf("invalid parent type: %s", parentType)
|
||||||
|
}
|
||||||
|
}
|
||||||
35
frontend/src/app/(app)/cases/[id]/dokumente/page.tsx
Normal file
35
frontend/src/app/(app)/cases/[id]/dokumente/page.tsx
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
"use client";
|
||||||
|
|
||||||
|
import { useQuery } from "@tanstack/react-query";
|
||||||
|
import { useParams } from "next/navigation";
|
||||||
|
import { api } from "@/lib/api";
|
||||||
|
import type { Document } from "@/lib/types";
|
||||||
|
import { DocumentList } from "@/components/documents/DocumentList";
|
||||||
|
import { DocumentUpload } from "@/components/documents/DocumentUpload";
|
||||||
|
import { Loader2 } from "lucide-react";
|
||||||
|
|
||||||
|
export default function DokumentePage() {
|
||||||
|
const { id } = useParams<{ id: string }>();
|
||||||
|
|
||||||
|
const { data, isLoading } = useQuery({
|
||||||
|
queryKey: ["case-documents", id],
|
||||||
|
queryFn: () => api.get<Document[]>(`/cases/${id}/documents`),
|
||||||
|
});
|
||||||
|
|
||||||
|
if (isLoading) {
|
||||||
|
return (
|
||||||
|
<div className="flex items-center justify-center py-8">
|
||||||
|
<Loader2 className="h-5 w-5 animate-spin text-neutral-400" />
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const documents = Array.isArray(data) ? data : [];
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="space-y-6">
|
||||||
|
<DocumentUpload caseId={id} />
|
||||||
|
<DocumentList documents={documents} caseId={id} />
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
86
frontend/src/app/(app)/cases/[id]/fristen/page.tsx
Normal file
86
frontend/src/app/(app)/cases/[id]/fristen/page.tsx
Normal file
@@ -0,0 +1,86 @@
|
|||||||
|
"use client";
|
||||||
|
|
||||||
|
import { useQuery } from "@tanstack/react-query";
|
||||||
|
import { useParams } from "next/navigation";
|
||||||
|
import { api } from "@/lib/api";
|
||||||
|
import type { Deadline } from "@/lib/types";
|
||||||
|
import { format } from "date-fns";
|
||||||
|
import { de } from "date-fns/locale";
|
||||||
|
import { Clock, Loader2 } from "lucide-react";
|
||||||
|
|
||||||
|
const DEADLINE_STATUS: Record<string, string> = {
|
||||||
|
pending: "bg-amber-50 text-amber-700",
|
||||||
|
completed: "bg-emerald-50 text-emerald-700",
|
||||||
|
overdue: "bg-red-50 text-red-700",
|
||||||
|
};
|
||||||
|
|
||||||
|
const DEADLINE_STATUS_LABEL: Record<string, string> = {
|
||||||
|
pending: "Offen",
|
||||||
|
completed: "Erledigt",
|
||||||
|
overdue: "Ueberfaellig",
|
||||||
|
};
|
||||||
|
|
||||||
|
export default function FristenPage() {
|
||||||
|
const { id } = useParams<{ id: string }>();
|
||||||
|
|
||||||
|
const { data, isLoading } = useQuery({
|
||||||
|
queryKey: ["case-deadlines", id],
|
||||||
|
queryFn: () =>
|
||||||
|
api.get<{ deadlines: Deadline[]; total: number }>(
|
||||||
|
`/deadlines?case_id=${id}`,
|
||||||
|
),
|
||||||
|
});
|
||||||
|
|
||||||
|
if (isLoading) {
|
||||||
|
return (
|
||||||
|
<div className="flex items-center justify-center py-8">
|
||||||
|
<Loader2 className="h-5 w-5 animate-spin text-neutral-400" />
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const deadlines = Array.isArray(data?.deadlines) ? data.deadlines : [];
|
||||||
|
|
||||||
|
if (deadlines.length === 0) {
|
||||||
|
return (
|
||||||
|
<div className="flex flex-col items-center py-8 text-center">
|
||||||
|
<div className="rounded-xl bg-neutral-100 p-3">
|
||||||
|
<Clock className="h-5 w-5 text-neutral-400" />
|
||||||
|
</div>
|
||||||
|
<p className="mt-2 text-sm text-neutral-500">
|
||||||
|
Keine Fristen vorhanden.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="space-y-2">
|
||||||
|
{deadlines.map((d) => (
|
||||||
|
<div
|
||||||
|
key={d.id}
|
||||||
|
className="flex flex-col gap-2 rounded-md border border-neutral-200 bg-white px-4 py-3 sm:flex-row sm:items-center sm:justify-between"
|
||||||
|
>
|
||||||
|
<div>
|
||||||
|
<p className="text-sm font-medium text-neutral-900">{d.title}</p>
|
||||||
|
{d.description && (
|
||||||
|
<p className="mt-0.5 text-sm text-neutral-500">
|
||||||
|
{d.description}
|
||||||
|
</p>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
<div className="flex items-center gap-3">
|
||||||
|
<span
|
||||||
|
className={`rounded-full px-2 py-0.5 text-xs font-medium ${DEADLINE_STATUS[d.status] ?? "bg-neutral-100 text-neutral-500"}`}
|
||||||
|
>
|
||||||
|
{DEADLINE_STATUS_LABEL[d.status] ?? d.status}
|
||||||
|
</span>
|
||||||
|
<span className="whitespace-nowrap text-sm text-neutral-500">
|
||||||
|
{format(new Date(d.due_date), "d. MMM yyyy", { locale: de })}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
226
frontend/src/app/(app)/cases/[id]/layout.tsx
Normal file
226
frontend/src/app/(app)/cases/[id]/layout.tsx
Normal file
@@ -0,0 +1,226 @@
|
|||||||
|
"use client";
|
||||||
|
|
||||||
|
import { useQuery } from "@tanstack/react-query";
|
||||||
|
import { useParams, usePathname } from "next/navigation";
|
||||||
|
import Link from "next/link";
|
||||||
|
import { api } from "@/lib/api";
|
||||||
|
import type { Case } from "@/lib/types";
|
||||||
|
import { Breadcrumb } from "@/components/layout/Breadcrumb";
|
||||||
|
import { Skeleton } from "@/components/ui/Skeleton";
|
||||||
|
import {
|
||||||
|
ArrowLeft,
|
||||||
|
Activity,
|
||||||
|
Clock,
|
||||||
|
FileText,
|
||||||
|
Users,
|
||||||
|
StickyNote,
|
||||||
|
AlertTriangle,
|
||||||
|
} from "lucide-react";
|
||||||
|
import { format } from "date-fns";
|
||||||
|
import { de } from "date-fns/locale";
|
||||||
|
|
||||||
|
interface CaseDetail extends Case {
|
||||||
|
parties: unknown[];
|
||||||
|
deadlines_count: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
const STATUS_BADGE: Record<string, string> = {
|
||||||
|
active: "bg-emerald-50 text-emerald-700",
|
||||||
|
pending: "bg-amber-50 text-amber-700",
|
||||||
|
closed: "bg-neutral-100 text-neutral-600",
|
||||||
|
archived: "bg-neutral-100 text-neutral-400",
|
||||||
|
};
|
||||||
|
|
||||||
|
const STATUS_LABEL: Record<string, string> = {
|
||||||
|
active: "Aktiv",
|
||||||
|
pending: "Anhaengig",
|
||||||
|
closed: "Geschlossen",
|
||||||
|
archived: "Archiviert",
|
||||||
|
};
|
||||||
|
|
||||||
|
const TABS = [
|
||||||
|
{ segment: "verlauf", label: "Verlauf", icon: Activity },
|
||||||
|
{ segment: "fristen", label: "Fristen", icon: Clock },
|
||||||
|
{ segment: "dokumente", label: "Dokumente", icon: FileText },
|
||||||
|
{ segment: "parteien", label: "Parteien", icon: Users },
|
||||||
|
{ segment: "notizen", label: "Notizen", icon: StickyNote },
|
||||||
|
] as const;
|
||||||
|
|
||||||
|
const TAB_LABELS: Record<string, string> = {
|
||||||
|
verlauf: "Verlauf",
|
||||||
|
fristen: "Fristen",
|
||||||
|
dokumente: "Dokumente",
|
||||||
|
parteien: "Parteien",
|
||||||
|
notizen: "Notizen",
|
||||||
|
};
|
||||||
|
|
||||||
|
function CaseDetailSkeleton() {
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<Skeleton className="h-4 w-28" />
|
||||||
|
<div className="mt-4 flex items-start justify-between">
|
||||||
|
<div>
|
||||||
|
<Skeleton className="h-6 w-48" />
|
||||||
|
<Skeleton className="mt-2 h-4 w-64" />
|
||||||
|
</div>
|
||||||
|
<div className="space-y-1">
|
||||||
|
<Skeleton className="h-3 w-24" />
|
||||||
|
<Skeleton className="h-3 w-24" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="mt-6 flex gap-4 border-b border-neutral-200 pb-2.5">
|
||||||
|
{[1, 2, 3, 4, 5].map((i) => (
|
||||||
|
<Skeleton key={i} className="h-4 w-20" />
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
<div className="mt-6 space-y-3">
|
||||||
|
{[1, 2, 3].map((i) => (
|
||||||
|
<Skeleton key={i} className="h-14 rounded-md" />
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function CaseDetailLayout({
|
||||||
|
children,
|
||||||
|
}: {
|
||||||
|
children: React.ReactNode;
|
||||||
|
}) {
|
||||||
|
const { id } = useParams<{ id: string }>();
|
||||||
|
const pathname = usePathname();
|
||||||
|
|
||||||
|
const {
|
||||||
|
data: caseDetail,
|
||||||
|
isLoading,
|
||||||
|
error,
|
||||||
|
} = useQuery({
|
||||||
|
queryKey: ["case", id],
|
||||||
|
queryFn: () => api.get<CaseDetail>(`/cases/${id}`),
|
||||||
|
});
|
||||||
|
|
||||||
|
// Determine active tab from pathname
|
||||||
|
const segments = pathname.split("/");
|
||||||
|
const activeSegment = segments[segments.length - 1] || "verlauf";
|
||||||
|
const activeTabLabel = TAB_LABELS[activeSegment];
|
||||||
|
|
||||||
|
if (isLoading) {
|
||||||
|
return <CaseDetailSkeleton />;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (error || !caseDetail) {
|
||||||
|
return (
|
||||||
|
<div className="py-12 text-center">
|
||||||
|
<div className="mx-auto mb-3 w-fit rounded-xl bg-red-50 p-3">
|
||||||
|
<AlertTriangle className="h-6 w-6 text-red-500" />
|
||||||
|
</div>
|
||||||
|
<p className="text-sm font-medium text-neutral-900">
|
||||||
|
Akte nicht gefunden
|
||||||
|
</p>
|
||||||
|
<p className="mt-1 text-sm text-neutral-500">
|
||||||
|
Die Akte existiert nicht oder Sie haben keine Berechtigung.
|
||||||
|
</p>
|
||||||
|
<Link
|
||||||
|
href="/cases"
|
||||||
|
className="mt-4 inline-flex items-center gap-1 text-sm text-neutral-500 transition-colors hover:text-neutral-700"
|
||||||
|
>
|
||||||
|
<ArrowLeft className="h-3.5 w-3.5" />
|
||||||
|
Zurueck zu Akten
|
||||||
|
</Link>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const breadcrumbItems = [
|
||||||
|
{ label: "Dashboard", href: "/dashboard" },
|
||||||
|
{ label: "Akten", href: "/cases" },
|
||||||
|
{ label: caseDetail.case_number, href: `/cases/${id}/verlauf` },
|
||||||
|
...(activeTabLabel ? [{ label: activeTabLabel }] : []),
|
||||||
|
];
|
||||||
|
|
||||||
|
const partiesCount = Array.isArray(caseDetail.parties)
|
||||||
|
? caseDetail.parties.length
|
||||||
|
: 0;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="animate-fade-in">
|
||||||
|
<Breadcrumb items={breadcrumbItems} />
|
||||||
|
|
||||||
|
<div className="mt-4 flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between">
|
||||||
|
<div>
|
||||||
|
<div className="flex flex-wrap items-center gap-3">
|
||||||
|
<h1 className="text-lg font-semibold text-neutral-900">
|
||||||
|
{caseDetail.title}
|
||||||
|
</h1>
|
||||||
|
<span
|
||||||
|
className={`inline-block rounded-full px-2 py-0.5 text-xs font-medium ${STATUS_BADGE[caseDetail.status] ?? "bg-neutral-100 text-neutral-500"}`}
|
||||||
|
>
|
||||||
|
{STATUS_LABEL[caseDetail.status] ?? caseDetail.status}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div className="mt-1 flex flex-wrap gap-x-4 gap-y-1 text-sm text-neutral-500">
|
||||||
|
<span>Az. {caseDetail.case_number}</span>
|
||||||
|
{caseDetail.case_type && <span>{caseDetail.case_type}</span>}
|
||||||
|
{caseDetail.court && <span>{caseDetail.court}</span>}
|
||||||
|
{caseDetail.court_ref && <span>({caseDetail.court_ref})</span>}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="text-right text-xs text-neutral-400">
|
||||||
|
<p>
|
||||||
|
Erstellt:{" "}
|
||||||
|
{format(new Date(caseDetail.created_at), "d. MMM yyyy", {
|
||||||
|
locale: de,
|
||||||
|
})}
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
Aktualisiert:{" "}
|
||||||
|
{format(new Date(caseDetail.updated_at), "d. MMM yyyy", {
|
||||||
|
locale: de,
|
||||||
|
})}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{caseDetail.ai_summary && (
|
||||||
|
<div className="mt-4 rounded-md border border-blue-100 bg-blue-50 px-4 py-3 text-sm text-blue-800">
|
||||||
|
{caseDetail.ai_summary}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
|
<div className="mt-6 border-b border-neutral-200">
|
||||||
|
<nav className="-mb-px flex gap-1 overflow-x-auto sm:gap-4">
|
||||||
|
{TABS.map((tab) => {
|
||||||
|
const isActive = activeSegment === tab.segment;
|
||||||
|
return (
|
||||||
|
<Link
|
||||||
|
key={tab.segment}
|
||||||
|
href={`/cases/${id}/${tab.segment}`}
|
||||||
|
className={`inline-flex shrink-0 items-center gap-1.5 border-b-2 px-1 pb-2.5 text-sm font-medium transition-colors ${
|
||||||
|
isActive
|
||||||
|
? "border-neutral-900 text-neutral-900"
|
||||||
|
: "border-transparent text-neutral-400 hover:text-neutral-600"
|
||||||
|
}`}
|
||||||
|
>
|
||||||
|
<tab.icon className="h-4 w-4" />
|
||||||
|
{tab.label}
|
||||||
|
{tab.segment === "fristen" &&
|
||||||
|
caseDetail.deadlines_count > 0 && (
|
||||||
|
<span className="ml-1 rounded-full bg-neutral-100 px-1.5 py-0.5 text-xs text-neutral-500">
|
||||||
|
{caseDetail.deadlines_count}
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
{tab.segment === "parteien" && partiesCount > 0 && (
|
||||||
|
<span className="ml-1 rounded-full bg-neutral-100 px-1.5 py-0.5 text-xs text-neutral-500">
|
||||||
|
{partiesCount}
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
</Link>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</nav>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="mt-6">{children}</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
10
frontend/src/app/(app)/cases/[id]/notizen/page.tsx
Normal file
10
frontend/src/app/(app)/cases/[id]/notizen/page.tsx
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
"use client";
|
||||||
|
|
||||||
|
import { useParams } from "next/navigation";
|
||||||
|
import { NotesList } from "@/components/notes/NotesList";
|
||||||
|
|
||||||
|
export default function NotizenPage() {
|
||||||
|
const { id } = useParams<{ id: string }>();
|
||||||
|
|
||||||
|
return <NotesList parentType="case" parentId={id} />;
|
||||||
|
}
|
||||||
@@ -1,341 +1,10 @@
|
|||||||
"use client";
|
import { redirect } from "next/navigation";
|
||||||
|
|
||||||
import { useQuery } from "@tanstack/react-query";
|
export default async function CaseDetailPage({
|
||||||
import { useParams } from "next/navigation";
|
params,
|
||||||
import { api } from "@/lib/api";
|
}: {
|
||||||
import type { Case, CaseEvent, Party, Deadline, Document } from "@/lib/types";
|
params: Promise<{ id: string }>;
|
||||||
import { CaseTimeline } from "@/components/cases/CaseTimeline";
|
}) {
|
||||||
import { PartyList } from "@/components/cases/PartyList";
|
const { id } = await params;
|
||||||
import {
|
redirect(`/cases/${id}/verlauf`);
|
||||||
ArrowLeft,
|
|
||||||
Clock,
|
|
||||||
FileText,
|
|
||||||
Users,
|
|
||||||
Activity,
|
|
||||||
AlertTriangle,
|
|
||||||
} from "lucide-react";
|
|
||||||
import { format } from "date-fns";
|
|
||||||
import { de } from "date-fns/locale";
|
|
||||||
import Link from "next/link";
|
|
||||||
import { useState } from "react";
|
|
||||||
import { Skeleton } from "@/components/ui/Skeleton";
|
|
||||||
|
|
||||||
interface CaseDetail extends Case {
|
|
||||||
parties: Party[];
|
|
||||||
recent_events: CaseEvent[];
|
|
||||||
deadlines_count: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
const STATUS_BADGE: Record<string, string> = {
|
|
||||||
active: "bg-emerald-50 text-emerald-700",
|
|
||||||
pending: "bg-amber-50 text-amber-700",
|
|
||||||
closed: "bg-neutral-100 text-neutral-600",
|
|
||||||
archived: "bg-neutral-100 text-neutral-400",
|
|
||||||
};
|
|
||||||
|
|
||||||
const STATUS_LABEL: Record<string, string> = {
|
|
||||||
active: "Aktiv",
|
|
||||||
pending: "Anhängig",
|
|
||||||
closed: "Geschlossen",
|
|
||||||
archived: "Archiviert",
|
|
||||||
};
|
|
||||||
|
|
||||||
const TABS = [
|
|
||||||
{ key: "timeline", label: "Verlauf", icon: Activity },
|
|
||||||
{ key: "deadlines", label: "Fristen", icon: Clock },
|
|
||||||
{ key: "documents", label: "Dokumente", icon: FileText },
|
|
||||||
{ key: "parties", label: "Parteien", icon: Users },
|
|
||||||
] as const;
|
|
||||||
|
|
||||||
type TabKey = (typeof TABS)[number]["key"];
|
|
||||||
|
|
||||||
function CaseDetailSkeleton() {
|
|
||||||
return (
|
|
||||||
<div>
|
|
||||||
<Skeleton className="h-4 w-28" />
|
|
||||||
<div className="mt-4 flex items-start justify-between">
|
|
||||||
<div>
|
|
||||||
<Skeleton className="h-6 w-48" />
|
|
||||||
<Skeleton className="mt-2 h-4 w-64" />
|
|
||||||
</div>
|
|
||||||
<div className="space-y-1">
|
|
||||||
<Skeleton className="h-3 w-24" />
|
|
||||||
<Skeleton className="h-3 w-24" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div className="mt-6 flex gap-4 border-b border-neutral-200 pb-2.5">
|
|
||||||
{[1, 2, 3, 4].map((i) => (
|
|
||||||
<Skeleton key={i} className="h-4 w-20" />
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
<div className="mt-6 space-y-3">
|
|
||||||
{[1, 2, 3].map((i) => (
|
|
||||||
<Skeleton key={i} className="h-14 rounded-md" />
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
export default function CaseDetailPage() {
|
|
||||||
const { id } = useParams<{ id: string }>();
|
|
||||||
const [activeTab, setActiveTab] = useState<TabKey>("timeline");
|
|
||||||
|
|
||||||
const {
|
|
||||||
data: caseDetail,
|
|
||||||
isLoading,
|
|
||||||
error,
|
|
||||||
} = useQuery({
|
|
||||||
queryKey: ["case", id],
|
|
||||||
queryFn: () => api.get<CaseDetail>(`/cases/${id}`),
|
|
||||||
});
|
|
||||||
|
|
||||||
const { data: deadlinesData } = useQuery({
|
|
||||||
queryKey: ["case-deadlines", id],
|
|
||||||
queryFn: () =>
|
|
||||||
api.get<{ deadlines: Deadline[]; total: number }>(
|
|
||||||
`/deadlines?case_id=${id}`,
|
|
||||||
),
|
|
||||||
enabled: activeTab === "deadlines",
|
|
||||||
});
|
|
||||||
|
|
||||||
const { data: documentsData } = useQuery({
|
|
||||||
queryKey: ["case-documents", id],
|
|
||||||
queryFn: () => api.get<Document[]>(`/cases/${id}/documents`),
|
|
||||||
enabled: activeTab === "documents",
|
|
||||||
});
|
|
||||||
|
|
||||||
if (isLoading) {
|
|
||||||
return <CaseDetailSkeleton />;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (error || !caseDetail) {
|
|
||||||
return (
|
|
||||||
<div className="py-12 text-center">
|
|
||||||
<div className="mx-auto mb-3 w-fit rounded-xl bg-red-50 p-3">
|
|
||||||
<AlertTriangle className="h-6 w-6 text-red-500" />
|
|
||||||
</div>
|
|
||||||
<p className="text-sm font-medium text-neutral-900">
|
|
||||||
Akte nicht gefunden
|
|
||||||
</p>
|
|
||||||
<p className="mt-1 text-sm text-neutral-500">
|
|
||||||
Die Akte existiert nicht oder Sie haben keine Berechtigung.
|
|
||||||
</p>
|
|
||||||
<Link
|
|
||||||
href="/cases"
|
|
||||||
className="mt-4 inline-flex items-center gap-1 text-sm text-neutral-500 transition-colors hover:text-neutral-700"
|
|
||||||
>
|
|
||||||
<ArrowLeft className="h-3.5 w-3.5" />
|
|
||||||
Zurück zu Akten
|
|
||||||
</Link>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
const deadlines = Array.isArray(deadlinesData?.deadlines) ? deadlinesData.deadlines : [];
|
|
||||||
const documents = Array.isArray(documentsData) ? documentsData : [];
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className="animate-fade-in">
|
|
||||||
<Link
|
|
||||||
href="/cases"
|
|
||||||
className="mb-4 inline-flex items-center gap-1 text-sm text-neutral-500 transition-colors hover:text-neutral-700"
|
|
||||||
>
|
|
||||||
<ArrowLeft className="h-3.5 w-3.5" />
|
|
||||||
Zurück zu Akten
|
|
||||||
</Link>
|
|
||||||
|
|
||||||
<div className="flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between">
|
|
||||||
<div>
|
|
||||||
<div className="flex flex-wrap items-center gap-3">
|
|
||||||
<h1 className="text-lg font-semibold text-neutral-900">
|
|
||||||
{caseDetail.title}
|
|
||||||
</h1>
|
|
||||||
<span
|
|
||||||
className={`inline-block rounded-full px-2 py-0.5 text-xs font-medium ${STATUS_BADGE[caseDetail.status] ?? "bg-neutral-100 text-neutral-500"}`}
|
|
||||||
>
|
|
||||||
{STATUS_LABEL[caseDetail.status] ?? caseDetail.status}
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
<div className="mt-1 flex flex-wrap gap-x-4 gap-y-1 text-sm text-neutral-500">
|
|
||||||
<span>Az. {caseDetail.case_number}</span>
|
|
||||||
{caseDetail.case_type && <span>{caseDetail.case_type}</span>}
|
|
||||||
{caseDetail.court && <span>{caseDetail.court}</span>}
|
|
||||||
{caseDetail.court_ref && <span>({caseDetail.court_ref})</span>}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div className="text-right text-xs text-neutral-400">
|
|
||||||
<p>
|
|
||||||
Erstellt:{" "}
|
|
||||||
{format(new Date(caseDetail.created_at), "d. MMM yyyy", {
|
|
||||||
locale: de,
|
|
||||||
})}
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
Aktualisiert:{" "}
|
|
||||||
{format(new Date(caseDetail.updated_at), "d. MMM yyyy", {
|
|
||||||
locale: de,
|
|
||||||
})}
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{caseDetail.ai_summary && (
|
|
||||||
<div className="mt-4 rounded-md border border-blue-100 bg-blue-50 px-4 py-3 text-sm text-blue-800">
|
|
||||||
{caseDetail.ai_summary}
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
|
|
||||||
<div className="mt-6 border-b border-neutral-200">
|
|
||||||
<nav className="-mb-px flex gap-1 overflow-x-auto sm:gap-4">
|
|
||||||
{TABS.map((tab) => (
|
|
||||||
<button
|
|
||||||
key={tab.key}
|
|
||||||
onClick={() => setActiveTab(tab.key)}
|
|
||||||
className={`inline-flex shrink-0 items-center gap-1.5 border-b-2 px-1 pb-2.5 text-sm font-medium transition-colors ${
|
|
||||||
activeTab === tab.key
|
|
||||||
? "border-neutral-900 text-neutral-900"
|
|
||||||
: "border-transparent text-neutral-400 hover:text-neutral-600"
|
|
||||||
}`}
|
|
||||||
>
|
|
||||||
<tab.icon className="h-4 w-4" />
|
|
||||||
{tab.label}
|
|
||||||
{tab.key === "deadlines" && caseDetail.deadlines_count > 0 && (
|
|
||||||
<span className="ml-1 rounded-full bg-neutral-100 px-1.5 py-0.5 text-xs text-neutral-500">
|
|
||||||
{caseDetail.deadlines_count}
|
|
||||||
</span>
|
|
||||||
)}
|
|
||||||
{tab.key === "parties" && Array.isArray(caseDetail.parties) && caseDetail.parties.length > 0 && (
|
|
||||||
<span className="ml-1 rounded-full bg-neutral-100 px-1.5 py-0.5 text-xs text-neutral-500">
|
|
||||||
{caseDetail.parties.length}
|
|
||||||
</span>
|
|
||||||
)}
|
|
||||||
</button>
|
|
||||||
))}
|
|
||||||
</nav>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="mt-6">
|
|
||||||
{activeTab === "timeline" && (
|
|
||||||
<CaseTimeline events={Array.isArray(caseDetail.recent_events) ? caseDetail.recent_events : []} />
|
|
||||||
)}
|
|
||||||
|
|
||||||
{activeTab === "deadlines" && (
|
|
||||||
<DeadlinesList deadlines={deadlines} />
|
|
||||||
)}
|
|
||||||
|
|
||||||
{activeTab === "documents" && (
|
|
||||||
<DocumentsList documents={documents} />
|
|
||||||
)}
|
|
||||||
|
|
||||||
{activeTab === "parties" && (
|
|
||||||
<PartyList caseId={id} parties={Array.isArray(caseDetail.parties) ? caseDetail.parties : []} />
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
function DeadlinesList({ deadlines }: { deadlines: Deadline[] }) {
|
|
||||||
if (deadlines.length === 0) {
|
|
||||||
return (
|
|
||||||
<div className="flex flex-col items-center py-8 text-center">
|
|
||||||
<div className="rounded-xl bg-neutral-100 p-3">
|
|
||||||
<Clock className="h-5 w-5 text-neutral-400" />
|
|
||||||
</div>
|
|
||||||
<p className="mt-2 text-sm text-neutral-500">
|
|
||||||
Keine Fristen vorhanden.
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
const DEADLINE_STATUS: Record<string, string> = {
|
|
||||||
pending: "bg-amber-50 text-amber-700",
|
|
||||||
completed: "bg-emerald-50 text-emerald-700",
|
|
||||||
overdue: "bg-red-50 text-red-700",
|
|
||||||
};
|
|
||||||
|
|
||||||
const DEADLINE_STATUS_LABEL: Record<string, string> = {
|
|
||||||
pending: "Offen",
|
|
||||||
completed: "Erledigt",
|
|
||||||
overdue: "Überfällig",
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className="space-y-2">
|
|
||||||
{deadlines.map((d) => (
|
|
||||||
<div
|
|
||||||
key={d.id}
|
|
||||||
className="flex flex-col gap-2 rounded-md border border-neutral-200 bg-white px-4 py-3 sm:flex-row sm:items-center sm:justify-between"
|
|
||||||
>
|
|
||||||
<div>
|
|
||||||
<p className="text-sm font-medium text-neutral-900">{d.title}</p>
|
|
||||||
{d.description && (
|
|
||||||
<p className="mt-0.5 text-sm text-neutral-500">
|
|
||||||
{d.description}
|
|
||||||
</p>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
<div className="flex items-center gap-3">
|
|
||||||
<span
|
|
||||||
className={`rounded-full px-2 py-0.5 text-xs font-medium ${DEADLINE_STATUS[d.status] ?? "bg-neutral-100 text-neutral-500"}`}
|
|
||||||
>
|
|
||||||
{DEADLINE_STATUS_LABEL[d.status] ?? d.status}
|
|
||||||
</span>
|
|
||||||
<span className="whitespace-nowrap text-sm text-neutral-500">
|
|
||||||
{format(new Date(d.due_date), "d. MMM yyyy", { locale: de })}
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
function DocumentsList({ documents }: { documents: Document[] }) {
|
|
||||||
if (documents.length === 0) {
|
|
||||||
return (
|
|
||||||
<div className="flex flex-col items-center py-8 text-center">
|
|
||||||
<div className="rounded-xl bg-neutral-100 p-3">
|
|
||||||
<FileText className="h-5 w-5 text-neutral-400" />
|
|
||||||
</div>
|
|
||||||
<p className="mt-2 text-sm text-neutral-500">
|
|
||||||
Keine Dokumente vorhanden.
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className="space-y-2">
|
|
||||||
{documents.map((doc) => (
|
|
||||||
<div
|
|
||||||
key={doc.id}
|
|
||||||
className="flex items-center justify-between rounded-md border border-neutral-200 bg-white px-4 py-3"
|
|
||||||
>
|
|
||||||
<div className="flex items-center gap-3">
|
|
||||||
<FileText className="h-4 w-4 text-neutral-400" />
|
|
||||||
<div>
|
|
||||||
<p className="text-sm font-medium text-neutral-900">
|
|
||||||
{doc.title}
|
|
||||||
</p>
|
|
||||||
<div className="flex gap-2 text-xs text-neutral-400">
|
|
||||||
{doc.doc_type && <span>{doc.doc_type}</span>}
|
|
||||||
{doc.file_size && (
|
|
||||||
<span>{(doc.file_size / 1024).toFixed(0)} KB</span>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<a
|
|
||||||
href={`/api/documents/${doc.id}`}
|
|
||||||
className="text-sm text-neutral-500 transition-colors hover:text-neutral-700"
|
|
||||||
>
|
|
||||||
Herunterladen
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|||||||
35
frontend/src/app/(app)/cases/[id]/parteien/page.tsx
Normal file
35
frontend/src/app/(app)/cases/[id]/parteien/page.tsx
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
"use client";
|
||||||
|
|
||||||
|
import { useQuery } from "@tanstack/react-query";
|
||||||
|
import { useParams } from "next/navigation";
|
||||||
|
import { api } from "@/lib/api";
|
||||||
|
import type { Case, Party } from "@/lib/types";
|
||||||
|
import { PartyList } from "@/components/cases/PartyList";
|
||||||
|
import { Loader2 } from "lucide-react";
|
||||||
|
|
||||||
|
interface CaseDetail extends Case {
|
||||||
|
parties: Party[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function ParteienPage() {
|
||||||
|
const { id } = useParams<{ id: string }>();
|
||||||
|
|
||||||
|
const { data: caseDetail, isLoading } = useQuery({
|
||||||
|
queryKey: ["case", id],
|
||||||
|
queryFn: () => api.get<CaseDetail>(`/cases/${id}`),
|
||||||
|
});
|
||||||
|
|
||||||
|
if (isLoading) {
|
||||||
|
return (
|
||||||
|
<div className="flex items-center justify-center py-8">
|
||||||
|
<Loader2 className="h-5 w-5 animate-spin text-neutral-400" />
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const parties = Array.isArray(caseDetail?.parties)
|
||||||
|
? caseDetail.parties
|
||||||
|
: [];
|
||||||
|
|
||||||
|
return <PartyList caseId={id} parties={parties} />;
|
||||||
|
}
|
||||||
35
frontend/src/app/(app)/cases/[id]/verlauf/page.tsx
Normal file
35
frontend/src/app/(app)/cases/[id]/verlauf/page.tsx
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
"use client";
|
||||||
|
|
||||||
|
import { useQuery } from "@tanstack/react-query";
|
||||||
|
import { useParams } from "next/navigation";
|
||||||
|
import { api } from "@/lib/api";
|
||||||
|
import type { Case, CaseEvent } from "@/lib/types";
|
||||||
|
import { CaseTimeline } from "@/components/cases/CaseTimeline";
|
||||||
|
import { Loader2 } from "lucide-react";
|
||||||
|
|
||||||
|
interface CaseDetail extends Case {
|
||||||
|
recent_events: CaseEvent[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function VerlaufPage() {
|
||||||
|
const { id } = useParams<{ id: string }>();
|
||||||
|
|
||||||
|
const { data: caseDetail, isLoading } = useQuery({
|
||||||
|
queryKey: ["case", id],
|
||||||
|
queryFn: () => api.get<CaseDetail>(`/cases/${id}`),
|
||||||
|
});
|
||||||
|
|
||||||
|
if (isLoading) {
|
||||||
|
return (
|
||||||
|
<div className="flex items-center justify-center py-8">
|
||||||
|
<Loader2 className="h-5 w-5 animate-spin text-neutral-400" />
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const events = Array.isArray(caseDetail?.recent_events)
|
||||||
|
? caseDetail.recent_events
|
||||||
|
: [];
|
||||||
|
|
||||||
|
return <CaseTimeline events={events} />;
|
||||||
|
}
|
||||||
@@ -5,6 +5,7 @@ import { api } from "@/lib/api";
|
|||||||
import type { Case } from "@/lib/types";
|
import type { Case } from "@/lib/types";
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import { useSearchParams, useRouter } from "next/navigation";
|
import { useSearchParams, useRouter } from "next/navigation";
|
||||||
|
import { Breadcrumb } from "@/components/layout/Breadcrumb";
|
||||||
import { Plus, Search, FolderOpen } from "lucide-react";
|
import { Plus, Search, FolderOpen } from "lucide-react";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { SkeletonTable } from "@/components/ui/Skeleton";
|
import { SkeletonTable } from "@/components/ui/Skeleton";
|
||||||
@@ -72,6 +73,12 @@ export default function CasesPage() {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="animate-fade-in">
|
<div className="animate-fade-in">
|
||||||
|
<Breadcrumb
|
||||||
|
items={[
|
||||||
|
{ label: "Dashboard", href: "/dashboard" },
|
||||||
|
{ label: "Akten" },
|
||||||
|
]}
|
||||||
|
/>
|
||||||
<div className="flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between">
|
<div className="flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between">
|
||||||
<div>
|
<div>
|
||||||
<h1 className="text-lg font-semibold text-neutral-900">Akten</h1>
|
<h1 className="text-lg font-semibold text-neutral-900">Akten</h1>
|
||||||
|
|||||||
@@ -8,6 +8,8 @@ import { CaseOverviewGrid } from "@/components/dashboard/CaseOverviewGrid";
|
|||||||
import { UpcomingTimeline } from "@/components/dashboard/UpcomingTimeline";
|
import { UpcomingTimeline } from "@/components/dashboard/UpcomingTimeline";
|
||||||
import { AISummaryCard } from "@/components/dashboard/AISummaryCard";
|
import { AISummaryCard } from "@/components/dashboard/AISummaryCard";
|
||||||
import { QuickActions } from "@/components/dashboard/QuickActions";
|
import { QuickActions } from "@/components/dashboard/QuickActions";
|
||||||
|
import { RecentActivityList } from "@/components/dashboard/RecentActivityList";
|
||||||
|
import { Breadcrumb } from "@/components/layout/Breadcrumb";
|
||||||
import { Skeleton, SkeletonCard } from "@/components/ui/Skeleton";
|
import { Skeleton, SkeletonCard } from "@/components/ui/Skeleton";
|
||||||
import { AlertTriangle, RefreshCw } from "lucide-react";
|
import { AlertTriangle, RefreshCw } from "lucide-react";
|
||||||
|
|
||||||
@@ -71,9 +73,12 @@ export default function DashboardPage() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const recentActivity = Array.isArray(data.recent_activity) ? data.recent_activity : [];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="animate-fade-in mx-auto max-w-6xl space-y-6">
|
<div className="animate-fade-in mx-auto max-w-6xl space-y-6">
|
||||||
<div>
|
<div>
|
||||||
|
<Breadcrumb items={[{ label: "Dashboard" }]} />
|
||||||
<h1 className="text-lg font-semibold text-neutral-900">Dashboard</h1>
|
<h1 className="text-lg font-semibold text-neutral-900">Dashboard</h1>
|
||||||
<p className="mt-0.5 text-sm text-neutral-500">
|
<p className="mt-0.5 text-sm text-neutral-500">
|
||||||
Fristenübersicht und Kanzlei-Status
|
Fristenübersicht und Kanzlei-Status
|
||||||
@@ -91,10 +96,14 @@ export default function DashboardPage() {
|
|||||||
</div>
|
</div>
|
||||||
<div className="space-y-6">
|
<div className="space-y-6">
|
||||||
<CaseOverviewGrid data={data.case_summary ?? { active_count: 0, new_this_month: 0, closed_count: 0 }} />
|
<CaseOverviewGrid data={data.case_summary ?? { active_count: 0, new_this_month: 0, closed_count: 0 }} />
|
||||||
<AISummaryCard data={data} />
|
<AISummaryCard data={data} onRefresh={() => refetch()} />
|
||||||
<QuickActions />
|
<QuickActions />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{recentActivity.length > 0 && (
|
||||||
|
<RecentActivityList activities={recentActivity} />
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,16 +2,20 @@
|
|||||||
|
|
||||||
import { DeadlineList } from "@/components/deadlines/DeadlineList";
|
import { DeadlineList } from "@/components/deadlines/DeadlineList";
|
||||||
import { DeadlineCalendarView } from "@/components/deadlines/DeadlineCalendarView";
|
import { DeadlineCalendarView } from "@/components/deadlines/DeadlineCalendarView";
|
||||||
|
import { Breadcrumb } from "@/components/layout/Breadcrumb";
|
||||||
import { useQuery } from "@tanstack/react-query";
|
import { useQuery } from "@tanstack/react-query";
|
||||||
import { api } from "@/lib/api";
|
import { api } from "@/lib/api";
|
||||||
import type { Deadline } from "@/lib/types";
|
import type { Deadline } from "@/lib/types";
|
||||||
import { Calendar, List, Calculator } from "lucide-react";
|
import { Calendar, List, Calculator } from "lucide-react";
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
|
import { useSearchParams } from "next/navigation";
|
||||||
|
|
||||||
type ViewMode = "list" | "calendar";
|
type ViewMode = "list" | "calendar";
|
||||||
|
|
||||||
export default function FristenPage() {
|
export default function FristenPage() {
|
||||||
|
const searchParams = useSearchParams();
|
||||||
|
const initialStatus = searchParams.get("status") ?? undefined;
|
||||||
const [view, setView] = useState<ViewMode>("list");
|
const [view, setView] = useState<ViewMode>("list");
|
||||||
|
|
||||||
const { data: deadlines } = useQuery({
|
const { data: deadlines } = useQuery({
|
||||||
@@ -21,50 +25,58 @@ export default function FristenPage() {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="animate-fade-in space-y-4">
|
<div className="animate-fade-in space-y-4">
|
||||||
<div className="flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between">
|
<div>
|
||||||
<div>
|
<Breadcrumb
|
||||||
<h1 className="text-lg font-semibold text-neutral-900">Fristen</h1>
|
items={[
|
||||||
<p className="mt-0.5 text-sm text-neutral-500">
|
{ label: "Dashboard", href: "/dashboard" },
|
||||||
Alle Fristen im Überblick
|
{ label: "Fristen" },
|
||||||
</p>
|
]}
|
||||||
</div>
|
/>
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between">
|
||||||
<Link
|
<div>
|
||||||
href="/fristen/rechner"
|
<h1 className="text-lg font-semibold text-neutral-900">Fristen</h1>
|
||||||
className="flex items-center gap-1.5 rounded-md border border-neutral-200 bg-white px-3 py-1.5 text-sm text-neutral-700 transition-colors hover:bg-neutral-50"
|
<p className="mt-0.5 text-sm text-neutral-500">
|
||||||
>
|
Alle Fristen im Überblick
|
||||||
<Calculator className="h-3.5 w-3.5" />
|
</p>
|
||||||
Fristenrechner
|
</div>
|
||||||
</Link>
|
<div className="flex items-center gap-2">
|
||||||
<div className="flex rounded-md border border-neutral-200 bg-white">
|
<Link
|
||||||
<button
|
href="/fristen/rechner"
|
||||||
onClick={() => setView("list")}
|
className="flex items-center gap-1.5 rounded-md border border-neutral-200 bg-white px-3 py-1.5 text-sm text-neutral-700 transition-colors hover:bg-neutral-50"
|
||||||
className={`flex items-center gap-1 rounded-l-md px-2.5 py-1.5 text-sm transition-colors ${
|
|
||||||
view === "list"
|
|
||||||
? "bg-neutral-100 font-medium text-neutral-900"
|
|
||||||
: "text-neutral-500 hover:text-neutral-700"
|
|
||||||
}`}
|
|
||||||
>
|
>
|
||||||
<List className="h-3.5 w-3.5" />
|
<Calculator className="h-3.5 w-3.5" />
|
||||||
Liste
|
Fristenrechner
|
||||||
</button>
|
</Link>
|
||||||
<button
|
<div className="flex rounded-md border border-neutral-200 bg-white">
|
||||||
onClick={() => setView("calendar")}
|
<button
|
||||||
className={`flex items-center gap-1 rounded-r-md px-2.5 py-1.5 text-sm transition-colors ${
|
onClick={() => setView("list")}
|
||||||
view === "calendar"
|
className={`flex items-center gap-1 rounded-l-md px-2.5 py-1.5 text-sm transition-colors ${
|
||||||
? "bg-neutral-100 font-medium text-neutral-900"
|
view === "list"
|
||||||
: "text-neutral-500 hover:text-neutral-700"
|
? "bg-neutral-100 font-medium text-neutral-900"
|
||||||
}`}
|
: "text-neutral-500 hover:text-neutral-700"
|
||||||
>
|
}`}
|
||||||
<Calendar className="h-3.5 w-3.5" />
|
>
|
||||||
Kalender
|
<List className="h-3.5 w-3.5" />
|
||||||
</button>
|
Liste
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
onClick={() => setView("calendar")}
|
||||||
|
className={`flex items-center gap-1 rounded-r-md px-2.5 py-1.5 text-sm transition-colors ${
|
||||||
|
view === "calendar"
|
||||||
|
? "bg-neutral-100 font-medium text-neutral-900"
|
||||||
|
: "text-neutral-500 hover:text-neutral-700"
|
||||||
|
}`}
|
||||||
|
>
|
||||||
|
<Calendar className="h-3.5 w-3.5" />
|
||||||
|
Kalender
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{view === "list" ? (
|
{view === "list" ? (
|
||||||
<DeadlineList />
|
<DeadlineList initialStatus={initialStatus} />
|
||||||
) : (
|
) : (
|
||||||
<DeadlineCalendarView deadlines={Array.isArray(deadlines) ? deadlines : []} />
|
<DeadlineCalendarView deadlines={Array.isArray(deadlines) ? deadlines : []} />
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import { AppointmentModal } from "@/components/appointments/AppointmentModal";
|
|||||||
import { useQuery } from "@tanstack/react-query";
|
import { useQuery } from "@tanstack/react-query";
|
||||||
import { api } from "@/lib/api";
|
import { api } from "@/lib/api";
|
||||||
import type { Appointment } from "@/lib/types";
|
import type { Appointment } from "@/lib/types";
|
||||||
|
import { Breadcrumb } from "@/components/layout/Breadcrumb";
|
||||||
import { Calendar, List, Plus } from "lucide-react";
|
import { Calendar, List, Plus } from "lucide-react";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
|
|
||||||
@@ -38,6 +39,12 @@ export default function TerminePage() {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="space-y-4">
|
<div className="space-y-4">
|
||||||
|
<Breadcrumb
|
||||||
|
items={[
|
||||||
|
{ label: "Dashboard", href: "/dashboard" },
|
||||||
|
{ label: "Termine" },
|
||||||
|
]}
|
||||||
|
/>
|
||||||
<div className="flex items-center justify-between">
|
<div className="flex items-center justify-between">
|
||||||
<div>
|
<div>
|
||||||
<h1 className="text-lg font-semibold text-neutral-900">Termine</h1>
|
<h1 className="text-lg font-semibold text-neutral-900">Termine</h1>
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { Sparkles } from "lucide-react";
|
import { useState } from "react";
|
||||||
|
import { Sparkles, RefreshCw } from "lucide-react";
|
||||||
import type { DashboardData } from "@/lib/types";
|
import type { DashboardData } from "@/lib/types";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
data: DashboardData;
|
data: DashboardData;
|
||||||
|
onRefresh?: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
function generateSummary(data: DashboardData): string {
|
function generateSummary(data: DashboardData): string {
|
||||||
@@ -51,18 +53,39 @@ function generateSummary(data: DashboardData): string {
|
|||||||
return parts.join(" ");
|
return parts.join(" ");
|
||||||
}
|
}
|
||||||
|
|
||||||
export function AISummaryCard({ data }: Props) {
|
export function AISummaryCard({ data, onRefresh }: Props) {
|
||||||
|
const [spinning, setSpinning] = useState(false);
|
||||||
const summary = generateSummary(data);
|
const summary = generateSummary(data);
|
||||||
|
|
||||||
|
function handleRefresh() {
|
||||||
|
if (!onRefresh) return;
|
||||||
|
setSpinning(true);
|
||||||
|
onRefresh();
|
||||||
|
setTimeout(() => setSpinning(false), 1000);
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="rounded-xl border border-neutral-200 bg-white p-5">
|
<div className="rounded-xl border border-neutral-200 bg-white p-5">
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center justify-between">
|
||||||
<div className="rounded-md bg-violet-50 p-1.5">
|
<div className="flex items-center gap-2">
|
||||||
<Sparkles className="h-4 w-4 text-violet-500" />
|
<div className="rounded-md bg-violet-50 p-1.5">
|
||||||
|
<Sparkles className="h-4 w-4 text-violet-500" />
|
||||||
|
</div>
|
||||||
|
<h2 className="text-sm font-semibold text-neutral-900">
|
||||||
|
KI-Zusammenfassung
|
||||||
|
</h2>
|
||||||
</div>
|
</div>
|
||||||
<h2 className="text-sm font-semibold text-neutral-900">
|
{onRefresh && (
|
||||||
KI-Zusammenfassung
|
<button
|
||||||
</h2>
|
onClick={handleRefresh}
|
||||||
|
title="Aktualisieren"
|
||||||
|
className="rounded-md p-1.5 text-neutral-400 transition-colors hover:bg-neutral-100 hover:text-neutral-600"
|
||||||
|
>
|
||||||
|
<RefreshCw
|
||||||
|
className={`h-4 w-4 ${spinning ? "animate-spin" : ""}`}
|
||||||
|
/>
|
||||||
|
</button>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
<p className="mt-3 text-sm leading-relaxed text-neutral-700">
|
<p className="mt-3 text-sm leading-relaxed text-neutral-700">
|
||||||
{summary}
|
{summary}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { FolderOpen, FolderPlus, Archive } from "lucide-react";
|
import Link from "next/link";
|
||||||
|
import { FolderOpen, FolderPlus, Archive, ChevronRight } from "lucide-react";
|
||||||
import type { CaseSummary } from "@/lib/types";
|
import type { CaseSummary } from "@/lib/types";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
@@ -16,6 +17,7 @@ export function CaseOverviewGrid({ data }: Props) {
|
|||||||
icon: FolderOpen,
|
icon: FolderOpen,
|
||||||
color: "text-blue-600",
|
color: "text-blue-600",
|
||||||
bg: "bg-blue-50",
|
bg: "bg-blue-50",
|
||||||
|
href: "/cases?status=active",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "Neu (Monat)",
|
label: "Neu (Monat)",
|
||||||
@@ -23,6 +25,7 @@ export function CaseOverviewGrid({ data }: Props) {
|
|||||||
icon: FolderPlus,
|
icon: FolderPlus,
|
||||||
color: "text-violet-600",
|
color: "text-violet-600",
|
||||||
bg: "bg-violet-50",
|
bg: "bg-violet-50",
|
||||||
|
href: "/cases?status=active&since=month",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "Abgeschlossen",
|
label: "Abgeschlossen",
|
||||||
@@ -30,25 +33,33 @@ export function CaseOverviewGrid({ data }: Props) {
|
|||||||
icon: Archive,
|
icon: Archive,
|
||||||
color: "text-neutral-500",
|
color: "text-neutral-500",
|
||||||
bg: "bg-neutral-50",
|
bg: "bg-neutral-50",
|
||||||
|
href: "/cases?status=closed",
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="rounded-xl border border-neutral-200 bg-white p-5">
|
<div className="rounded-xl border border-neutral-200 bg-white p-5">
|
||||||
<h2 className="text-sm font-semibold text-neutral-900">Aktenübersicht</h2>
|
<h2 className="text-sm font-semibold text-neutral-900">Aktenübersicht</h2>
|
||||||
<div className="mt-4 space-y-3">
|
<div className="mt-4 space-y-1">
|
||||||
{items.map((item) => (
|
{items.map((item) => (
|
||||||
<div key={item.label} className="flex items-center justify-between">
|
<Link
|
||||||
|
key={item.label}
|
||||||
|
href={item.href}
|
||||||
|
className="group -mx-2 flex items-center justify-between rounded-lg px-2 py-2 transition-colors hover:bg-neutral-50"
|
||||||
|
>
|
||||||
<div className="flex items-center gap-2.5">
|
<div className="flex items-center gap-2.5">
|
||||||
<div className={`rounded-md p-1.5 ${item.bg}`}>
|
<div className={`rounded-md p-1.5 ${item.bg}`}>
|
||||||
<item.icon className={`h-4 w-4 ${item.color}`} />
|
<item.icon className={`h-4 w-4 ${item.color}`} />
|
||||||
</div>
|
</div>
|
||||||
<span className="text-sm text-neutral-600">{item.label}</span>
|
<span className="text-sm text-neutral-600">{item.label}</span>
|
||||||
</div>
|
</div>
|
||||||
<span className="text-lg font-semibold tabular-nums text-neutral-900">
|
<div className="flex items-center gap-1.5">
|
||||||
{item.value}
|
<span className="text-lg font-semibold tabular-nums text-neutral-900">
|
||||||
</span>
|
{item.value}
|
||||||
</div>
|
</span>
|
||||||
|
<ChevronRight className="h-4 w-4 text-neutral-300 transition-colors group-hover:text-neutral-500" />
|
||||||
|
</div>
|
||||||
|
</Link>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { useEffect, useRef } from "react";
|
import { useEffect, useRef } from "react";
|
||||||
|
import Link from "next/link";
|
||||||
import { AlertTriangle, Clock, CheckCircle } from "lucide-react";
|
import { AlertTriangle, Clock, CheckCircle } from "lucide-react";
|
||||||
import type { DeadlineSummary } from "@/lib/types";
|
import type { DeadlineSummary } from "@/lib/types";
|
||||||
|
|
||||||
@@ -27,10 +28,9 @@ function AnimatedCount({ value }: { value: number }) {
|
|||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
data: DeadlineSummary;
|
data: DeadlineSummary;
|
||||||
onFilter?: (filter: "overdue" | "this_week" | "ok") => void;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function DeadlineTrafficLights({ data, onFilter }: Props) {
|
export function DeadlineTrafficLights({ data }: Props) {
|
||||||
const safe = data ?? { overdue_count: 0, due_this_week: 0, due_next_week: 0, ok_count: 0 };
|
const safe = data ?? { overdue_count: 0, due_this_week: 0, due_next_week: 0, ok_count: 0 };
|
||||||
const cards = [
|
const cards = [
|
||||||
{
|
{
|
||||||
@@ -38,6 +38,7 @@ export function DeadlineTrafficLights({ data, onFilter }: Props) {
|
|||||||
label: "Überfällig",
|
label: "Überfällig",
|
||||||
count: safe.overdue_count ?? 0,
|
count: safe.overdue_count ?? 0,
|
||||||
icon: AlertTriangle,
|
icon: AlertTriangle,
|
||||||
|
href: "/fristen?status=overdue",
|
||||||
bg: "bg-red-50",
|
bg: "bg-red-50",
|
||||||
border: "border-red-200",
|
border: "border-red-200",
|
||||||
iconColor: "text-red-500",
|
iconColor: "text-red-500",
|
||||||
@@ -51,6 +52,7 @@ export function DeadlineTrafficLights({ data, onFilter }: Props) {
|
|||||||
label: "Diese Woche",
|
label: "Diese Woche",
|
||||||
count: safe.due_this_week ?? 0,
|
count: safe.due_this_week ?? 0,
|
||||||
icon: Clock,
|
icon: Clock,
|
||||||
|
href: "/fristen?status=this_week",
|
||||||
bg: "bg-amber-50",
|
bg: "bg-amber-50",
|
||||||
border: "border-amber-200",
|
border: "border-amber-200",
|
||||||
iconColor: "text-amber-500",
|
iconColor: "text-amber-500",
|
||||||
@@ -64,6 +66,7 @@ export function DeadlineTrafficLights({ data, onFilter }: Props) {
|
|||||||
label: "Im Zeitplan",
|
label: "Im Zeitplan",
|
||||||
count: (safe.ok_count ?? 0) + (safe.due_next_week ?? 0),
|
count: (safe.ok_count ?? 0) + (safe.due_next_week ?? 0),
|
||||||
icon: CheckCircle,
|
icon: CheckCircle,
|
||||||
|
href: "/fristen?status=ok",
|
||||||
bg: "bg-emerald-50",
|
bg: "bg-emerald-50",
|
||||||
border: "border-emerald-200",
|
border: "border-emerald-200",
|
||||||
iconColor: "text-emerald-500",
|
iconColor: "text-emerald-500",
|
||||||
@@ -77,9 +80,9 @@ export function DeadlineTrafficLights({ data, onFilter }: Props) {
|
|||||||
return (
|
return (
|
||||||
<div className="grid grid-cols-1 gap-4 sm:grid-cols-3">
|
<div className="grid grid-cols-1 gap-4 sm:grid-cols-3">
|
||||||
{cards.map((card) => (
|
{cards.map((card) => (
|
||||||
<button
|
<Link
|
||||||
key={card.key}
|
key={card.key}
|
||||||
onClick={() => onFilter?.(card.key)}
|
href={card.href}
|
||||||
className={`group relative overflow-hidden rounded-xl border ${card.border} ${card.bg} ${card.ring} p-6 text-left transition-all hover:shadow-md active:scale-[0.98]`}
|
className={`group relative overflow-hidden rounded-xl border ${card.border} ${card.bg} ${card.ring} p-6 text-left transition-all hover:shadow-md active:scale-[0.98]`}
|
||||||
>
|
>
|
||||||
{card.pulse && (
|
{card.pulse && (
|
||||||
@@ -99,7 +102,7 @@ export function DeadlineTrafficLights({ data, onFilter }: Props) {
|
|||||||
<div className={`mt-4 text-4xl font-bold tracking-tight ${card.countColor}`}>
|
<div className={`mt-4 text-4xl font-bold tracking-tight ${card.countColor}`}>
|
||||||
<AnimatedCount value={card.count} />
|
<AnimatedCount value={card.count} />
|
||||||
</div>
|
</div>
|
||||||
</button>
|
</Link>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import { FolderPlus, Clock, Sparkles, CalendarSync } from "lucide-react";
|
import { FolderPlus, Clock, Sparkles, CalendarPlus } from "lucide-react";
|
||||||
|
|
||||||
const actions = [
|
const actions = [
|
||||||
{
|
{
|
||||||
@@ -12,22 +12,22 @@ const actions = [
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "Frist eintragen",
|
label: "Frist eintragen",
|
||||||
href: "/fristen",
|
href: "/fristen/neu",
|
||||||
icon: Clock,
|
icon: Clock,
|
||||||
color: "text-amber-600 bg-amber-50 hover:bg-amber-100",
|
color: "text-amber-600 bg-amber-50 hover:bg-amber-100",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
label: "Neuer Termin",
|
||||||
|
href: "/termine/neu",
|
||||||
|
icon: CalendarPlus,
|
||||||
|
color: "text-emerald-600 bg-emerald-50 hover:bg-emerald-100",
|
||||||
|
},
|
||||||
{
|
{
|
||||||
label: "AI Analyse",
|
label: "AI Analyse",
|
||||||
href: "/ai/extract",
|
href: "/ai/extract",
|
||||||
icon: Sparkles,
|
icon: Sparkles,
|
||||||
color: "text-violet-600 bg-violet-50 hover:bg-violet-100",
|
color: "text-violet-600 bg-violet-50 hover:bg-violet-100",
|
||||||
},
|
},
|
||||||
{
|
|
||||||
label: "CalDAV Sync",
|
|
||||||
href: "/einstellungen",
|
|
||||||
icon: CalendarSync,
|
|
||||||
color: "text-emerald-600 bg-emerald-50 hover:bg-emerald-100",
|
|
||||||
},
|
|
||||||
];
|
];
|
||||||
|
|
||||||
export function QuickActions() {
|
export function QuickActions() {
|
||||||
|
|||||||
80
frontend/src/components/dashboard/RecentActivityList.tsx
Normal file
80
frontend/src/components/dashboard/RecentActivityList.tsx
Normal file
@@ -0,0 +1,80 @@
|
|||||||
|
"use client";
|
||||||
|
|
||||||
|
import Link from "next/link";
|
||||||
|
import { formatDistanceToNow, parseISO } from "date-fns";
|
||||||
|
import { de } from "date-fns/locale";
|
||||||
|
import {
|
||||||
|
FileText,
|
||||||
|
Scale,
|
||||||
|
Calendar,
|
||||||
|
Clock,
|
||||||
|
MessageSquare,
|
||||||
|
ChevronRight,
|
||||||
|
} from "lucide-react";
|
||||||
|
import type { RecentActivity } from "@/lib/types";
|
||||||
|
|
||||||
|
const EVENT_ICONS: Record<string, typeof FileText> = {
|
||||||
|
status_changed: Scale,
|
||||||
|
deadline_created: Clock,
|
||||||
|
appointment_created: Calendar,
|
||||||
|
document_uploaded: FileText,
|
||||||
|
note_added: MessageSquare,
|
||||||
|
};
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
activities: RecentActivity[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export function RecentActivityList({ activities }: Props) {
|
||||||
|
const safe = Array.isArray(activities) ? activities : [];
|
||||||
|
|
||||||
|
if (safe.length === 0) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="rounded-xl border border-neutral-200 bg-white p-5">
|
||||||
|
<h2 className="text-sm font-semibold text-neutral-900">
|
||||||
|
Letzte Aktivität
|
||||||
|
</h2>
|
||||||
|
<div className="mt-3 divide-y divide-neutral-100">
|
||||||
|
{safe.map((activity) => {
|
||||||
|
const Icon = EVENT_ICONS[activity.event_type ?? ""] ?? FileText;
|
||||||
|
const timeAgo = activity.created_at
|
||||||
|
? formatDistanceToNow(parseISO(activity.created_at), {
|
||||||
|
addSuffix: true,
|
||||||
|
locale: de,
|
||||||
|
})
|
||||||
|
: "";
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Link
|
||||||
|
key={activity.id}
|
||||||
|
href={`/cases/${activity.case_id}`}
|
||||||
|
className="group flex items-center gap-3 py-2.5 transition-colors first:pt-0 last:pb-0 hover:bg-neutral-50 -mx-5 px-5"
|
||||||
|
>
|
||||||
|
<div className="rounded-md bg-neutral-100 p-1.5">
|
||||||
|
<Icon className="h-3.5 w-3.5 text-neutral-500" />
|
||||||
|
</div>
|
||||||
|
<div className="min-w-0 flex-1">
|
||||||
|
<p className="truncate text-sm text-neutral-900">
|
||||||
|
{activity.title}
|
||||||
|
</p>
|
||||||
|
<div className="flex items-center gap-2 text-xs text-neutral-500">
|
||||||
|
<span>{activity.case_number}</span>
|
||||||
|
{timeAgo && (
|
||||||
|
<>
|
||||||
|
<span className="text-neutral-300">·</span>
|
||||||
|
<span>{timeAgo}</span>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<ChevronRight className="h-4 w-4 shrink-0 text-neutral-300 transition-colors group-hover:text-neutral-500" />
|
||||||
|
</Link>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -1,8 +1,9 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
|
import Link from "next/link";
|
||||||
import { format, parseISO, isToday, isTomorrow } from "date-fns";
|
import { format, parseISO, isToday, isTomorrow } from "date-fns";
|
||||||
import { de } from "date-fns/locale";
|
import { de } from "date-fns/locale";
|
||||||
import { Clock, Calendar, MapPin } from "lucide-react";
|
import { Clock, Calendar, MapPin, ChevronRight } from "lucide-react";
|
||||||
import type { UpcomingDeadline, UpcomingAppointment } from "@/lib/types";
|
import type { UpcomingDeadline, UpcomingAppointment } from "@/lib/types";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
@@ -80,8 +81,12 @@ export function UpcomingTimeline({ deadlines, appointments }: Props) {
|
|||||||
function TimelineEntry({ item }: { item: TimelineItem }) {
|
function TimelineEntry({ item }: { item: TimelineItem }) {
|
||||||
if (item.type === "deadline") {
|
if (item.type === "deadline") {
|
||||||
const d = item.data;
|
const d = item.data;
|
||||||
|
const href = `/fristen/${d.id}`;
|
||||||
return (
|
return (
|
||||||
<div className="flex items-start gap-3 rounded-lg border border-neutral-100 bg-neutral-50/50 px-3 py-2.5">
|
<Link
|
||||||
|
href={href}
|
||||||
|
className="group flex items-start gap-3 rounded-lg border border-neutral-100 bg-neutral-50/50 px-3 py-2.5 transition-colors hover:border-neutral-200 hover:bg-neutral-100/50"
|
||||||
|
>
|
||||||
<div className="mt-0.5 rounded-md bg-amber-50 p-1">
|
<div className="mt-0.5 rounded-md bg-amber-50 p-1">
|
||||||
<Clock className="h-3.5 w-3.5 text-amber-500" />
|
<Clock className="h-3.5 w-3.5 text-amber-500" />
|
||||||
</div>
|
</div>
|
||||||
@@ -90,19 +95,40 @@ function TimelineEntry({ item }: { item: TimelineItem }) {
|
|||||||
{d.title}
|
{d.title}
|
||||||
</p>
|
</p>
|
||||||
<p className="mt-0.5 truncate text-xs text-neutral-500">
|
<p className="mt-0.5 truncate text-xs text-neutral-500">
|
||||||
{d.case_number} · {d.case_title}
|
{d.case_id ? (
|
||||||
|
<span
|
||||||
|
onClick={(e) => e.stopPropagation()}
|
||||||
|
className="inline"
|
||||||
|
>
|
||||||
|
<Link
|
||||||
|
href={`/cases/${d.case_id}`}
|
||||||
|
className="underline decoration-neutral-300 hover:text-neutral-900 hover:decoration-neutral-500"
|
||||||
|
>
|
||||||
|
{d.case_number}
|
||||||
|
</Link>
|
||||||
|
{" · "}
|
||||||
|
</span>
|
||||||
|
) : (
|
||||||
|
<>{d.case_number} · </>
|
||||||
|
)}
|
||||||
|
{d.case_title}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<span className="shrink-0 text-xs font-medium text-amber-600">
|
<div className="flex shrink-0 items-center gap-1.5">
|
||||||
Frist
|
<span className="text-xs font-medium text-amber-600">Frist</span>
|
||||||
</span>
|
<ChevronRight className="h-3.5 w-3.5 text-neutral-300 transition-colors group-hover:text-neutral-500" />
|
||||||
</div>
|
</div>
|
||||||
|
</Link>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const a = item.data;
|
const a = item.data;
|
||||||
|
const href = `/termine/${a.id}`;
|
||||||
return (
|
return (
|
||||||
<div className="flex items-start gap-3 rounded-lg border border-neutral-100 bg-neutral-50/50 px-3 py-2.5">
|
<Link
|
||||||
|
href={href}
|
||||||
|
className="group flex items-start gap-3 rounded-lg border border-neutral-100 bg-neutral-50/50 px-3 py-2.5 transition-colors hover:border-neutral-200 hover:bg-neutral-100/50"
|
||||||
|
>
|
||||||
<div className="mt-0.5 rounded-md bg-blue-50 p-1">
|
<div className="mt-0.5 rounded-md bg-blue-50 p-1">
|
||||||
<Calendar className="h-3.5 w-3.5 text-blue-500" />
|
<Calendar className="h-3.5 w-3.5 text-blue-500" />
|
||||||
</div>
|
</div>
|
||||||
@@ -121,7 +147,20 @@ function TimelineEntry({ item }: { item: TimelineItem }) {
|
|||||||
</span>
|
</span>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
{a.case_number && (
|
{a.case_number && a.case_id && (
|
||||||
|
<>
|
||||||
|
<span className="text-neutral-300">·</span>
|
||||||
|
<span onClick={(e) => e.stopPropagation()}>
|
||||||
|
<Link
|
||||||
|
href={`/cases/${a.case_id}`}
|
||||||
|
className="underline decoration-neutral-300 hover:text-neutral-900 hover:decoration-neutral-500"
|
||||||
|
>
|
||||||
|
{a.case_number}
|
||||||
|
</Link>
|
||||||
|
</span>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
{a.case_number && !a.case_id && (
|
||||||
<>
|
<>
|
||||||
<span className="text-neutral-300">·</span>
|
<span className="text-neutral-300">·</span>
|
||||||
<span>{a.case_number}</span>
|
<span>{a.case_number}</span>
|
||||||
@@ -129,9 +168,10 @@ function TimelineEntry({ item }: { item: TimelineItem }) {
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<span className="shrink-0 text-xs font-medium text-blue-600">
|
<div className="flex shrink-0 items-center gap-1.5">
|
||||||
Termin
|
<span className="text-xs font-medium text-blue-600">Termin</span>
|
||||||
</span>
|
<ChevronRight className="h-3.5 w-3.5 text-neutral-300 transition-colors group-hover:text-neutral-500" />
|
||||||
</div>
|
</div>
|
||||||
|
</Link>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,14 @@ import { toast } from "sonner";
|
|||||||
import { useState, useMemo } from "react";
|
import { useState, useMemo } from "react";
|
||||||
import { EmptyState } from "@/components/ui/EmptyState";
|
import { EmptyState } from "@/components/ui/EmptyState";
|
||||||
|
|
||||||
type StatusFilter = "all" | "pending" | "completed" | "overdue";
|
type StatusFilter = "all" | "pending" | "completed" | "overdue" | "this_week" | "ok";
|
||||||
|
|
||||||
|
function mapUrlStatus(status?: string): StatusFilter {
|
||||||
|
if (status === "overdue") return "overdue";
|
||||||
|
if (status === "this_week") return "this_week";
|
||||||
|
if (status === "ok") return "ok";
|
||||||
|
return "all";
|
||||||
|
}
|
||||||
|
|
||||||
function getUrgency(deadline: Deadline): "red" | "amber" | "green" {
|
function getUrgency(deadline: Deadline): "red" | "amber" | "green" {
|
||||||
if (deadline.status === "completed") return "green";
|
if (deadline.status === "completed") return "green";
|
||||||
@@ -47,9 +54,15 @@ const urgencyConfig = {
|
|||||||
const selectClass =
|
const selectClass =
|
||||||
"rounded-md border border-neutral-200 bg-white px-2.5 py-1 text-sm text-neutral-700 transition-colors focus:border-neutral-400 focus:ring-1 focus:ring-neutral-400 outline-none";
|
"rounded-md border border-neutral-200 bg-white px-2.5 py-1 text-sm text-neutral-700 transition-colors focus:border-neutral-400 focus:ring-1 focus:ring-neutral-400 outline-none";
|
||||||
|
|
||||||
export function DeadlineList() {
|
interface Props {
|
||||||
|
initialStatus?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function DeadlineList({ initialStatus }: Props) {
|
||||||
const queryClient = useQueryClient();
|
const queryClient = useQueryClient();
|
||||||
const [statusFilter, setStatusFilter] = useState<StatusFilter>("all");
|
const [statusFilter, setStatusFilter] = useState<StatusFilter>(
|
||||||
|
mapUrlStatus(initialStatus),
|
||||||
|
);
|
||||||
const [caseFilter, setCaseFilter] = useState<string>("all");
|
const [caseFilter, setCaseFilter] = useState<string>("all");
|
||||||
|
|
||||||
const { data: deadlines, isLoading } = useQuery({
|
const { data: deadlines, isLoading } = useQuery({
|
||||||
@@ -90,6 +103,18 @@ export function DeadlineList() {
|
|||||||
if (d.status === "completed") return false;
|
if (d.status === "completed") return false;
|
||||||
if (!isPast(parseISO(d.due_date))) return false;
|
if (!isPast(parseISO(d.due_date))) return false;
|
||||||
}
|
}
|
||||||
|
if (statusFilter === "this_week") {
|
||||||
|
if (d.status === "completed") return false;
|
||||||
|
const due = parseISO(d.due_date);
|
||||||
|
if (isPast(due)) return false;
|
||||||
|
if (!isThisWeek(due, { weekStartsOn: 1 })) return false;
|
||||||
|
}
|
||||||
|
if (statusFilter === "ok") {
|
||||||
|
if (d.status === "completed") return false;
|
||||||
|
const due = parseISO(d.due_date);
|
||||||
|
if (isPast(due)) return false;
|
||||||
|
if (isThisWeek(due, { weekStartsOn: 1 })) return false;
|
||||||
|
}
|
||||||
if (caseFilter !== "all" && d.case_id !== caseFilter) return false;
|
if (caseFilter !== "all" && d.case_id !== caseFilter) return false;
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
@@ -144,10 +169,10 @@ export function DeadlineList() {
|
|||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
onClick={() =>
|
onClick={() =>
|
||||||
setStatusFilter(statusFilter === "pending" ? "all" : "pending")
|
setStatusFilter(statusFilter === "this_week" ? "all" : "this_week")
|
||||||
}
|
}
|
||||||
className={`rounded-lg border p-3 text-left transition-all ${
|
className={`rounded-lg border p-3 text-left transition-all ${
|
||||||
statusFilter === "pending"
|
statusFilter === "this_week"
|
||||||
? "border-amber-300 bg-amber-50 ring-1 ring-amber-200"
|
? "border-amber-300 bg-amber-50 ring-1 ring-amber-200"
|
||||||
: "border-neutral-200 bg-white hover:bg-neutral-50"
|
: "border-neutral-200 bg-white hover:bg-neutral-50"
|
||||||
}`}
|
}`}
|
||||||
@@ -158,9 +183,11 @@ export function DeadlineList() {
|
|||||||
<div className="text-xs text-neutral-500">Diese Woche</div>
|
<div className="text-xs text-neutral-500">Diese Woche</div>
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
onClick={() => setStatusFilter("all")}
|
onClick={() =>
|
||||||
|
setStatusFilter(statusFilter === "ok" ? "all" : "ok")
|
||||||
|
}
|
||||||
className={`rounded-lg border p-3 text-left transition-all ${
|
className={`rounded-lg border p-3 text-left transition-all ${
|
||||||
statusFilter === "all"
|
statusFilter === "ok"
|
||||||
? "border-green-300 bg-green-50 ring-1 ring-green-200"
|
? "border-green-300 bg-green-50 ring-1 ring-green-200"
|
||||||
: "border-neutral-200 bg-white hover:bg-neutral-50"
|
: "border-neutral-200 bg-white hover:bg-neutral-50"
|
||||||
}`}
|
}`}
|
||||||
@@ -187,6 +214,8 @@ export function DeadlineList() {
|
|||||||
<option value="pending">Offen</option>
|
<option value="pending">Offen</option>
|
||||||
<option value="completed">Erledigt</option>
|
<option value="completed">Erledigt</option>
|
||||||
<option value="overdue">Überfällig</option>
|
<option value="overdue">Überfällig</option>
|
||||||
|
<option value="this_week">Diese Woche</option>
|
||||||
|
<option value="ok">Im Zeitplan</option>
|
||||||
</select>
|
</select>
|
||||||
{Array.isArray(cases) && cases.length > 0 && (
|
{Array.isArray(cases) && cases.length > 0 && (
|
||||||
<select
|
<select
|
||||||
|
|||||||
@@ -6,24 +6,33 @@ export interface BreadcrumbItem {
|
|||||||
href?: string;
|
href?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function Breadcrumb({ items }: { items: BreadcrumbItem[] }) {
|
interface Props {
|
||||||
|
items: BreadcrumbItem[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export function Breadcrumb({ items }: Props) {
|
||||||
return (
|
return (
|
||||||
<nav className="mb-4 flex items-center gap-1 text-sm text-neutral-500">
|
<nav aria-label="Breadcrumb" className="mb-4 flex items-center gap-1 text-sm text-neutral-500">
|
||||||
{items.map((item, i) => (
|
{items.map((item, i) => {
|
||||||
<span key={i} className="flex items-center gap-1">
|
const isLast = i === items.length - 1;
|
||||||
{i > 0 && <ChevronRight className="h-3.5 w-3.5 text-neutral-300" />}
|
return (
|
||||||
{item.href ? (
|
<span key={i} className="flex items-center gap-1">
|
||||||
<Link
|
{i > 0 && <ChevronRight className="h-3.5 w-3.5 text-neutral-300" />}
|
||||||
href={item.href}
|
{isLast || !item.href ? (
|
||||||
className="transition-colors hover:text-neutral-700"
|
<span className={isLast ? "font-medium text-neutral-900" : ""}>
|
||||||
>
|
{item.label}
|
||||||
{item.label}
|
</span>
|
||||||
</Link>
|
) : (
|
||||||
) : (
|
<Link
|
||||||
<span className="font-medium text-neutral-900">{item.label}</span>
|
href={item.href}
|
||||||
)}
|
className="transition-colors hover:text-neutral-900"
|
||||||
</span>
|
>
|
||||||
))}
|
{item.label}
|
||||||
|
</Link>
|
||||||
|
)}
|
||||||
|
</span>
|
||||||
|
);
|
||||||
|
})}
|
||||||
</nav>
|
</nav>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -176,6 +176,19 @@ export interface CalDAVSyncResponse {
|
|||||||
last_sync_at?: null;
|
last_sync_at?: null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface Note {
|
||||||
|
id: string;
|
||||||
|
tenant_id: string;
|
||||||
|
case_id?: string;
|
||||||
|
deadline_id?: string;
|
||||||
|
appointment_id?: string;
|
||||||
|
case_event_id?: string;
|
||||||
|
content: string;
|
||||||
|
created_by?: string;
|
||||||
|
created_at: string;
|
||||||
|
updated_at: string;
|
||||||
|
}
|
||||||
|
|
||||||
export interface ApiError {
|
export interface ApiError {
|
||||||
error: string;
|
error: string;
|
||||||
status: number;
|
status: number;
|
||||||
@@ -223,11 +236,22 @@ export interface UpcomingAppointment {
|
|||||||
case_title?: string;
|
case_title?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface RecentActivity {
|
||||||
|
id: string;
|
||||||
|
event_type?: string;
|
||||||
|
title: string;
|
||||||
|
case_id: string;
|
||||||
|
case_number: string;
|
||||||
|
event_date?: string;
|
||||||
|
created_at: string;
|
||||||
|
}
|
||||||
|
|
||||||
export interface DashboardData {
|
export interface DashboardData {
|
||||||
deadline_summary: DeadlineSummary;
|
deadline_summary: DeadlineSummary;
|
||||||
case_summary: CaseSummary;
|
case_summary: CaseSummary;
|
||||||
upcoming_deadlines: UpcomingDeadline[];
|
upcoming_deadlines: UpcomingDeadline[];
|
||||||
upcoming_appointments: UpcomingAppointment[];
|
upcoming_appointments: UpcomingAppointment[];
|
||||||
|
recent_activity?: RecentActivity[];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Notes
|
// Notes
|
||||||
|
|||||||
Reference in New Issue
Block a user