feat: add delete customer + fix auth form UX
- Backend: DELETE /api/customers/:id removes customer + extensions + logs - Frontend: delete button on customer detail with confirmation - Auth form: only sends espocrm_api_key when credentials are entered Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
+13
-2
@@ -107,6 +107,12 @@ function CustomersTab() {
|
||||
const [selected, setSelected] = useState(null)
|
||||
const [showForm, setShowForm] = useState(false)
|
||||
|
||||
const deleteCustomer = async (id) => {
|
||||
await fetch(`${API}/customers/${id}`, { method: 'DELETE' })
|
||||
if (selected === id) setSelected(null)
|
||||
reload()
|
||||
}
|
||||
|
||||
if (!customers) return <Loader />
|
||||
return (
|
||||
<div className="flex gap-6">
|
||||
@@ -143,7 +149,7 @@ function CustomersTab() {
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex-1 min-w-0">
|
||||
{selected ? <CustomerDetail customerId={selected} /> : (
|
||||
{selected ? <CustomerDetail customerId={selected} onDelete={() => deleteCustomer(selected)} /> : (
|
||||
<div className="bg-white rounded-xl p-12 text-center text-slate-400">
|
||||
<Icon name="touch_app" className="text-5xl mb-4 block" />
|
||||
<p className="font-medium">בחר לקוח מהרשימה</p>
|
||||
@@ -226,7 +232,7 @@ function CustomerForm({ onDone, onCancel, customer }) {
|
||||
)
|
||||
}
|
||||
|
||||
function CustomerDetail({ customerId }) {
|
||||
function CustomerDetail({ customerId, onDelete }) {
|
||||
const { data: customer, reload } = useFetch(`${API}/customers/${customerId}`)
|
||||
const { data: allExtensions } = useFetch(`${API}/extensions`)
|
||||
const [deploying, setDeploying] = useState(null)
|
||||
@@ -366,6 +372,11 @@ function CustomerDetail({ customerId }) {
|
||||
title="עריכת לקוח">
|
||||
<Icon name="edit" className="text-lg" />
|
||||
</button>
|
||||
<button onClick={() => { if (confirm('למחוק את הלקוח לצמיתות?')) onDelete() }}
|
||||
className="p-2 text-slate-400 hover:text-red-600 hover:bg-red-50 rounded-lg transition-all"
|
||||
title="מחיקת לקוח">
|
||||
<Icon name="delete" className="text-lg" />
|
||||
</button>
|
||||
</div>
|
||||
)}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user