Skip to content

Commit 9605f52

Browse files
authored
Merge pull request #35 from rzyuras/develop2
Develop2
2 parents 2f3523d + a9004b2 commit 9605f52

27 files changed

+12353
-3297
lines changed

Sample-01/package.json

+8-3
Original file line numberDiff line numberDiff line change
@@ -22,25 +22,30 @@
2222
"@fortawesome/react-fontawesome": "^0.2",
2323
"@heroicons/react": "^2.1.3",
2424
"@mui/material": "^5.15.15",
25+
"@sendgrid/mail": "^8.1.3",
26+
"@tanstack/react-query": "^5.37.1",
2527
"autoprefixer": "^10.4",
2628
"axios": "^1.6.8",
2729
"buffer": "^6.0.3",
28-
"cors": "^2.8",
30+
"cors": "^2.8.5",
2931
"crypto": "^1.0.1",
3032
"date-fns": "^3.6.0",
3133
"date-fns-tz": "^3.1.3",
32-
"express": "^4.18",
34+
"express": "^4.19.2",
3335
"express-oauth2-jwt-bearer": "^1.6.0",
3436
"helmet": "^4.4",
3537
"highlight.js": "^11.9.0",
38+
"history": "^5.3.0",
3639
"jsonwebtoken": "^9.0.2",
3740
"morgan": "^1.9",
41+
"node-fetch": "^3.3.2",
3842
"npm-run-all": "^4.1",
3943
"postcss": "^8.4",
4044
"react": "^18.2.0",
4145
"react-dom": "^18.2.0",
46+
"react-is": "^16.13.1",
4247
"react-qty-picker": "^1.0.6",
43-
"react-router-dom": "^5.3",
48+
"react-router-dom": "^6.23.1",
4449
"react-scripts": "^5.0",
4550
"reactjs-popup": "^2.0.6",
4651
"reactstrap": "^9.2",

Sample-01/src/App.css

+13
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
font-size: 16px;
6060
}
6161

62+
6263
.modal-button:hover {
6364
background-color: #0056b3;
6465
}
@@ -78,6 +79,7 @@
7879

7980
.btn-comprar {
8081
margin-left: 30px;
82+
margin-top: 5px;
8183
background-color: #007bff;
8284
color: #fff;
8385
padding: 10px 20px;
@@ -87,12 +89,23 @@
8789
font-size: 16px;
8890
}
8991

92+
.btn-comprar:disabled {
93+
background-color: grey;
94+
color: darkgrey;
95+
cursor: not-allowed;
96+
}
97+
9098
.flight-container {
9199
display: flex;
92100
flex-direction: row;
93101
justify-content: space-between;
94102
}
95103

104+
.btn-container {
105+
display: flex;
106+
justify-content: center;
107+
}
108+
96109
.Airline-Logo {
97110
margin-right: 10px;
98111
}

Sample-01/src/App.js

+13-9
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from "react";
2-
import { Router, Route, Switch } from "react-router-dom";
2+
import { BrowserRouter as Router, Route, Routes } from "react-router-dom";
33
import { Container } from "reactstrap";
44
// import Loading from "./components/Loading";
55
import NavBar from "./components/NavBar";
@@ -16,6 +16,8 @@ import initFontAwesome from "./utils/initFontAwesome";
1616
import FlightList from "./views/FlightList";
1717
import Flight from "./views/FlightDetails";
1818
import PurchaseList from "./views/MyPurchases";
19+
import PurchaseCompleted from "./views/PurchaseCompleted";
20+
import Recommendations from "./views/Recommendations";
1921

2022
initFontAwesome();
2123

