Skip to content

Commit ad784f5

Browse files
0xsemajclaude
andcommitted
fix: update webhook service taxonomy and guard against undefined service
- Rename service values from signals.vss/events.behavior/events.safety to signals/events - Prefix condition field names with vss. namespace - Merge event name options into single events key - Change isEventService to use strict equality instead of startsWith (fixes crash when service is undefined) - Add service default value to NewWebhookForm to prevent undefined on initial render Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 7fe8461 commit ad784f5

3 files changed

Lines changed: 23 additions & 23 deletions

File tree

src/components/Webhooks/NewWebhookForm.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ export const NewWebhookForm = ({
4949
const methods = useForm<WebhookFormInput>({
5050
mode: 'onChange',
5151
defaultValues: {
52+
service: '',
5253
coolDownPeriod: 0,
5354
cel: { operator: 'AND', conditions: [{ field: '', value: '', operator: '' }] },
5455
subscribe: {

src/components/Webhooks/fields/Service.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,8 @@ export const WebhookServiceField = () => {
3636
required: 'Please select a webhook service',
3737
})}
3838
options={[
39-
{ value: 'signals.vss', text: 'VSS Signals' },
40-
{ value: 'events.behavior', text: 'Driving Behavior' },
41-
{ value: 'events.safety', text: 'Safety Events' },
39+
{ value: 'signals', text: 'VSS Signals' },
40+
{ value: 'events', text: 'Events' },
4241
]}
4342
control={control}
4443
/>

src/utils/webhook.ts

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -50,92 +50,92 @@ const booleanValidation: RegisterOptions = {
5050
};
5151

5252
export const eventNamesByService: Record<string, { value: string; label: string }[]> = {
53-
'events.behavior': [
54-
{ value: 'harshBraking', label: 'Harsh Braking' },
55-
{ value: 'extremeBraking', label: 'Extreme Braking' },
56-
{ value: 'harshAcceleration', label: 'Harsh Acceleration' },
57-
{ value: 'harshCornering', label: 'Harsh Cornering' },
53+
events: [
54+
{ value: 'behavior.harshBraking', label: 'Harsh Braking' },
55+
{ value: 'behavior.extremeBraking', label: 'Extreme Braking' },
56+
{ value: 'behavior.harshAcceleration', label: 'Harsh Acceleration' },
57+
{ value: 'behavior.harshCornering', label: 'Harsh Cornering' },
58+
{ value: 'safety.collision', label: 'Collision' },
5859
],
59-
'events.safety': [{ value: 'collision', label: 'Collision' }],
6060
};
6161

62-
export const isEventService = (service: string): boolean => service.startsWith('events.');
62+
export const isEventService = (service: string): boolean => service === 'events';
6363

6464
export const conditionsConfig: ConditionConfig[] = [
6565
{
66-
field: 'speed',
66+
field: 'vss.speed',
6767
label: 'Speed',
6868
inputType: 'number',
6969
validation: numericValidation,
7070
},
7171
{
72-
field: 'obdIsPluggedIn',
72+
field: 'vss.obdIsPluggedIn',
7373
label: 'Device Plugged In',
7474
inputType: 'boolean',
7575
validation: booleanValidation,
7676
},
7777
{
78-
field: 'isIgnitionOn',
78+
field: 'vss.isIgnitionOn',
7979
label: 'Is Ignition On',
8080
inputType: 'boolean',
8181
validation: booleanValidation,
8282
},
8383
{
84-
field: 'powertrainTractionBatteryCurrentPower',
84+
field: 'vss.powertrainTractionBatteryCurrentPower',
8585
label: 'Battery current power',
8686
inputType: 'number',
8787
validation: numericValidation,
8888
},
8989
{
90-
field: 'powertrainTractionBatteryChargingIsCharging',
90+
field: 'vss.powertrainTractionBatteryChargingIsCharging',
9191
label: 'Battery is charging',
9292
inputType: 'boolean',
9393
validation: booleanValidation,
9494
},
9595
{
96-
field: 'powertrainTransmissionTravelledDistance',
96+
field: 'vss.powertrainTransmissionTravelledDistance',
9797
label: 'Odometer',
9898
inputType: 'number',
9999
validation: numericValidation,
100100
},
101101
{
102-
field: 'powertrainTractionBatteryStateOfChargeCurrent',
102+
field: 'vss.powertrainTractionBatteryStateOfChargeCurrent',
103103
label: 'Charge level',
104104
inputType: 'number',
105105
validation: numericValidation,
106106
},
107107
{
108-
field: 'powertrainFuelSystemRelativeLevel',
108+
field: 'vss.powertrainFuelSystemRelativeLevel',
109109
label: 'Fuel System Relative Level',
110110
inputType: 'number',
111111
validation: numericValidation,
112112
},
113113
{
114-
field: 'powertrainFuelSystemAbsoluteLevel',
114+
field: 'vss.powertrainFuelSystemAbsoluteLevel',
115115
label: 'Fuel System Absolute Level',
116116
inputType: 'number',
117117
validation: numericValidation,
118118
},
119119
{
120-
field: 'chassisAxleRow1WheelLeftTirePressure',
120+
field: 'vss.chassisAxleRow1WheelLeftTirePressure',
121121
label: 'Tire pressure (front left)',
122122
inputType: 'number',
123123
validation: numericValidation,
124124
},
125125
{
126-
field: 'chassisAxleRow1WheelRightTirePressure',
126+
field: 'vss.chassisAxleRow1WheelRightTirePressure',
127127
label: 'Tire pressure (front right)',
128128
inputType: 'number',
129129
validation: numericValidation,
130130
},
131131
{
132-
field: 'chassisAxleRow2WheelLeftTirePressure',
132+
field: 'vss.chassisAxleRow2WheelLeftTirePressure',
133133
label: 'Tire pressure (back left)',
134134
inputType: 'number',
135135
validation: numericValidation,
136136
},
137137
{
138-
field: 'chassisAxleRow2WheelRightTirePressure',
138+
field: 'vss.chassisAxleRow2WheelRightTirePressure',
139139
label: 'Tire pressure (back right)',
140140
inputType: 'number',
141141
validation: numericValidation,

0 commit comments

Comments
 (0)