mirror of
				https://github.com/juspay/hyperswitch.git
				synced 2025-11-01 02:57:02 +08:00 
			
		
		
		
	feat(wasm): fetch list of country codes and country names (#7642)
Co-authored-by: Sayak Bhattacharya <sayak.b@Sayak-Bhattacharya-G092THXJ34.local>
This commit is contained in:
		 Sayak Bhattacharya
					Sayak Bhattacharya
				
			
				
					committed by
					
						 GitHub
						GitHub
					
				
			
			
				
	
			
			
			 GitHub
						GitHub
					
				
			
						parent
						
							9e82c40eed
						
					
				
				
					commit
					63d9b534d0
				
			| @ -32,6 +32,9 @@ use wasm_bindgen::prelude::*; | ||||
|  | ||||
| use crate::utils::JsResultExt; | ||||
| type JsResult = Result<JsValue, JsValue>; | ||||
| use api_models::payment_methods::CountryCodeWithName; | ||||
| use common_enums::CountryAlpha2; | ||||
| use strum::IntoEnumIterator; | ||||
|  | ||||
| struct SeedData { | ||||
|     cgraph: hyperswitch_constraint_graph::ConstraintGraph<dir::DirValue>, | ||||
| @ -73,6 +76,20 @@ pub fn convert_forex_value(amount: i64, from_currency: JsValue, to_currency: JsV | ||||
|     Ok(serde_wasm_bindgen::to_value(&converted_amount)?) | ||||
| } | ||||
|  | ||||
| /// This function can be used by the frontend to get all the two letter country codes | ||||
| /// along with their country names. | ||||
| #[wasm_bindgen(js_name=getTwoLetterCountryCode)] | ||||
| pub fn get_two_letter_country_code() -> JsResult { | ||||
|     let country_code_with_name = CountryAlpha2::iter() | ||||
|         .map(|country_code| CountryCodeWithName { | ||||
|             code: country_code, | ||||
|             name: common_enums::Country::from_alpha2(country_code), | ||||
|         }) | ||||
|         .collect::<Vec<_>>(); | ||||
|  | ||||
|     Ok(serde_wasm_bindgen::to_value(&country_code_with_name)?) | ||||
| } | ||||
|  | ||||
| /// This function can be used by the frontend to provide the WASM with information about | ||||
| /// all the merchant's connector accounts. The input argument is a vector of all the merchant's | ||||
| /// connector accounts from the API. | ||||
|  | ||||
		Reference in New Issue
	
	Block a user