Skip to content

Commit d744154

Browse files
committed
added state & district selection
1 parent 4af9d37 commit d744154

File tree

10 files changed

+357
-79
lines changed

10 files changed

+357
-79
lines changed

ios/Podfile.lock

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -203,8 +203,6 @@ PODS:
203203
- React-jsi (= 0.64.0)
204204
- React-perflogger (= 0.64.0)
205205
- React-jsinspector (0.64.0)
206-
- react-native-notifications (3.4.2):
207-
- React-Core
208206
- react-native-safe-area-context (3.2.0):
209207
- React-Core
210208
- React-perflogger (0.64.0)
@@ -275,6 +273,8 @@ PODS:
275273
- React-Core
276274
- RNCMaskedView (0.1.11):
277275
- React
276+
- RNCPicker (1.15.0):
277+
- React-Core
278278
- RNGestureHandler (1.10.3):
279279
- React-Core
280280
- RNKeychain (7.0.0):
@@ -312,6 +312,8 @@ PODS:
312312
- React-Core
313313
- RNSha256 (1.4.7):
314314
- React
315+
- RNSVG (12.1.1):
316+
- React
315317
- Yoga (1.14.0)
316318

317319
DEPENDENCIES:
@@ -332,7 +334,6 @@ DEPENDENCIES:
332334
- React-jsi (from `../node_modules/react-native/ReactCommon/jsi`)
333335
- React-jsiexecutor (from `../node_modules/react-native/ReactCommon/jsiexecutor`)
334336
- React-jsinspector (from `../node_modules/react-native/ReactCommon/jsinspector`)
335-
- react-native-notifications (from `../node_modules/react-native-notifications`)
336337
- react-native-safe-area-context (from `../node_modules/react-native-safe-area-context`)
337338
- React-perflogger (from `../node_modules/react-native/ReactCommon/reactperflogger`)
338339
- React-RCTActionSheet (from `../node_modules/react-native/Libraries/ActionSheetIOS`)
@@ -348,11 +349,13 @@ DEPENDENCIES:
348349
- ReactCommon/turbomodule/core (from `../node_modules/react-native/ReactCommon`)
349350
- "RNCAsyncStorage (from `../node_modules/@react-native-async-storage/async-storage`)"
350351
- "RNCMaskedView (from `../node_modules/@react-native-community/masked-view`)"
352+
- "RNCPicker (from `../node_modules/@react-native-picker/picker`)"
351353
- RNGestureHandler (from `../node_modules/react-native-gesture-handler`)
352354
- RNKeychain (from `../node_modules/react-native-keychain`)
353355
- RNReanimated (from `../node_modules/react-native-reanimated`)
354356
- RNScreens (from `../node_modules/react-native-screens`)
355357
- RNSha256 (from `../node_modules/react-native-sha256`)
358+
- RNSVG (from `../node_modules/react-native-svg`)
356359
- Yoga (from `../node_modules/react-native/ReactCommon/yoga`)
357360

358361
SPEC REPOS:
@@ -390,8 +393,6 @@ EXTERNAL SOURCES:
390393
:path: "../node_modules/react-native/ReactCommon/jsiexecutor"
391394
React-jsinspector:
392395
:path: "../node_modules/react-native/ReactCommon/jsinspector"
393-
react-native-notifications:
394-
:path: "../node_modules/react-native-notifications"
395396
react-native-safe-area-context:
396397
:path: "../node_modules/react-native-safe-area-context"
397398
React-perflogger:
@@ -422,6 +423,8 @@ EXTERNAL SOURCES:
422423
:path: "../node_modules/@react-native-async-storage/async-storage"
423424
RNCMaskedView:
424425
:path: "../node_modules/@react-native-community/masked-view"
426+
RNCPicker:
427+
:path: "../node_modules/@react-native-picker/picker"
425428
RNGestureHandler:
426429
:path: "../node_modules/react-native-gesture-handler"
427430
RNKeychain:
@@ -432,6 +435,8 @@ EXTERNAL SOURCES:
432435
:path: "../node_modules/react-native-screens"
433436
RNSha256:
434437
:path: "../node_modules/react-native-sha256"
438+
RNSVG:
439+
:path: "../node_modules/react-native-svg"
435440
Yoga:
436441
:path: "../node_modules/react-native/ReactCommon/yoga"
437442