@@ -31,17 +33,19 @@ const App = () => {
3133
// }
3234

3335
return (
34-
<Router history={history}>
36+
<Router>
3537
<div id="app" className="d-flex flex-column h-100">
3638
<NavBar />
3739
<Container className="flex-grow-1 mt-5">
38-
<Switch>
39-
<Route path="/" exact component={Home} />
40-
<Route path="/profile" component={Profile} />
41-
<Route path="/flights" component={FlightList}/>
42-
<Route path="/details/:flightId" component={Flight}/>
43-
<Route path="/mypurchases" component={PurchaseList} />
44-
</Switch>
40+
<Routes>
41+
<Route path="/" element={<Home/>} />
42+
<Route path="/profile" element={<Profile/>} />
43+
<Route path="/flights" element={<FlightList/>}/>
44+
<Route path="/details/:flightId" element={<Flight/>}/>
45+
<Route path="/mypurchases" element={<PurchaseList/>} />
46+
<Route path="/purchase" element={<PurchaseCompleted/>} />
47+
<Route path="/recommendations" element={<Recommendations/>} />
48+
</Routes>
4549
</Container>
4650
{/*<Footer />*/}
4751
</div>

Sample-01/src/api/flights.js

+41-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import axios from 'axios';
22

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';
45

56
export const getAllFlights = async (token, filters = {}, pageNumber = 1) => {
67
try {
@@ -38,16 +39,33 @@ export const getFlightDetails = async (token, flightId) => {
3839
}
3940
}
4041

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) => {
4256
try {
4357
const headers = {
4458
Authorization: `Bearer ${token}`
4559
};
4660
const data = {
47-
'type': "our_group_purchase",
61+
// 'type': "our_group_purchase",
4862
'flight_id': flightId,
49-
'quantity': quantity
63+
'quantity': quantity,
64+
'latitudeIp': latitude,
65+
'longitudeIp': longitude,
66+
'name': name
5067
};
68+
console.log(data);
5169
const response = await axios.post(`${BASE_URL}/flights/request/`, data, { headers });
5270
return response.data;
5371
} catch (error) {
@@ -66,4 +84,22 @@ export const getPurchase = async (token) => {
6684
} catch (error) {
6785
console.error("Failed to request flight:", error);
6886
}
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+
}

Sample-01/src/components/IPdetails.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,4 +78,4 @@ function IPdetails() {
7878
);
7979
}
8080

81-
export default IPdetails;
81+
export default IPdetails;

Sample-01/src/components/NavBar.js

+10
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,16 @@ const NavBar = () => {
7878
Mis Solicitudes
7979
</NavLink>
8080
</NavItem>
81+
<NavItem>
82+
<NavLink
83+
tag={RouterNavLink}
84+
to="/recommendations"
85+
exact
86+
activeClassName="router-link-exact-active"
87+
>
88+
Recomendaciones
89+
</NavLink>
90+
</NavItem>
8191
</>
8292
)}
8393
</Nav>

Sample-01/src/components/PopUp.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ const Popup = ({ onClose, children }) => {
1313
);
1414
};
1515

16-
export default Popup;
16+
export default Popup;

Sample-01/src/index.js

+10-5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// Import necessary dependencies
12
import React from "react";
23
import ReactDOM from "react-dom";
34
import "./index.css";
@@ -7,14 +8,17 @@ import { Auth0Provider } from "@auth0/auth0-react";
78
import history from "./utils/history";
89
import { getConfig } from "./config";
910

11+
// Define onRedirectCallback function
1012
const onRedirectCallback = (appState) => {
1113
history.push(
1214
appState && appState.returnTo ? appState.returnTo : window.location.pathname
1315
);
1416
};
1517

18+
// Get Auth0 configuration
1619
const config = getConfig();
1720

21+
// Configuration for Auth0Provider
1822
const providerConfig = {
1923
domain: config.domain,
2024
clientId: config.clientId,
@@ -26,13 +30,14 @@ const providerConfig = {
2630
},
2731
};
2832

29-
ReactDOM.render(
33+
// Render the app using the new client rendering API
34+
ReactDOM.createRoot(document.getElementById('root')).render(
3035
<React.StrictMode>
3136
<Auth0Provider {...providerConfig}>
32-
<App />
37+
<App />
3338
</Auth0Provider>
34-
</React.StrictMode>,
35-
document.getElementById('root')
39+
</React.StrictMode>
3640
);
3741

38-
serviceWorker.unregister();
42+
// Unregister service worker
43+
serviceWorker.unregister();

0 commit comments

Comments
 (0)