From 0c0db322384312a3993c80152b47eee70f8182ec Mon Sep 17 00:00:00 2001 From: giostatic <116467840+giostatic@users.noreply.github.com> Date: Sat, 12 Apr 2025 20:24:08 -1000 Subject: [PATCH 1/2] Ability to update the request works, changes seem to be submitted to server based on local hosting, and added table UI to search results page --- techforgood/package-lock.json | 34 +++++ techforgood/package.json | 1 + techforgood/src/pages/request/Requests.js | 88 ++++++++++--- .../src/pages/request/UpdateRequestModal.js | 119 ++++++++++++++++++ .../src/pages/search/SearchRequests.js | 112 ++++++++++++----- 5 files changed, 304 insertions(+), 50 deletions(-) create mode 100644 techforgood/src/pages/request/UpdateRequestModal.js diff --git a/techforgood/package-lock.json b/techforgood/package-lock.json index 5d5a336..0a43fd8 100644 --- a/techforgood/package-lock.json +++ b/techforgood/package-lock.json @@ -14,6 +14,7 @@ "react": "^19.0.0", "react-dom": "^19.0.0", "react-hook-form": "^7.54.2", + "react-modal": "^3.16.3", "react-router-dom": "^7.1.5", "react-scripts": "5.0.1" }, @@ -7890,6 +7891,11 @@ "url": "https://github.com/sindresorhus/execa?sponsor=1" } }, + "node_modules/exenv": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/exenv/-/exenv-1.2.2.tgz", + "integrity": "sha512-Z+ktTxTwv9ILfgKCk32OX3n/doe+OcLTRtqK9pcL+JsP3J1/VW8Uvl4ZjLlKqeW4rzK4oesDOGMEMRIZqtP4Iw==" + }, "node_modules/exit": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/exit/-/exit-0.1.2.tgz", @@ -13655,6 +13661,26 @@ "resolved": "https://registry.npmjs.org/react-is/-/react-is-17.0.2.tgz", "integrity": "sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w==" }, + "node_modules/react-lifecycles-compat": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/react-lifecycles-compat/-/react-lifecycles-compat-3.0.4.tgz", + "integrity": "sha512-fBASbA6LnOU9dOU2eW7aQ8xmYBSXUIWr+UmF9b1efZBazGNO+rcXT/icdKnYm2pTwcRylVUYwW7H1PHfLekVzA==" + }, + "node_modules/react-modal": { + "version": "3.16.3", + "resolved": "https://registry.npmjs.org/react-modal/-/react-modal-3.16.3.tgz", + "integrity": "sha512-yCYRJB5YkeQDQlTt17WGAgFJ7jr2QYcWa1SHqZ3PluDmnKJ/7+tVU+E6uKyZ0nODaeEj+xCpK4LcSnKXLMC0Nw==", + "dependencies": { + "exenv": "^1.2.0", + "prop-types": "^15.7.2", + "react-lifecycles-compat": "^3.0.0", + "warning": "^4.0.3" + }, + "peerDependencies": { + "react": "^0.14.0 || ^15.0.0 || ^16 || ^17 || ^18 || ^19", + "react-dom": "^0.14.0 || ^15.0.0 || ^16 || ^17 || ^18 || ^19" + } + }, "node_modules/react-refresh": { "version": "0.11.0", "resolved": "https://registry.npmjs.org/react-refresh/-/react-refresh-0.11.0.tgz", @@ -16187,6 +16213,14 @@ "makeerror": "1.0.12" } }, + "node_modules/warning": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/warning/-/warning-4.0.3.tgz", + "integrity": "sha512-rpJyN222KWIvHJ/F53XSZv0Zl/accqHR8et1kpaMTD/fLCRxtV8iX8czMzY7sVZupTI3zcUTg8eycS2kNF9l6w==", + "dependencies": { + "loose-envify": "^1.0.0" + } + }, "node_modules/watchpack": { "version": "2.4.2", "resolved": "https://registry.npmjs.org/watchpack/-/watchpack-2.4.2.tgz", diff --git a/techforgood/package.json b/techforgood/package.json index 1e67ba2..9573e33 100644 --- a/techforgood/package.json +++ b/techforgood/package.json @@ -9,6 +9,7 @@ "react": "^19.0.0", "react-dom": "^19.0.0", "react-hook-form": "^7.54.2", + "react-modal": "^3.16.3", "react-router-dom": "^7.1.5", "react-scripts": "5.0.1" }, diff --git a/techforgood/src/pages/request/Requests.js b/techforgood/src/pages/request/Requests.js index 3223c7a..85c5cbb 100644 --- a/techforgood/src/pages/request/Requests.js +++ b/techforgood/src/pages/request/Requests.js @@ -2,6 +2,7 @@ import { useEffect, useState } from 'react'; import getRequests from '../../features/firebase/auth/getRequests'; import deleteRequest from '../../features/firebase/auth/deleteRequest'; import { useAuth } from '../../features/firebase/AuthProvider'; +import UpdateRequestModal from './UpdateRequestModal'; // Import the modal component const UserRequests = () => { const { user, loading: authLoading } = useAuth(); @@ -10,6 +11,10 @@ const UserRequests = () => { const [error, setError] = useState(null); const [currentPage, setCurrentPage] = useState(1); const resultsPerPage = 5; + const [isModalOpen, setIsModalOpen] = useState(false); + const [selectedRequest, setSelectedRequest] = useState(null); + const [successMessage, setSuccessMessage] = useState(''); // State for success message + const [fadeOut, setFadeOut] = useState(false); // State for fade-out effect useEffect(() => { const fetchRequests = async () => { @@ -45,6 +50,16 @@ const UserRequests = () => { } }; + const handleEdit = (request) => { + setSelectedRequest(request); + setIsModalOpen(true); + }; + + const closeModal = () => { + setIsModalOpen(false); + setSelectedRequest(null); + }; + const handleNextPage = () => { setCurrentPage(prevPage => prevPage + 1); }; @@ -64,30 +79,52 @@ const UserRequests = () => { return (
+ {successMessage} +
+ )}| Title | Description | +Keywords | Date Created | Actions |
|---|---|---|---|---|
| {request.title} | -{request.description} | -{new Date(request.created).toLocaleDateString()} | -- - {/* onClick={() => handleEdit(request.id)} */} - - | -|
| {request.title} | ++ {request.description.length > 100 ? ( + handleEdit(request)} + > + {request.description.substring(0, 100)}... + + ) : ( + request.description + )} + | +{request.keywords ? request.keywords.join(', ') : 'N/A'} | +{new Date(request.created).toLocaleDateString()} | ++ + + | +
No results found
) : ( <> - {currentResults.map((result, index) => ( -{result.description.split(/\s/).map((word, idx) => {
- if (submittedQueryArr.includes(word.replace(/\W/, "").toLowerCase())){
- return
Submitted on: {new Date(result.created).toLocaleDateString()}
- {result.keywords ? ( -Keywords: {result.keywords.map((words, idx) => { - const words_split = words.split(/\s/) - const pieces = [] - for (const word of words_split){ +
| Title | +Description | +Keywords | +Date Created | +Actions | +
|---|---|---|---|---|
| {result.title.split(/\s/).map((word, idx) => {
if (submittedQueryArr.includes(word.replace(/\W/, "").toLowerCase())){
- pieces.push( |
+ {result.description.split(/\s/).map((word, idx) => {
+ if (submittedQueryArr.includes(word.replace(/\W/, "").toLowerCase())){
+ return |
+ {result.keywords ? (
+ Keywords: {result.keywords.map((words, idx) => {
+ const words_split = words.split(/\s/)
+ const pieces = []
+ for (const word of words_split){
+ if (submittedQueryArr.includes(word.replace(/\W/, "").toLowerCase())){
+ pieces.push( |
+ ) : (
+ <>>
+ )}
+ Submitted on: {new Date(result.created).toLocaleDateString()} | ++ + | +
Page {currentPage}
{currentPage > 1 && } @@ -110,4 +125,33 @@ function SearchRequests() { ); } +const styles = { + requestTable: { + collumns: '10', + borderTop: '1px solid black', + borderBottom: '1px solid black', + margin: '0 auto', + width: '60%', + borderCollapse: 'collapse', + }, + tableHeaderRow: { + backgroundColor: '#f2f2f2', + borderBottom: '1px solid black', + }, + requestTableHeader: { + fontSize: '18px', + padding: '10px', + }, + requestTitleHeader: { + textTransform: 'capitalize', + padding: '10px', + fontWeight: 'bold', + }, + actionsStyling: { + gap: '5px', + padding: '5px', + }, +}; + + export default SearchRequests; From 932313b419076bd04a5f22cccba0d1678abd59fc Mon Sep 17 00:00:00 2001 From: giostatic <116467840+giostatic@users.noreply.github.com> Date: Wed, 23 Apr 2025 10:55:38 -1000 Subject: [PATCH 2/2] files were automatically updated after firebase deployment. can ignore these changes. --- techforgood/build/asset-manifest.json | 6 +++--- techforgood/build/index.html | 2 +- techforgood/build/static/css/main.94d3a9b7.css.map | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/techforgood/build/asset-manifest.json b/techforgood/build/asset-manifest.json index 9c2d4c7..82c9cec 100644 --- a/techforgood/build/asset-manifest.json +++ b/techforgood/build/asset-manifest.json @@ -1,13 +1,13 @@ { "files": { "main.css": "/static/css/main.94d3a9b7.css", - "main.js": "/static/js/main.8d564318.js", + "main.js": "/static/js/main.c4fc4305.js", "index.html": "/index.html", "main.94d3a9b7.css.map": "/static/css/main.94d3a9b7.css.map", - "main.8d564318.js.map": "/static/js/main.8d564318.js.map" + "main.c4fc4305.js.map": "/static/js/main.c4fc4305.js.map" }, "entrypoints": [ "static/css/main.94d3a9b7.css", - "static/js/main.8d564318.js" + "static/js/main.c4fc4305.js" ] } \ No newline at end of file diff --git a/techforgood/build/index.html b/techforgood/build/index.html index 97bc208..5f34c7a 100644 --- a/techforgood/build/index.html +++ b/techforgood/build/index.html @@ -1 +1 @@ -