diff --git a/react/src/WifiConfigDialog.tsx b/react/src/WifiConfigDialog.tsx index 45bb665..7e35386 100644 --- a/react/src/WifiConfigDialog.tsx +++ b/react/src/WifiConfigDialog.tsx @@ -78,6 +78,10 @@ export interface WifiConfigState { homeNetworkSsid: string; homeNetworkError: boolean; homeNetworkErrorMessage: string; + countryCodeError: boolean; + countryCodeErrorMessage: string; + channelError: boolean; + channelErrorMessage: string; countryCode: string; channel: string; knownWifiNetworks: string[]; @@ -112,6 +116,10 @@ const WifiConfigDialog = withStyles(styles, { withTheme: true })( homeNetworkSsid: this.props.wifiConfigSettings.homeNetwork, homeNetworkError: false, homeNetworkErrorMessage: NBSP, + countryCodeError: false, + countryCodeErrorMessage: NBSP, + channelError: false, + channelErrorMessage: NBSP, showWifiWarningDialog: false, showHelpDialog: false, wifiWarningGiven: this.props.wifiConfigSettings.wifiWarningGiven, @@ -257,7 +265,19 @@ const WifiConfigDialog = withStyles(styles, { withTheme: true })( this.setState({ homeNetworkError: true, homeNetworkErrorMessage: "* Required" }); hasError = true; } + if (this.state.countryCode === "") + { + this.setState({ countryCodeError: true, countryCodeErrorMessage: "* Required" }); + hasError = true; + } + if (this.validChannelSelection() === "") + { + this.setState({ channelError: true, channelErrorMessage: "* Required" }); + hasError = true; + + } } + if (this.state.autoStartMode !== 0 && (!this.props.wifiConfigSettings.hasSavedPassword) && this.state.newPassword.length === 0) { this.setState({ passwordError: true, passwordErrorMessage: "* Required" }); hasError = true; @@ -291,12 +311,14 @@ const WifiConfigDialog = withStyles(styles, { withTheme: true })( handleChannelChange(e: any) { let value = e.target.value as string; - this.setState({ channel: value }); + this.setState({ channel: value, channelError: false, channelErrorMessage: NBSP }); } - handleCountryChanged(e: any) { - let value = e.target.value as string; + handleCountryChanged(value: string) { - this.setState({ countryCode: value }); + this.setState({ countryCode: value, + countryCodeError: false, countryCodeErrorMessage: NBSP, + channelError: false, channelErrorMessage: NBSP + }); this.requestWifiChannels(value); } handleTogglePasswordVisibility() { @@ -334,6 +356,20 @@ const WifiConfigDialog = withStyles(styles, { withTheme: true })( this.handleOk(true); } + validChannelSelection() { + if (!this.state.wifiChannels) + { + return ''; // null selector. + } + for (let wifiChannel of this.state.wifiChannels) + { + if (wifiChannel.channelId === this.state.channel) + { + return this.state.channel; // yes, it's a valid selection. + } + } + return ''; // null selector value. + } render() { let props = this.props; @@ -522,34 +558,35 @@ const WifiConfigDialog = withStyles(styles, { withTheme: true })( ? { display: "flex", flexFlow: "row nowrap", gap: 24, alignItems: "start" } : { display: "block" } }> -