From 245a08c00f7316223f8268f4b6882b20fc619985 Mon Sep 17 00:00:00 2001 From: Will Sams Date: Fri, 22 May 2026 13:48:17 -0400 Subject: [PATCH 1/3] Fix modal wiring, Book button placement, and stale deps --- frontend/package.json | 3 +-- frontend/src/main.jsx | 7 ++++++- frontend/src/screens/home/index.jsx | 11 ++++++++++- frontend/src/screens/home/tabs/DefaultTab.jsx | 13 +++++++------ frontend/src/shared/base/baseApi.js | 10 +++++----- frontend/src/shared/utils/urls.js | 8 ++++++-- tools/env.example.sh | 2 ++ 7 files changed, 37 insertions(+), 17 deletions(-) diff --git a/frontend/package.json b/frontend/package.json index fe8fc0b..8d24ad7 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -15,11 +15,9 @@ "dependencies": { "@reduxjs/toolkit": "^2.0.1", "axios": "^1.6.7", - "axios-mock-adapter": "^1.22.0", "bootstrap": "^5.2.0", "history": "^5.3.0", "lodash": "^4.17.21", - "moment": "^2.30.1", "react": "^18.2.0", "react-bootstrap": "^2.10.1", "react-dom": "^18.2.0", @@ -37,6 +35,7 @@ "@babel/plugin-syntax-jsx": "^7.23.3", "@babel/preset-env": "^7.23.9", "@babel/preset-react": "^7.23.3", + "axios-mock-adapter": "^1.22.0", "@testing-library/jest-dom": "^6.4.1", "@testing-library/react": "^14.2.1", "@testing-library/user-event": "^14.5.2", diff --git a/frontend/src/main.jsx b/frontend/src/main.jsx index 8567820..3ee772f 100644 --- a/frontend/src/main.jsx +++ b/frontend/src/main.jsx @@ -9,7 +9,12 @@ import { createBaseApi } from '@/shared/base'; import { getApiUrl } from '@/shared/utils/urls'; import { store } from './configureStore'; -createBaseApi(getApiUrl(), store).then(() => { +const credentials = { + username: import.meta.env.VITE_API_USERNAME ?? 'example-user', + password: import.meta.env.VITE_API_PASSWORD ?? 'example-user', +}; + +createBaseApi(getApiUrl(), store, credentials).then(() => { ReactDOM.createRoot(document.getElementById('react-app')).render( diff --git a/frontend/src/screens/home/index.jsx b/frontend/src/screens/home/index.jsx index 72a2872..0aea5da 100644 --- a/frontend/src/screens/home/index.jsx +++ b/frontend/src/screens/home/index.jsx @@ -20,9 +20,15 @@ const HomeComponent = ({ const confirmation = { isOpen: useSelector((state) => state?.shared?.confirmationModalIsOpen), message: useSelector((state) => state?.shared?.confirmationModalMessage), - canecllationText: useSelector( + cancellationText: useSelector( (state) => state?.shared?.confirmationModalCancellationText, ), + confirmationText: useSelector( + (state) => state?.shared?.confirmationModalText, + ), + confirmButtonStyle: useSelector( + (state) => state?.shared?.confirmationModalButtonStyle, + ), title: useSelector((state) => state?.shared?.confirmationModalTitle), }; @@ -73,6 +79,9 @@ const HomeComponent = ({ isOpen={confirmation.isOpen} title={confirmation.title} message={confirmation.message} + confirmationText={confirmation.confirmationText} + cancellationText={confirmation.cancellationText} + confirmButtonStyle={confirmation.confirmButtonStyle} handleConfirm={handleConfirmAction} handleReject={handleRejectAction} /> diff --git a/frontend/src/screens/home/tabs/DefaultTab.jsx b/frontend/src/screens/home/tabs/DefaultTab.jsx index 51010b4..902b94e 100644 --- a/frontend/src/screens/home/tabs/DefaultTab.jsx +++ b/frontend/src/screens/home/tabs/DefaultTab.jsx @@ -16,7 +16,12 @@ const DefaultTab = ({ return (
-

Reservations

+
+

Reservations

+ + + +
{loading && reservations.length === 0 && } {!loading && reservations.length === 0 && ( @@ -31,11 +36,7 @@ const DefaultTab = ({ Stay End Date Total Charge - - - - - + diff --git a/frontend/src/shared/base/baseApi.js b/frontend/src/shared/base/baseApi.js index 78a74e1..d580cc4 100644 --- a/frontend/src/shared/base/baseApi.js +++ b/frontend/src/shared/base/baseApi.js @@ -39,11 +39,11 @@ const handleResponseError = (error, store) => { return Promise.reject(error); }; -const getToken = async (url) => { +const getToken = async (url, credentials = {}) => { const formData = new FormData(); formData.append('grant_type', 'password'); - formData.append('username', 'example-user'); - formData.append('password', 'example-user'); + formData.append('username', credentials.username ?? 'example-user'); + formData.append('password', credentials.password ?? 'example-user'); const response = await axios.post(`${url}/token`, formData, { headers: { @@ -54,9 +54,9 @@ const getToken = async (url) => { return response?.data?.access_token || ''; }; -export const createBaseApi = async (url, store) => { +export const createBaseApi = async (url, store, credentials = {}) => { try { - const tokenValue = await getToken(url); + const tokenValue = await getToken(url, credentials); instance = createInstance(url, tokenValue); instance.interceptors.request.use( diff --git a/frontend/src/shared/utils/urls.js b/frontend/src/shared/utils/urls.js index 9af97e3..3b4cd1b 100644 --- a/frontend/src/shared/utils/urls.js +++ b/frontend/src/shared/utils/urls.js @@ -1,2 +1,6 @@ -/* c8 ignore next */ -export const getApiUrl = () => `${import.meta.env.VITE_RESERVATION_API}`; +/* c8 ignore next 4 */ +export const getApiUrl = () => { + const url = import.meta.env.VITE_RESERVATION_API; + if (!url) throw new Error('VITE_RESERVATION_API is not set'); + return url; +}; diff --git a/tools/env.example.sh b/tools/env.example.sh index 3fc4db8..33d8ad7 100644 --- a/tools/env.example.sh +++ b/tools/env.example.sh @@ -9,6 +9,8 @@ export REFRESH_SECRET_KEY=s3cr3t-k3y export COOKIE_EXPIRATION=86400 export FRONTEND_PORT=3000 +export VITE_API_USERNAME=example-user +export VITE_API_PASSWORD=example-user export RESERVATION_PORT=8080 export RESERVATION_API=http://localhost:${RESERVATION_PORT}/${ENV} From f9bf33f069dce9d4f5559e32a7b502991f25e294 Mon Sep 17 00:00:00 2001 From: Will Sams Date: Fri, 22 May 2026 13:51:48 -0400 Subject: [PATCH 2/3] Refresh changes after booking a reservation --- frontend/src/screens/home/reducers/home.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/frontend/src/screens/home/reducers/home.js b/frontend/src/screens/home/reducers/home.js index 7c0cca9..2b4d73e 100644 --- a/frontend/src/screens/home/reducers/home.js +++ b/frontend/src/screens/home/reducers/home.js @@ -26,6 +26,14 @@ const actionHandlers = { loading: false, }; }, + [onSuccessful(actionTypes.CREATE_RESERVATION)]: (state, action) => { + const reservations = action?.response?.data || []; + return { + ...state, + reservations, + loading: false, + }; + }, }; const reducer = createComponentReducer( From bef912bde4b940f3d4498aa0b2060931247fe926 Mon Sep 17 00:00:00 2001 From: Will Sams Date: Fri, 22 May 2026 13:53:31 -0400 Subject: [PATCH 3/3] Forget Pendleton --- frontend/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/index.html b/frontend/index.html index 6814594..653917f 100644 --- a/frontend/index.html +++ b/frontend/index.html @@ -24,7 +24,7 @@