feat: auto-assign extensions + form validation
- Backend: new customers auto-get all active extensions assigned - Frontend: required field validation (name, URL, credentials) - Frontend: removed manual "add extension" dropdown (auto-assigned) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
+8
-10
@@ -179,7 +179,13 @@ function CustomerForm({ onDone, onCancel, customer }) {
|
||||
}
|
||||
}
|
||||
|
||||
const [error, setError] = useState('')
|
||||
|
||||
const submit = async () => {
|
||||
if (!form.name.trim()) { setError('שם לקוח הוא שדה חובה'); return }
|
||||
if (!form.espocrm_url.trim()) { setError('EspoCRM URL הוא שדה חובה'); return }
|
||||
if (!isEdit && !form.espocrm_api_key) { setError('יש להזין שם משתמש וסיסמה'); return }
|
||||
setError('')
|
||||
const payload = { ...form }
|
||||
if (!payload.espocrm_api_key) delete payload.espocrm_api_key
|
||||
const url = isEdit ? `${API}/customers/${customer.id}` : `${API}/customers`
|
||||
@@ -223,6 +229,7 @@ function CustomerForm({ onDone, onCancel, customer }) {
|
||||
<p className="text-[10px] text-slate-400 text-right">השאר ריק כדי לא לשנות</p>
|
||||
)}
|
||||
</div>
|
||||
{error && <p className="text-xs text-red-600 font-bold text-right">{error}</p>}
|
||||
<div className="flex gap-2">
|
||||
<button onClick={submit}
|
||||
className="deep-action-gradient text-white px-4 py-2.5 rounded-xl font-bold flex-1 shadow-lg shadow-blue-500/20 active:scale-95 transition-all">
|
||||
@@ -504,16 +511,7 @@ function CustomerDetail({ customerId, onDelete }) {
|
||||
</table>
|
||||
</section>
|
||||
|
||||
{available.length > 0 && (
|
||||
<div className="mt-6 bg-white rounded-xl p-6">
|
||||
<h4 className="text-sm font-bold text-slate-400 uppercase tracking-widest mb-3">הוסף הרחבה</h4>
|
||||
<select onChange={e => e.target.value && assign(parseInt(e.target.value))}
|
||||
className="bg-slate-50 border-none rounded-xl px-4 py-2.5 w-full text-sm focus:ring-2 focus:ring-blue-500">
|
||||
<option value="">בחר הרחבה...</option>
|
||||
{available.map(e => <option key={e.id} value={e.id}>{e.name} v{e.latest_version}</option>)}
|
||||
</select>
|
||||
</div>
|
||||
)}
|
||||
{/* Extensions are auto-assigned on customer creation */}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user