From 333bcabea5c40e6590f9061b9b36c11e94465176 Mon Sep 17 00:00:00 2001
From: Lor3wp <61760289+Lor3wp@users.noreply.github.com>
Date: Wed, 6 Dec 2023 23:23:36 +0200
Subject: [PATCH 1/5] changes
---
src/components/BankButton.jsx | 29 ++++++++++++++++++++++++++---
src/components/BankType.jsx | 11 ++++++++++-
src/components/UserForm.jsx | 25 -------------------------
src/pages/RentProcess.jsx | 13 ++++++++-----
4 files changed, 44 insertions(+), 34 deletions(-)
diff --git a/src/components/BankButton.jsx b/src/components/BankButton.jsx
index a112a9b..2b1d74c 100644
--- a/src/components/BankButton.jsx
+++ b/src/components/BankButton.jsx
@@ -4,17 +4,39 @@ import { useState } from 'react';
import PopUpWarningModal from '../components/PopUpWarningModal';
import { useNavigate } from 'react-router-dom';
import { Trans, useTranslation } from 'react-i18next';
-
-const BankButton = ({ logo, bankName, rentId }) => {
+import useApi from '../hooks/useApi';
+// import { useStepper } from '../hooks/useStepper';
+const BankButton = ({ logo, bankName, rentId, randomUUID }) => {
const [showWarningModal, setShowWarningModal] = useState(false);
const navigate = useNavigate();
const { t } = useTranslation();
+ // const { userData } = useStepper();
+ // const { postRequest } = useApi();
- const handleClick = (bankName) => {
+ const handleClick = async (bankName) => {
if (bankName === 'HSY') {
handleOpenWarningModal();
} else {
+ // try {
+ // const bodyData = {
+ // customerInfo: {
+ // name: userData.firstName,
+ // lastName: userData.lastName,
+ // phoneNumber: userData.phoneNumber,
+ // email: userData.emailAddress,
+ // address: userData.streetName,
+ // zipCode: userData.postalCode,
+ // city: userData.cityName,
+ // },
+ // uuid: randomUUID,
+ // };
+
+ // const responce = await postRequest('add-reservation', bodyData);
+ // console.log('BankButton.jsx 36', responce);
+ // } catch (error) {
+ // console.log(error);
+ // }
navigate(`/rent-successful/${rentId}`);
}
};
@@ -69,6 +91,7 @@ BankButton.propTypes = {
logo: PropTypes.any.isRequired,
bankName: PropTypes.string,
rentId: PropTypes.string.isRequired,
+ randomUUID: PropTypes.string.isRequired,
};
export default BankButton;
diff --git a/src/components/BankType.jsx b/src/components/BankType.jsx
index 68b56bd..32d082d 100644
--- a/src/components/BankType.jsx
+++ b/src/components/BankType.jsx
@@ -2,7 +2,14 @@ import PropTypes from 'prop-types';
import BankButton from './BankButton';
import styles from '../css/BankButton.module.css';
-const BankType = ({ gridName, title, arrayName, paymentName, rentId }) => {
+const BankType = ({
+ gridName,
+ title,
+ arrayName,
+ paymentName,
+ rentId,
+ randomUUID,
+}) => {
return (
{title}
@@ -14,6 +21,7 @@ const BankType = ({ gridName, title, arrayName, paymentName, rentId }) => {
bankName={item.bankName}
key={item.bankName}
rentId={rentId}
+ randomUUID={randomUUID}
>
))}
@@ -28,5 +36,6 @@ BankType.propTypes = {
arrayName: PropTypes.array,
paymentName: PropTypes.string,
rentId: PropTypes.string.isRequired,
+ randomUUID: PropTypes.string.isRequired,
};
export default BankType;
diff --git a/src/components/UserForm.jsx b/src/components/UserForm.jsx
index 57e41f4..d628796 100644
--- a/src/components/UserForm.jsx
+++ b/src/components/UserForm.jsx
@@ -13,7 +13,6 @@ import PopUpWarningModal from '../components/PopUpWarningModal';
import hsyLogo from '../assets/hsy_logo_dark.png';
import { useStepper } from '../hooks/useStepper';
import { useTranslation } from 'react-i18next';
-import useApi from '../hooks/useApi';
const UserForm = ({ onSubmit, onPrevStep }) => {
const [validated, setValidated] = useState(false);
const [showInfoModal, setShowInfoModal] = useState(false);
@@ -31,10 +30,8 @@ const UserForm = ({ onSubmit, onPrevStep }) => {
setUserData,
acceptTerms,
setAcceptTerms,
- randomUUID,
} = useStepper();
- const { postRequest } = useApi();
const { t } = useTranslation();
const navigate = useNavigate();
@@ -187,27 +184,6 @@ const UserForm = ({ onSubmit, onPrevStep }) => {
postalCode: submitEvent.elements.postalCode.value,
cityName: submitEvent.elements.cityName.value,
});
-
- try {
- const bodyData = {
- customerInfo: {
- name: submitEvent.elements.firstName.value,
- lastName: submitEvent.elements.lastName.value,
- phoneNumber: submitEvent.elements.phoneNumber.value,
- email: submitEvent.elements.emailAddress.value,
- addres: submitEvent.elements.streetName.value,
- zipCode: submitEvent.elements.postalCode.value,
- city: submitEvent.elements.cityName.value,
- },
- idPrepaid: false,
- uuid: randomUUID,
- };
-
- const responce = await postRequest('add-reservation', bodyData);
- console.log('UserForm.jsx 209', responce);
- } catch (error) {
- console.log(error);
- }
};
const handleOpenTosModal = () => {
@@ -380,7 +356,6 @@ UserForm.propTypes = {
onSubmit: PropTypes.func.isRequired,
handleInfoModal: PropTypes.func,
onPrevStep: PropTypes.func.isRequired,
- randomUUID: PropTypes.string.isRequired,
};
export default UserForm;
diff --git a/src/pages/RentProcess.jsx b/src/pages/RentProcess.jsx
index 6dfd83f..909f30f 100644
--- a/src/pages/RentProcess.jsx
+++ b/src/pages/RentProcess.jsx
@@ -26,7 +26,7 @@ import BankType from '../components/BankType';
import PopUpWarningModal from '../components/PopUpWarningModal';
import { useTranslation } from 'react-i18next';
import { v4 as uuidv4 } from 'uuid';
-const RentProcessPage = () => {
+const RentProcessPage = async () => {
const countdownDuration = 20 * 60 * 1000;
const [activeStep, setActiveStep] = useState(0);
@@ -40,9 +40,9 @@ const RentProcessPage = () => {
calculateReservationDeadline(),
);
- const mockRentData = {
- id: '656e0884162df1917d30e826',
- };
+ const mockRentData = {
+ id: '656e0884162df1917d30e826',
+ };
const { t } = useTranslation();
@@ -145,6 +145,7 @@ const RentProcessPage = () => {
title={t('Mobiilimaksutavat')}
arrayName={mobileBanks}
paymentName={styles.mobilePayment}
+ randomUUID={randomUUID}
/>
{
title={t('Korttimaksutavat')}
arrayName={cardPayments}
paymentName={styles.cardPayment}
+ randomUUID={randomUUID}
/>
{
title={t('Pankkimaksutavat')}
arrayName={bankPayments}
paymentName={styles.bankPayment}
+ randomUUID={randomUUID}
/>
{
title={t('Maksu paikan päällä')}
arrayName={irlPayments}
paymentName={styles.irlPayment}
+ randomUUID={randomUUID}
/>
);
@@ -196,7 +200,6 @@ const RentProcessPage = () => {
handleWarningModal={handleWarningModal}
onSubmit={handleFormSubmit}
onPrevStep={handlePrevStep}
- randomUUID={randomUUID}
/>
);
case 3:
From 94173bda1ba91e82618653e158f94c3c63f118c6 Mon Sep 17 00:00:00 2001
From: Lor3wp <61760289+Lor3wp@users.noreply.github.com>
Date: Wed, 6 Dec 2023 23:27:35 +0200
Subject: [PATCH 2/5] working
---
src/components/BankButton.jsx | 42 +++++++++++++++++------------------
src/components/UserForm.jsx | 2 +-
src/pages/RentProcess.jsx | 2 +-
3 files changed, 23 insertions(+), 23 deletions(-)
diff --git a/src/components/BankButton.jsx b/src/components/BankButton.jsx
index 2b1d74c..2b233f7 100644
--- a/src/components/BankButton.jsx
+++ b/src/components/BankButton.jsx
@@ -5,38 +5,38 @@ import PopUpWarningModal from '../components/PopUpWarningModal';
import { useNavigate } from 'react-router-dom';
import { Trans, useTranslation } from 'react-i18next';
import useApi from '../hooks/useApi';
-// import { useStepper } from '../hooks/useStepper';
+import { useStepper } from '../hooks/useStepper';
const BankButton = ({ logo, bankName, rentId, randomUUID }) => {
const [showWarningModal, setShowWarningModal] = useState(false);
const navigate = useNavigate();
const { t } = useTranslation();
- // const { userData } = useStepper();
- // const { postRequest } = useApi();
+ const { userData } = useStepper();
+ const { postRequest } = useApi();
const handleClick = async (bankName) => {
if (bankName === 'HSY') {
handleOpenWarningModal();
} else {
- // try {
- // const bodyData = {
- // customerInfo: {
- // name: userData.firstName,
- // lastName: userData.lastName,
- // phoneNumber: userData.phoneNumber,
- // email: userData.emailAddress,
- // address: userData.streetName,
- // zipCode: userData.postalCode,
- // city: userData.cityName,
- // },
- // uuid: randomUUID,
- // };
+ try {
+ const bodyData = {
+ customerInfo: {
+ name: userData.firstName,
+ lastName: userData.lastName,
+ phoneNumber: userData.phoneNumber,
+ email: userData.emailAddress,
+ address: userData.streetName,
+ zipCode: userData.postalCode,
+ city: userData.cityName,
+ },
+ uuid: randomUUID,
+ };
- // const responce = await postRequest('add-reservation', bodyData);
- // console.log('BankButton.jsx 36', responce);
- // } catch (error) {
- // console.log(error);
- // }
+ const responce = await postRequest('add-reservation', bodyData);
+ console.log('BankButton.jsx 36', responce);
+ } catch (error) {
+ console.log(error);
+ }
navigate(`/rent-successful/${rentId}`);
}
};
diff --git a/src/components/UserForm.jsx b/src/components/UserForm.jsx
index d628796..170185d 100644
--- a/src/components/UserForm.jsx
+++ b/src/components/UserForm.jsx
@@ -174,7 +174,7 @@ const UserForm = ({ onSubmit, onPrevStep }) => {
navigate('/', { replace: true });
};
- const handleConfirmRentInfo = async () => {
+ const handleConfirmRentInfo = () => {
onSubmit({
firstName: submitEvent.elements.firstName.value,
lastName: submitEvent.elements.lastName.value,
diff --git a/src/pages/RentProcess.jsx b/src/pages/RentProcess.jsx
index 909f30f..8cd0a9f 100644
--- a/src/pages/RentProcess.jsx
+++ b/src/pages/RentProcess.jsx
@@ -26,7 +26,7 @@ import BankType from '../components/BankType';
import PopUpWarningModal from '../components/PopUpWarningModal';
import { useTranslation } from 'react-i18next';
import { v4 as uuidv4 } from 'uuid';
-const RentProcessPage = async () => {
+const RentProcessPage = () => {
const countdownDuration = 20 * 60 * 1000;
const [activeStep, setActiveStep] = useState(0);
From 534e592861115d1a2671b68fba30201085797d7c Mon Sep 17 00:00:00 2001
From: Lor3wp <61760289+Lor3wp@users.noreply.github.com>
Date: Wed, 6 Dec 2023 23:37:59 +0200
Subject: [PATCH 3/5] id passed
---
src/components/BankButton.jsx | 5 +++--
src/hooks/useApi.js | 2 ++
2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/src/components/BankButton.jsx b/src/components/BankButton.jsx
index 2b233f7..05b1de8 100644
--- a/src/components/BankButton.jsx
+++ b/src/components/BankButton.jsx
@@ -8,6 +8,7 @@ import useApi from '../hooks/useApi';
import { useStepper } from '../hooks/useStepper';
const BankButton = ({ logo, bankName, rentId, randomUUID }) => {
const [showWarningModal, setShowWarningModal] = useState(false);
+
const navigate = useNavigate();
const { t } = useTranslation();
@@ -33,11 +34,11 @@ const BankButton = ({ logo, bankName, rentId, randomUUID }) => {
};
const responce = await postRequest('add-reservation', bodyData);
- console.log('BankButton.jsx 36', responce);
+ console.log('BankButton.jsx 36', responce.updatedReservation._id);
+ navigate(`/rent-successful/${responce.updatedReservation._id}`);
} catch (error) {
console.log(error);
}
- navigate(`/rent-successful/${rentId}`);
}
};
diff --git a/src/hooks/useApi.js b/src/hooks/useApi.js
index 9dc52e1..585d124 100644
--- a/src/hooks/useApi.js
+++ b/src/hooks/useApi.js
@@ -45,6 +45,7 @@ const useApi = () => {
try {
const response = await postRequest(endpoint, data);
handleApiSuccess(response);
+ return response;
} catch (error) {
handleApiError(error);
}
@@ -53,6 +54,7 @@ const useApi = () => {
try {
const response = await deleteRequest(endpoint, uuid);
handleApiSuccess(response);
+ return response;
} catch (error) {
handleApiError(error);
}
From 839c089516fbba165a72ef110443d07b0582b66b Mon Sep 17 00:00:00 2001
From: Lor3wp <61760289+Lor3wp@users.noreply.github.com>
Date: Wed, 6 Dec 2023 23:44:09 +0200
Subject: [PATCH 4/5] get rent info
---
src/components/BankButton.jsx | 3 +--
src/utils/axios.js | 6 +-----
2 files changed, 2 insertions(+), 7 deletions(-)
diff --git a/src/components/BankButton.jsx b/src/components/BankButton.jsx
index 05b1de8..62bfdd0 100644
--- a/src/components/BankButton.jsx
+++ b/src/components/BankButton.jsx
@@ -6,7 +6,7 @@ import { useNavigate } from 'react-router-dom';
import { Trans, useTranslation } from 'react-i18next';
import useApi from '../hooks/useApi';
import { useStepper } from '../hooks/useStepper';
-const BankButton = ({ logo, bankName, rentId, randomUUID }) => {
+const BankButton = ({ logo, bankName, randomUUID }) => {
const [showWarningModal, setShowWarningModal] = useState(false);
const navigate = useNavigate();
@@ -91,7 +91,6 @@ const BankButton = ({ logo, bankName, rentId, randomUUID }) => {
BankButton.propTypes = {
logo: PropTypes.any.isRequired,
bankName: PropTypes.string,
- rentId: PropTypes.string.isRequired,
randomUUID: PropTypes.string.isRequired,
};
diff --git a/src/utils/axios.js b/src/utils/axios.js
index eb25be9..d4dd889 100644
--- a/src/utils/axios.js
+++ b/src/utils/axios.js
@@ -1,10 +1,6 @@
import axios from 'axios';
-import { NODE_ENV, PUBLIC_DOMAIN, PUBLIC_PORT } from './constants';
-const baseURL =
- NODE_ENV === 'production'
- ? 'https://hsytrailerapi.azurewebsites.net/api/'
- : `http://${PUBLIC_DOMAIN ?? 'localhost'}:${PUBLIC_PORT ?? '3000'}/api/`;
+const baseURL = 'https://hsytrailerapi.azurewebsites.net/api/';
const axiosInstance = axios.create({
baseURL: baseURL,
From ffe058725e6db9dab7d280a2e1d2178c53ad953a Mon Sep 17 00:00:00 2001
From: Lor3wp <61760289+Lor3wp@users.noreply.github.com>
Date: Thu, 7 Dec 2023 00:23:57 +0200
Subject: [PATCH 5/5] fixed timezone issues with calendar date selection
---
src/components/Calendar.jsx | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/src/components/Calendar.jsx b/src/components/Calendar.jsx
index 4ff5054..ce69a8e 100644
--- a/src/components/Calendar.jsx
+++ b/src/components/Calendar.jsx
@@ -28,7 +28,9 @@ const RentCalendar = ({ futureDates, setSelectedDate }) => {
};
const handleChange = (date) => {
- setSelectedDate(date);
+ date.setHours(date.getHours() + 12);
+ setSelectedDate(date);
+ console.log(date.getHours());
};
const tileDisabled = ({ date }) => {