1
1
import axios from 'axios' ;
2
2
3
- const BASE_URL = 'https://wtfmzvwh4b.execute-api.us-east-1.amazonaws.com' ;
3
+ // const BASE_URL = 'http://localhost:3000';
4
+ const BASE_URL = 'https://rvvfas273i.execute-api.us-east-2.amazonaws.com/dev' ;
4
5
5
6
export const getAllFlights = async ( token , filters = { } , pageNumber = 1 ) => {
6
7
try {
@@ -38,16 +39,33 @@ export const getFlightDetails = async (token, flightId) => {
38
39
}
39
40
}
40
41
41
- export const postFlightRequest = async ( token , flightId , quantity ) => {
42
+ export const getRecommendations = async ( token ) => {
43
+ try {
44
+ const headers = {
45
+ Authorization : `Bearer ${ token } `
46
+ } ;
47
+ const response = await axios . get ( `${ BASE_URL } /flights/recommendations` , { headers } ) ;
48
+ return response . data . flights ;
49
+ } catch ( error ) {
50
+ console . error ( "Error: details" , error )
51
+ throw error ;
52
+ }
53
+ }
54
+
55
+ export const postFlightRequest = async ( token , flightId , quantity , latitude , longitude , name ) => {
42
56
try {
43
57
const headers = {
44
58
Authorization : `Bearer ${ token } `
45
59
} ;
46
60
const data = {
47
- 'type' : "our_group_purchase" ,
61
+ // 'type': "our_group_purchase",
48
62
'flight_id' : flightId ,
49
- 'quantity' : quantity
63
+ 'quantity' : quantity ,
64
+ 'latitudeIp' : latitude ,
65
+ 'longitudeIp' : longitude ,
66
+ 'name' : name
50
67
} ;
68
+ console . log ( data ) ;
51
69
const response = await axios . post ( `${ BASE_URL } /flights/request/` , data , { headers } ) ;
52
70
return response . data ;
53
71
} catch ( error ) {
@@ -66,4 +84,22 @@ export const getPurchase = async (token) => {
66
84
} catch ( error ) {
67
85
console . error ( "Failed to request flight:" , error ) ;
68
86
}
69
- }
87
+ }
88
+
89
+ export const commitTransaction = async ( token , token_ws , userEmail , purchaseUuid ) => {
90
+ try {
91
+ const headers = {
92
+ Authorization : `Bearer ${ token } `
93
+ } ;
94
+ const data = {
95
+ 'ws_token' : token_ws ,
96
+ 'userEmail' : userEmail ,
97
+ 'purchase_uuid' : purchaseUuid
98
+ } ;
99
+ const response = await axios . post ( `${ BASE_URL } /flights/commit` , data , { headers} ) ;
100
+ return response . data ;
101
+ } catch ( error ) {
102
+ console . error ( "Failed to commit transaction:" , error ) ;
103
+ throw error ;
104
+ }
105
+ }
0 commit comments