Skip to content

Commit

Permalink
Fix pincode api
Browse files Browse the repository at this point in the history
  • Loading branch information
Ashesh3 committed Dec 20, 2023
1 parent 7c21b80 commit 1b3fd2b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Components/Facility/FacilityCreate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ export const FacilityCreate = (props: FacilityProps) => {
if (!fetchedDistricts) return;

const matchedDistrict = fetchedDistricts.find((district) => {
return includesIgnoreCase(district.name, pincodeDetails.district);
return includesIgnoreCase(district.name, pincodeDetails.districtname);
});
if (!matchedDistrict) return;

Expand Down
3 changes: 2 additions & 1 deletion src/Utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,13 +214,14 @@ export const parseCsvFile = async (

export const getPincodeDetails = async (pincode: string, apiKey: string) => {
const response = await fetch(
`https://api.data.gov.in/resource/5c2f62fe-5afa-4119-a499-fec9d604d5bd?api-key=${apiKey}&format=json&filters[pincode]=${pincode}&limit=1`
`https://api.data.gov.in/resource/6176ee09-3d56-4a3b-8115-21841576b2f6?api-key=${apiKey}&format=json&filters[pincode]=${pincode}&limit=1`
);
const data = await response.json();
return data.records[0];
};

export const includesIgnoreCase = (str1: string, str2: string) => {
if (!str1 || !str2) return false;
const lowerCaseStr1 = str1.toLowerCase();
const lowerCaseStr2 = str2.toLowerCase();
return (
Expand Down

0 comments on commit 1b3fd2b

Please sign in to comment.