Function: handleSubmit()
handleSubmit(
event:FormEvent,properties: {addMonitorToSite: (siteIdentifier:string,monitor:Monitor) =>Promise<void>;clearError: () =>void;createSite: (siteData: {identifier:string;monitoring?:boolean;monitors?:Monitor[];name?:string; }) =>Promise<void>;generateUuid: () =>string;logger:LoggerInterface;onSuccess?: () =>void;setFormError: (error:string|undefined) =>void;addMode:FormMode;baselineUrl:string;bodyKeyword:string;certificateWarningDays:string;checkInterval:number;edgeLocations:string;expectedHeaderValue:string;expectedJsonValue:string;expectedStatusCode:string;expectedValue:string;formError:string|undefined;headerName:string;heartbeatExpectedStatus:string;heartbeatMaxDriftSeconds:string;heartbeatStatusField:string;heartbeatTimestampField:string;host:string;jsonPath:string;maxPongDelayMs:string;maxReplicationLagSeconds:string;maxResponseTime:string;monitorType:"http"|"http-keyword"|"http-status"|"http-header"|"http-json"|"http-latency"|"port"|"ping"|"dns"|"ssl"|"websocket-keepalive"|"server-heartbeat"|"replication"|"cdn-edge-consistency";name:string;port:string;primaryStatusUrl:string;recordType:string;replicaStatusUrl:string;replicationTimestampField:string;selectedExistingSite:string;siteIdentifier:string;url:string; }):Promise<void>
Defined in: src/components/AddSiteForm/Submit.tsx:505
Handles form submission for adding sites or monitors.
Performs comprehensive validation based on add mode and monitor type:
- For new sites: validates site name and monitor configuration
- For existing sites: validates site selection and monitor configuration
- For HTTP monitors: validates URL format and protocol
- For port monitors: validates host and port number
Parametersโ
eventโ
Form submission event
propertiesโ
Form state, actions, and dependencies
addMonitorToSiteโ
(siteIdentifier: string, monitor: Monitor) => Promise<void>
Add a monitor to an existing site
clearErrorโ
() => void
Clear any existing error state
createSiteโ
(siteData: { identifier: string; monitoring?: boolean; monitors?: Monitor[]; name?: string; }) => Promise<void>
Create a new site with monitors
generateUuidโ
() => string
UUID generator function for creating unique identifiers
loggerโ
Logger instance for debugging and error tracking
onSuccess?โ
() => void
Optional callback executed after successful submission
setFormErrorโ
(error: string | undefined) => void
Set form error message
addModeโ
Form operation mode (new site vs existing site)
baselineUrlโ
string
Baseline URL for CDN edge consistency monitors
bodyKeywordโ
string
Keyword to match for HTTP keyword monitors
certificateWarningDaysโ
string
SSL certificate warning days
checkIntervalโ
number
Check interval in milliseconds
edgeLocationsโ
string
Edge endpoint list for CDN edge consistency monitors
expectedHeaderValueโ
string
Expected HTTP header value for header monitors
expectedJsonValueโ
string
Expected JSON value for JSON monitors
expectedStatusCodeโ
string
Expected HTTP status code for status-based HTTP monitors
expectedValueโ
string
Expected value for DNS record verification
formErrorโ
string | undefined
Current form validation error
headerNameโ
string
Header name for HTTP header monitors
heartbeatExpectedStatusโ
string
Expected heartbeat status field
heartbeatMaxDriftSecondsโ
string
Heartbeat drift tolerance
heartbeatStatusFieldโ
string
Heartbeat status field path
heartbeatTimestampFieldโ
string
Heartbeat timestamp field path
hostโ
string
Host/IP field for port and DNS monitors
jsonPathโ
string
JSON path for HTTP JSON monitors
maxPongDelayMsโ
string
Maximum pong delay for WebSocket monitors
maxReplicationLagSecondsโ
string
Maximum replication lag in seconds
maxResponseTimeโ
string
Maximum response time for latency monitors
monitorTypeโ
"http" | "http-keyword" | "http-status" | "http-header" | "http-json" | "http-latency" | "port" | "ping" | "dns" | "ssl" | "websocket-keepalive" | "server-heartbeat" | "replication" | "cdn-edge-consistency"
Selected monitor type
nameโ
string
Display name for the site
portโ
string
Port number field for port monitors
primaryStatusUrlโ
string
Primary replication status URL
recordTypeโ
string
DNS record type field for DNS monitors
replicaStatusUrlโ
string
Replica status URL
replicationTimestampFieldโ
string
Replication timestamp field
selectedExistingSiteโ
string
Selected existing site identifier when adding to existing
siteIdentifierโ
string
Generated site identifier
urlโ
string
URL field for HTTP monitors
Returnsโ
Promise<void>
Promise that resolves when submission is complete
Exampleโ
const handleFormSubmit = (e: FormEvent) => {
handleSubmit(e, {
...formState,
...formActions,
...storeActions,
generateUuid,
logger,
onSuccess: () => setIsVisible(false),
});
};