@@ -452,7 +457,6 @@ SPEC CHECKSUMS:
452457
React-jsi: 74341196d9547cbcbcfa4b3bbbf03af56431d5a1
453458
React-jsiexecutor: 06a9c77b56902ae7ffcdd7a4905f664adc5d237b
454459
React-jsinspector: 0ae35a37b20d5e031eb020a69cc5afdbd6406301
455-
react-native-notifications: 51ed8167f70f01c5000ba81a4465ea98b4612e23
456460
react-native-safe-area-context: f0906bf8bc9835ac9a9d3f97e8bde2a997d8da79
457461
React-perflogger: 9c547d8f06b9bf00cb447f2b75e8d7f19b7e02af
458462
React-RCTActionSheet: 3080b6e12e0e1a5b313c8c0050699b5c794a1b11
@@ -468,11 +472,13 @@ SPEC CHECKSUMS:
468472
ReactCommon: cfe2b7fd20e0dbd2d1185cd7d8f99633fbc5ff05
469473
RNCAsyncStorage: f47a7e8f927f7c9da947491fc55752eb9ce17f2d
470474
RNCMaskedView: 0e1bc4bfa8365eba5fbbb71e07fbdc0555249489
475+
RNCPicker: 5256da29a92406cac439ac6605719e233714a86a
471476
RNGestureHandler: a479ebd5ed4221a810967000735517df0d2db211
472477
RNKeychain: f75b8c8b2f17d3b2aa1f25b4a0ac5b83d947ff8f
473478
RNReanimated: b8c8004b43446e3c2709fe64b2b41072f87428ad
474479
RNScreens: bd1523c3bde7069b8e958e5a16e1fc7722ad0bdd
475480
RNSha256: bf2c90a9e0cec6dcbcc4100e4e19715ae7feaa34
481+
RNSVG: 551acb6562324b1d52a4e0758f7ca0ec234e278f
476482
Yoga: 8c8436d4171c87504c648ae23b1d81242bdf3bbf
477483

