mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-04-06 07:29:16 +00:00
Extract countryStates logic from customer_address modal and re-use new CountryStates service
This commit is contained in:
@@ -3,6 +3,9 @@ angular.module("ofn.admin").factory "CountryStates", ($filter) ->
|
||||
|
||||
statesFor: (countries, country_id) ->
|
||||
return [] unless country_id
|
||||
country = $filter('filter')(countries, {id: country_id}, true)[0]
|
||||
country = $filter('filter')(countries, {id: parseInt(country_id)}, true)[0]
|
||||
return [] unless country
|
||||
country.states
|
||||
|
||||
addressStateMatchesCountryStates: (countryStates, stateId) ->
|
||||
countryStates.some (state) -> state.id == stateId
|
||||
|
||||
Reference in New Issue
Block a user