diff --git a/src/pages/AssignProjectPage.jsx b/src/pages/AssignProjectPage.jsx index bea7f9a..998b88c 100644 --- a/src/pages/AssignProjectPage.jsx +++ b/src/pages/AssignProjectPage.jsx @@ -1,6 +1,5 @@ import { useState, useEffect, useMemo, useCallback } from 'react' import { Link, useNavigate, useParams } from 'react-router-dom' -import { FaSpinner, FaPlus, FaArrowLeft, FaArrowRight, FaCheck } from 'react-icons/fa6' import { useCustomers } from '../hooks/useCustomers' import { useAuth } from '../context/AuthContext' import { databases, DATABASE_ID, COLLECTIONS, Query } from '../lib/appwrite' @@ -9,7 +8,7 @@ import { nextStep, prevStep, newTicketDefaults, canFinish, openTicketsFor } from import { suggestSubdomain, slugify } from '../lib/subdomain' import { isArchived } from '../lib/leads' import { ticketPath, ticketRef } from '../lib/ticketRoutes' -import { PageHeader, Card, Button, Field } from '../components/ui' +import { PageHeader, Card, Button, Field, Badge } from '../components/ui' import { CreateCustomerForm } from './CustomersPage' const todayIso = () => new Date().toLocaleDateString('sv-SE', { timeZone: 'Europe/Berlin' }) @@ -176,36 +175,45 @@ export default function AssignProjectPage() { } } - if (loading) return
+ if (loading) return
Wird geladen …
if (loadError) { return (
- -
{loadError}
+ +

{loadError}

) } + const createdLine = project.$createdAt && ( + <> · angelegt am {fmtDate(project.$createdAt)}{project.createdByGitea ? ` von ${project.createdByGitea}` : ''} + ) const header = ( - -
{repoName || project.projectName}
-
- {repoUrl && Repository in Gitea öffnen} - {project.$createdAt && <> · angelegt am {fmtDate(project.$createdAt)}{project.createdByGitea ? ` von ${project.createdByGitea}` : ''}} -
-
+ + {repoUrl && Repository in Gitea öffnen} + {createdLine} + + ) : undefined} + /> ) if (done) { return (
- {header} -
    - {done.warnings.map((w, i) =>
  • {w}
  • )} -
- +
+
    + {done.warnings.map((w, i) =>
  • {w}
  • )} +
+
+ +
+
) @@ -215,16 +223,15 @@ export default function AssignProjectPage() { if (project.kind) { return (
- {header} - {notice &&
{notice}
} -

- Bereits erledigt von {project.kindSetBy || 'unbekannt'} am {fmtDate(project.kindSetAt)}. -

- {project.ticketId && ( -

- )} +
+ {notice &&

{notice}

} +

+ Bereits erledigt von {project.kindSetBy || 'unbekannt'} am {fmtDate(project.kindSetAt)}. +

+ {project.ticketId &&

} +
) @@ -236,159 +243,172 @@ export default function AssignProjectPage() { return (
- {header} - {state.step === 'kind' && ( -
- {kinds.map((k) => ( - - ))} -
- )} - - {state.step === 'customer?' && ( -
- - -
- )} - - {state.step === 'customer' && ( - <> -
- setSearch(e.target.value)} style={{ maxWidth: 320 }} /> - {isAdmin && ( - - )} -
- {showNewCustomer && isAdmin && ( - setShowNewCustomer(false)} - onCreate={async (data) => { - const r = await createCustomer(data) - if (r.success) { - setShowNewCustomer(false) - patch({ customerId: r.data.$id, ticketId: '', newTicket: null }) - } - return r - }} - /> - )} -
- {filteredCustomers.slice(0, 100).map((c) => ( -
patch({ customerId: c.$id, ticketId: '', newTicket: null })}> -
-
{c.name}{c.code && · {c.code}}
-
{[c.location, c.email].filter(Boolean).join(' · ') || '-'}
-
- {state.customerId === c.$id && } -
+
+ {state.step === 'kind' && ( +
+ {kinds.map((k) => ( + ))} - {filteredCustomers.length === 0 &&
Kein Kunde gefunden.
}
- - )} + )} - {state.step === 'ticket' && ( - <> - {ticketsLoading ? : ticketsError ? ( -
-
Die Tickets des Kunden konnten nicht geladen werden.
- -
- ) : ( -
- {openTickets.map((t) => ( -
patch({ ticketId: t.$id, newTicket: null })}> -
-
#{t.woid} {t.topic}
-
{[t.type, t.status].filter(Boolean).join(' · ')}
-
- {state.ticketId === t.$id && } -
- ))} - {openTickets.length === 0 &&
Dieser Kunde hat keine offenen Tickets.
} -
- )} - {!ticketsError && !ticketsLoading && ( - - )} - {state.newTicket && ( -
-
- - - -
-