478484
PODFILE CHECKSUM: 55e4074caf798c70301cff54fd03c77bbff60f00

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"dependencies": {
1313
"@react-native-async-storage/async-storage": "^1.15.4",
1414
"@react-native-community/masked-view": "^0.1.11",
15+
"@react-native-picker/picker": "^1.15.0",
1516
"@react-navigation/native": "^5.9.4",
1617
"@react-navigation/stack": "^5.14.4",
1718
"@types/react-native-push-notification": "^7.2.0",

src/API/APIEndpoints.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
export const baseUrl = 'https://cdn-api.co-vin.in/api';
22
export const generateOTP = `/v2/auth/generateMobileOTP`;
33
export const confirmOTP = `/v2/auth/validateMobileOtp`;
4-
// const getSlotUrl =
5-
// 'https://api.demo.co-vin.in/api/v2/appointment/sessions/public/calendarByDistrict?district_id=395&date=06-05-2021';
6-
// 'https://cdn-api.co-vin.in/api/v2/appointment/sessions/public/findByDistrict?district_id=395&date=06-05-2021';
7-
// 'https://cdn-api.co-vin.in/api/v2/appointment/sessions/public/calendarByDistrict?district_id=395&date=06-05-2021';
8-
export const getSlots = `/v2/appointment/sessions/calendarByDistrict`;
4+
export const getSlots = `/v2/appointment/sessions/public/calendarByDistrict`;
95
export const getBeneficieryDetails = `/v2/appointment/beneficiaries`;
106
export const bookAppointment = '/v2/appointment/schedule';
117
export const getCaptcha = '/v2/auth/getRecaptcha';
128
export const cancelAppointment = '/v2/appointment/cancel';
9+
export const getDistricts = '/v2/admin/location/districts';

src/API/APIHelper.ts

Lines changed: 44 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,13 @@ import {
99
bookAppointment as bookAppointmentUrl,
1010
getCaptcha as getCaptchaUrl,
1111
cancelAppointment,
12+
getDistricts as getDistrictsUrl,
1213
} from './APIEndpoints';
1314
import {removeCredentials} from '../Storage/LocalStorage';
1415
import {Center} from '../Types/SlotTypes';
1516
import Navigator from '../Navigation/RootNavigation';
1617
import {Beneficiary} from '../Types/BeneficiaryTypes';
18+
import {DISTRICT} from '../Constants/Constants';
1719

1820
let api = axios.create({
1921
baseURL: baseUrl,
@@ -130,16 +132,31 @@ export const getSlots = async (
130132
};
131133
}
132134
count += 1;
135+
console.log('DistrictId: ' + districtId);
136+
console.log('date: ' + date);
137+
console.log('token: ' + token);
138+
console.log('vaccine: ' + vaccine);
139+
140+
let headers: any;
141+
if (token === '') {
142+
headers = {
143+
accept: 'application/json',
144+
'Content-Type': 'application/json',
145+
'Accept-Language': 'hi_IN',
146+
};
147+
} else {
148+
headers = {
149+
accept: 'application/json',
150+
'Content-Type': 'application/json',
151+
'Accept-Language': 'hi_IN',
152+
Authorization: `Bearer ${token}`,
153+
};
154+
}
133155
try {
134156
const response = await api({
135157
url: getSlotUrl,
136158
method: 'get',
137-
headers: {
138-
accept: 'application/json',
139-
'Content-Type': 'application/json',
140-
'Accept-Language': 'hi_IN',
141-
Authorization: `Bearer ${token}`,
142-
},
159+
headers: headers,
143160
params: params,
144161
});
145162

@@ -202,9 +219,6 @@ export const getCaptcha = async (token: string) => {
202219
return undefined;
203220
};
204221

205-
/**
206-
* curl -X POST "https://api.demo.co-vin.in/api/v2/appointment/schedule" -H "accept: application/json" -H "Content-Type: application/json" -H "x-api-key: 3sjOr2rmM52GzhpMHjDEE1kpQeRxwFDr4YcBEimi" -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX25hbWUiOiI2OTRkNmQ3MS0wY2FiLTRjNGMtYTk2Ni02NjRlZDRjNTc1NjEiLCJ1c2VyX2lkIjoiNjk0ZDZkNzEtMGNhYi00YzRjLWE5NjYtNjY0ZWQ0YzU3NTYxIiwidXNlcl90eXBlIjoiQkVORUZJQ0lBUlkiLCJtb2JpbGVfbnVtYmVyIjo5NzI2MTg0ODM3LCJiZW5lZmljaWFyeV9yZWZlcmVuY2VfaWQiOjIxMzk1NzA3Njg1NDIyLCJzZWNyZXRfa2V5IjoiYjVjYWIxNjctNzk3Ny00ZGYxLTgwMjctYTYzYWExNDRmMDRlIiwidWEiOiJNb3ppbGxhLzUuMCAoTWFjaW50b3NoOyBJbnRlbCBNYWMgT1MgWCAxMF8xMF8xKSBBcHBsZVdlYktpdC81MzcuMzYgKEtIVE1MLCBsaWtlIEdlY2tvKSBDaHJvbWUvMzkuMC4yMTcxLjk1IFNhZmFyaS81MzcuMzYiLCJkYXRlX21vZGlmaWVkIjoiMjAyMS0wNS0wOVQxNDoyMzo0MS4yNTVaIiwiaWF0IjoxNjIwNTcwMjIxLCJleHAiOjE2MjA1NzExMjF9.NV65xMZJFZg7vTcwHH8FSdMZF0qbM7-sCW3Gfo3YUvc" -d "{\"dose\":1,\"session_id\":\"3fa85f64-5717-4562-b3fc-2c963f66afa6\",\"slot\":\"FORENOON\",\"beneficiaries\":[\"1234567890123\",\"9876543210987\"]}"
207-
*/
208222
export const bookAppointment = async (
209223
token: string,
210224
dose: number,
@@ -276,3 +290,24 @@ export const cancelBooking = async (
276290
}
277291
return undefined;
278292
};
293+
294+
export const getDistricts = async (
295+
stateId: number,
296+
): Promise<DISTRICT[] | undefined> => {
297+
try {
298+
const response = await api({
299+
url: getDistrictsUrl + '/' + stateId,
300+
method: 'get',
301+
headers: {
302+
accept: 'application/json',
303+
'Accept-Language': 'hi_IN',
304+
},
305+
});
306+
if (response) {
307+
return response.data.districts;
308+
}
309+
} catch (error) {
310+
console.error(`ERROR: ${error}`);
311+
}
312+
return undefined;
313+
};

src/App.tsx

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import Navigator from './Navigation/RootNavigation';
2525
import BeneficiaryListScreen from './Components/BeneficiaryListScreen/BeneficiaryListScreen';
2626

2727
import {
28-
districtId,
28+
DISTRICT_ID_PREF,
2929
FEE_PREF,
3030
minAge,
3131
VACCINE_PREF,
@@ -42,6 +42,7 @@ import {
4242
} from './Components/SettingsScreen/SettingsScreen';
4343
import {
4444
getUserAgePreference,
45+
getUserDistrictIdPreference,
4546
getUserFeeTypePreference,
4647
getUserVaccinePreference,
4748
} from './Storage/LocalStorage';
@@ -111,10 +112,16 @@ const App = () => {
111112
const agePromise = getUserAgePreference();
112113
const vaccinePromise = getUserVaccinePreference();
113114
const feePromise = getUserFeeTypePreference();
115+
const districtIdPromise = getUserDistrictIdPreference();
114116

115-
const allPromise = Promise.all([agePromise, vaccinePromise, feePromise]);
117+
const allPromise = Promise.all([
118+
agePromise,
119+
vaccinePromise,
120+
feePromise,
121+
districtIdPromise,
122+
]);
116123

117-
allPromise.then(([age, vaccine, fee]) => {
124+
allPromise.then(([age, vaccine, fee, disId]) => {
118125
let preferredAge = minAge;
119126
if (age) {
120127
preferredAge = age;
@@ -130,11 +137,16 @@ const App = () => {
130137
preferredFees = fee;
131138
}
132139
console.log('Preferred Fee: ' + preferredFees);
140+
let preferredDistrictId = DISTRICT_ID_PREF;
141+
if (disId) {
142+
preferredDistrictId = disId;
143+
}
144+
console.log('Preferred District: ' + preferredDistrictId);
133145
const vaccineParam =
134146
preferredVaccine !== VaccineType[VaccineType.BOTH]
135147
? preferredVaccine
136148
: undefined;
137-
getSlots(districtId, today(), '', vaccineParam).then(res => {
149+
getSlots(preferredDistrictId, today(), '', vaccineParam).then(res => {
138150
if (res) {
139151
setCenters(res);
140152
const filteredList = res.filter(item => {

0 commit comments

Comments
 (0)