Skip to content

Commit 07f3306

Browse files
authored
feat: Stop ConfigFlow if no active contracts found (#271)
1 parent ff98625 commit 07f3306

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

custom_components/iec/config_flow.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,9 @@ async def async_step_mfa(
136136
for contract in contracts
137137
if contract.status == 1
138138
]
139-
if len(contract_ids) == 1:
139+
if len(contract_ids) == 0:
140+
errors["base"] = "no_active_contracts"
141+
elif len(contract_ids) == 1:
140142
data[CONF_SELECTED_CONTRACTS] = [contract_ids[0]]
141143
return self._async_create_iec_entry(data)
142144
else:

custom_components/iec/translations/en.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,8 @@
9999
"cannot_connect": "[%key:common::config_flow::error::cannot_connect%]",
100100
"invalid_auth": "[%key:common::config_flow::error::invalid_auth%]",
101101
"invalid_id": "Invalid Israeli ID",
102-
"no_contracts": "You should select at least one contract"
102+
"no_contracts": "You should select at least one contract",
103+
"no_active_contracts": "No active contracts found"
103104
},
104105
"abort": {
105106
"already_configured": "[%key:common::config_flow::abort::already_configured_service%]",

custom_components/iec/translations/he.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,8 @@
102102
"cannot_connect": "[%key:common::config_flow::error::cannot_connect%]",
103103
"invalid_auth": "[%key:common::config_flow::error::invalid_auth%]",
104104
"invalid_id": "תעודת זהות לא תקנית",
105-
"no_contracts": "נא לבחור לפחות חוזה אחד"
105+
"no_contracts": "נא לבחור לפחות חוזה אחד",
106+
"no_active_contracts": "לא נמצאו חוזים פעילים"
106107
},
107108
"abort": {
108109
"already_configured": "[%key:common::config_flow::abort::already_configured_service%]",

0 commit comments

Comments
 (0)