Fix jwt-token

This commit is contained in:
2025-08-28 13:17:37 +02:00
parent 93be5d3dbf
commit 02ee6486ab
2 changed files with 64 additions and 2 deletions

View File

@@ -462,7 +462,9 @@ const CreateAlertRuleModal = ({ onClose, onSave }) => {
device_ids: [],
drone_types: [],
min_rssi: '',
max_rssi: ''
max_rssi: '',
sms_phone_number: '',
webhook_url: ''
});
const [saving, setSaving] = useState(false);
const [devices, setDevices] = useState([]);
@@ -502,6 +504,11 @@ const CreateAlertRuleModal = ({ onClose, onSave }) => {
if (!payload.max_rssi) delete payload.max_rssi;
if (!payload.device_ids || payload.device_ids.length === 0) payload.device_ids = null;
if (!payload.drone_types || payload.drone_types.length === 0) payload.drone_types = null;
// Only include webhook_url if webhook channel is selected
if (!payload.alert_channels || !payload.alert_channels.includes('webhook')) {
delete payload.webhook_url;
}
await api.post('/alerts/rules', payload);
onSave();
@@ -733,6 +740,46 @@ const CreateAlertRuleModal = ({ onClose, onSave }) => {
)}
</div>
</div>
{/* Conditional channel-specific fields */}
{formData.alert_channels.includes('sms') && (
<div>
<label className="block text-sm font-medium text-gray-700 mb-1">
SMS Phone Number
</label>
<input
type="tel"
name="sms_phone_number"
placeholder="+1234567890"
className="w-full border border-gray-300 rounded-md px-3 py-2 focus:ring-primary-500 focus:border-primary-500"
value={formData.sms_phone_number || ''}
onChange={handleChange}
/>
<div className="text-xs text-gray-500 mt-1">
Include country code (e.g., +1 for US)
</div>
</div>
)}
{formData.alert_channels.includes('webhook') && (
<div>
<label className="block text-sm font-medium text-gray-700 mb-1">
Webhook URL *
</label>
<input
type="url"
name="webhook_url"
placeholder="https://your-webhook-endpoint.com/alerts"
required={formData.alert_channels.includes('webhook')}
className="w-full border border-gray-300 rounded-md px-3 py-2 focus:ring-primary-500 focus:border-primary-500"
value={formData.webhook_url || ''}
onChange={handleChange}
/>
<div className="text-xs text-gray-500 mt-1">
Must be a valid HTTPS URL
</div>
</div>
)}
</div>
</div>