Skip to content

Commit

Permalink
fix: make recommendMethod work on the browser as well
Browse files Browse the repository at this point in the history
  • Loading branch information
khawarizmus committed Oct 7, 2023
1 parent c7605cc commit 29ab43a
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 74 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@
}
},
"dependencies": {
"@rapideditor/country-coder": "^5.2.2",
"adhan": "^4.4.3",
"country-locator": "^2.1.1",
"rxjs": "^7.5.6",
"tslog": "^4.4.4"
}
Expand Down
102 changes: 33 additions & 69 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions src/MethodRecommender.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { findCountryByCoordinate } from 'country-locator'
import { iso1A3Code } from '@rapideditor/country-coder'
import { CountryMethods } from './data/methods'
import type { Methods } from './types/Methods'
import type { CoordinatesObject } from './types/Coordinates'

export function recommendMethod({ latitude, longitude }: CoordinatesObject): Methods[] | undefined {
const countryInfo = findCountryByCoordinate(latitude, longitude)
return countryInfo?.code ? (CountryMethods as Record<string, Methods[]>)[countryInfo?.code] : undefined
export function recommendMethod({ longitude, latitude }: CoordinatesObject): Methods[] | undefined {
const countryCode = iso1A3Code([longitude, latitude])
return countryCode ? (CountryMethods as Record<string, Methods[]>)[countryCode] : undefined
}

0 comments on commit 29ab43a

Please sign in to comment.