()
| 218 | }, [id, isNew]); |
| 219 | |
| 220 | const handleSave = async () => { |
| 221 | setIsSaving(true); |
| 222 | try { |
| 223 | const payload = { |
| 224 | ...form, |
| 225 | expectedInputs: form.expectedInputs, // simplified for now |
| 226 | }; |
| 227 | |
| 228 | if (isNew) { |
| 229 | const created = (await api.webhooks.create(payload)) as any; |
| 230 | toast({ title: 'Webhook created' }); |
| 231 | setInitialForm(payload); |
| 232 | navigate(`/webhooks/${created.id}`, { replace: true }); |
| 233 | } else { |
| 234 | await api.webhooks.update(id!, payload); |
| 235 | setInitialForm(payload); |
| 236 | toast({ title: 'Webhook saved' }); |
| 237 | } |
| 238 | } catch (error) { |
| 239 | toast({ |
| 240 | title: 'Save failed', |
| 241 | description: String(error), |
| 242 | variant: 'destructive', |
| 243 | }); |
| 244 | } finally { |
| 245 | setIsSaving(false); |
| 246 | } |
| 247 | }; |
| 248 | |
| 249 | // Keyboard shortcut |
| 250 | useEffect(() => { |
no test coverage detected