From dcb7c5b79dd4fb8c646f6aaa77bafb48291a5030 Mon Sep 17 00:00:00 2001 From: Avaneeshakrishna Date: Mon, 15 Sep 2025 15:12:53 -0700 Subject: [PATCH] Add latest FRUIT-69 changes for UI --- .gitignore | 1 + README.md | 194 ++++-------------- frontend/.gitignore | 25 +++ frontend/package-lock.json | 6 +- frontend/package.json | 6 +- frontend/public/App.jsx | 17 ++ frontend/public/favicon.ico | Bin 0 -> 3870 bytes frontend/public/index.html | 43 ++++ frontend/src/ActivitiesList.jsx | 42 ++++ frontend/src/AgrotourismBookingDashboard.jsx | 19 ++ frontend/src/App.css | 38 ++++ frontend/src/App.jsx | 17 ++ frontend/src/BookingForm.jsx | 205 +++++++++++++++++++ frontend/src/ManageBookings.jsx | 47 +++++ frontend/src/index.css | 13 ++ frontend/src/index.js | 6 + 16 files changed, 518 insertions(+), 161 deletions(-) create mode 100644 .gitignore create mode 100644 frontend/public/App.jsx create mode 100644 frontend/public/favicon.ico create mode 100644 frontend/public/index.html create mode 100644 frontend/src/ActivitiesList.jsx create mode 100644 frontend/src/AgrotourismBookingDashboard.jsx create mode 100644 frontend/src/App.css create mode 100644 frontend/src/App.jsx create mode 100644 frontend/src/BookingForm.jsx create mode 100644 frontend/src/ManageBookings.jsx create mode 100644 frontend/src/index.css create mode 100644 frontend/src/index.js diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1412452 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +dynamodb_local_latest/ \ No newline at end of file diff --git a/README.md b/README.md index a5d33a9..58beeac 100644 --- a/README.md +++ b/README.md @@ -1,186 +1,70 @@ -# Agrinet - Decentralized Agricultural Marketplace 🌱 +# Getting Started with Create React App -## Overview +This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app). -Agrinet is a decentralized agricultural trading and service platform built to enhance transparency, trust, and efficiency in agricultural markets. It connects producers, consumers, and service providers while ensuring secure transactions, reputation-based ratings, and localized economic sustainability. +## Available Scripts -## Features +In the project directory, you can run: -#### Marketplace System 🏪 +### `npm start` -- Direct Market Access: Producers list goods, services, and contracts. -- Agrotourism Integration: Farmers can offer farm tours, events, and educational workshops. -- Service Marketplace: Users can provide or request agricultural services (e.g., logistics, maintenance). +Runs the app in the development mode.\ +Open [http://localhost:3000](http://localhost:3000) to view it in your browser. -#### Secure Transactions 🔒 +The page will reload when you make changes.\ +You may also see any lint errors in the console. -- LBTAS (Leveson-Based Trade Assessment Scale): Ensures a trust-based rating system. -- Dialog Recorder: Logs key transaction details for security and auditing. -- Machine Scrub Module: Filters and verifies transaction data. +### `npm test` -#### Key & Authentication System 🔑 +Launches the test runner in the interactive watch mode.\ +See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information. -- McEliese Key Generation: Ensures secure user identification. -- Key Transmission Limits: Auto-retirement after 3, 6, 9, 12, or 365 transmissions. -- Multi-Factor Verification: Email/phone validation with retry & lockout security. +### `npm run build` -#### PING System 📡 +Builds the app for production to the `build` folder.\ +It correctly bundles React in production mode and optimizes the build for the best performance. -- Production Progress Reporting: Allows contract buyers to track order status. -- Real-Time Notifications: Updates on market trends, contract changes, and service requests. +The build is minified and the filenames include the hashes.\ +Your app is ready to be deployed! -#### SMS Access 📱 +See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information. -- Query market and weather data through SMS using simple text commands. -- Supports local languages and queues messages offline with delivery confirmation. +### `npm run eject` -#### Financial Transactions 🏦 +**Note: this is a one-way operation. Once you `eject`, you can't go back!** -- Deposit & Donations to NTARI Account: Supports decentralized funding. -- Automated Payouts: Ensures secure fund disbursements upon transaction completion. +If you aren't satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project. -#### Decentralized Data Management 🌍 +Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you're on your own. -- User Profiles & Logs: Maintains key issuance logs parallel to user profiles. -- Geo-Filtering & Search Optimization: Enables market visibility based on location. +You don't have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn't feel obligated to use this feature. However we understand that this tool wouldn't be useful if you couldn't customize it when you are ready for it. -#### Square Foot Gardening Calculator 🌿 +## Learn More -- Plant spacing recommendations for common crops. -- Compatibility matrix to plan companion planting. -- Growth projections and seasonal schedules with visual grid layouts. +You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started). -## Technology Stack +To learn React, check out the [React documentation](https://reactjs.org/). -- Frontend: React with Next.js (responsive site structure) -- Backend: Node.js (API handling) -- Database: Amazon DynamoDB (for storing users, contracts, and transactions) -- Security: OAuth 2.0 / McEliese Key Cryptography -- Real-Time Processing: Webhooks & PING System - -## Installation & Setup +### Code Splitting -1. Clone the repository -``` -git clone https://github.com/YOUR_USERNAME/Fruitful.git -cd Agrinet -``` +This section has moved here: [https://facebook.github.io/create-react-app/docs/code-splitting](https://facebook.github.io/create-react-app/docs/code-splitting) -2. Setup the backend -``` -cd backend -npm install -node server.js -``` +### Analyzing the Bundle Size -3. Deploy the frontend -``` -cd frontend -npm install -npm run dev -``` +This section has moved here: [https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size](https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size) -For local development, set the `NEXT_PUBLIC_BACKEND_URL` environment variable to your backend's URL before running the frontend, for example: -``` -NEXT_PUBLIC_BACKEND_URL=http://localhost:5000 npm run dev -``` -Only environment variables prefixed with `NEXT_PUBLIC_` are exposed to the browser, so this prefix is required. -Alternatively, configure a proxy so that requests to `/api` are forwarded to the backend. +### Making a Progressive Web App -### Environment Variables +This section has moved here: [https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app](https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app) -The backend now uses Amazon DynamoDB. Set the following variables in your environment or `.env` file: +### Advanced Configuration -- `AWS_ACCESS_KEY_ID` -- `AWS_SECRET_ACCESS_KEY` -- `AWS_REGION` -- `DYNAMODB_ENDPOINT` *(optional, for DynamoDB Local e.g. `http://localhost:8000`)* -- `TWILIO_SID` -- `TWILIO_AUTH_TOKEN` -- `TWILIO_FROM_NUMBER` -- `TWILIO_STATUS_CALLBACK_URL` *(optional for delivery confirmation)* +This section has moved here: [https://facebook.github.io/create-react-app/docs/advanced-configuration](https://facebook.github.io/create-react-app/docs/advanced-configuration) -## Square Foot Gardening Usage +### Deployment -The backend includes a utility for planning square foot gardens. +This section has moved here: [https://facebook.github.io/create-react-app/docs/deployment](https://facebook.github.io/create-react-app/docs/deployment) -```javascript -const { planSeason } = require('./backend/utils/squareFootGardening'); - -const layout = [ - ['tomato', 'basil'], - ['lettuce', null], -]; - -const plan = planSeason(layout, '2024-03-01', 'spring'); -console.log(plan.grid); -console.log(plan.schedule); -``` - -The planner validates companion planting, projects growth timelines, and renders an ASCII grid of the garden. - -## API Endpoints - -Additional chat interface endpoints (e.g., `/conversations`, `/messages/:id`, `/stream/:id`) and their expected JSON -structures are documented inline in the frontend components -[`Sidebar.jsx`](frontend/chat-ui/src/components/Sidebar.jsx) and -[`ChatWindow.jsx`](frontend/chat-ui/src/components/ChatWindow.jsx). -### User Registration -#### POST /userRegistration -``` -{ - "name": "John Doe", - "email": "johndoe@example.com", - "location": "Kentucky, USA", - "role": "producer" -} -``` - -### Create Contract -#### POST /createContract -``` -{ - "producerId": "user123", - "type": "Tomato", - "variety": "Roma", - "category": "food", - "amountNeeded": "500 lbs", - "dateNeeded": "2025-03-15", - "pingRate": "weekly" -} -``` - -### Submit LBTAS Rating -#### POST /submitRating -``` -{ - "transactionId": "tx987", - "rating": 4 -} -``` - -## Contributing -We welcome contributions from the community! 🚀 - -1. Fork the repo -2. Create a feature branch -3. Submit a pull request - -### Checking for hardcoded URLs - -Run the following script to detect any hardcoded `localhost` references before committing code: - -```bash -./scripts/list-hardcoded-urls.sh -``` - -The script lists offending lines and exits with a nonzero status if any are found. -Existing references known to be safe are tracked in `scripts/hardcoded-url-allowlist.txt`. - -## License -MIT License – Feel free to modify and share. 📜 - -## Contact & Support -- NTARI https://www.ntari.org/ -- Email - tech@ntari.org -- Slack - [Join our community for discussions!](https://ntari.slack.com) +### `npm run build` fails to minify + +This section has moved here: [https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify](https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify) diff --git a/frontend/.gitignore b/frontend/.gitignore index 8be7598..8187374 100644 --- a/frontend/.gitignore +++ b/frontend/.gitignore @@ -2,3 +2,28 @@ node_modules/ .next/ chat-ui/dist/ + +# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. + +# dependencies +/node_modules +/.pnp +.pnp.js + +# testing +/coverage + +# production +/build + +# misc +.DS_Store +.env.local +.env.development.local +.env.test.local +.env.production.local + +npm-debug.log* +yarn-debug.log* +yarn-error.log* + diff --git a/frontend/package-lock.json b/frontend/package-lock.json index 2c91b78..481f016 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -8,9 +8,9 @@ "name": "agrinet-frontend", "version": "1.0.0", "dependencies": { - "next": "14.1.0", - "react": "18.2.0", - "react-dom": "18.2.0" + "next": "^14.1.0", + "react": "^18.2.0", + "react-dom": "^18.2.0" }, "devDependencies": { "eslint": "8.56.0", diff --git a/frontend/package.json b/frontend/package.json index 78f8d3c..6001bd8 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -13,9 +13,9 @@ "test-connection": "node test-connection.js" }, "dependencies": { - "next": "14.1.0", - "react": "18.2.0", - "react-dom": "18.2.0" + "next": "^14.1.0", + "react": "^18.2.0", + "react-dom": "^18.2.0" }, "devDependencies": { "eslint": "8.56.0", diff --git a/frontend/public/App.jsx b/frontend/public/App.jsx new file mode 100644 index 0000000..8b15b3e --- /dev/null +++ b/frontend/public/App.jsx @@ -0,0 +1,17 @@ +import React from 'react'; +import Container from '@mui/material/Container'; +import Typography from '@mui/material/Typography'; +import AgrotourismBookingDashboard from './AgrotourismBookingDashboard'; + +function App() { + return ( + + + Agrotourism Booking Platform + + + + ); +} + +export default App; \ No newline at end of file diff --git a/frontend/public/favicon.ico b/frontend/public/favicon.ico new file mode 100644 index 0000000000000000000000000000000000000000..a11777cc471a4344702741ab1c8a588998b1311a GIT binary patch literal 3870 zcma);c{J4h9>;%nil|2-o+rCuEF-(I%-F}ijC~o(k~HKAkr0)!FCj~d>`RtpD?8b; zXOC1OD!V*IsqUwzbMF1)-gEDD=A573Z-&G7^LoAC9|WO7Xc0Cx1g^Zu0u_SjAPB3vGa^W|sj)80f#V0@M_CAZTIO(t--xg= z!sii`1giyH7EKL_+Wi0ab<)&E_0KD!3Rp2^HNB*K2@PHCs4PWSA32*-^7d{9nH2_E zmC{C*N*)(vEF1_aMamw2A{ZH5aIDqiabnFdJ|y0%aS|64E$`s2ccV~3lR!u<){eS` z#^Mx6o(iP1Ix%4dv`t@!&Za-K@mTm#vadc{0aWDV*_%EiGK7qMC_(`exc>-$Gb9~W!w_^{*pYRm~G zBN{nA;cm^w$VWg1O^^<6vY`1XCD|s_zv*g*5&V#wv&s#h$xlUilPe4U@I&UXZbL z0)%9Uj&@yd03n;!7do+bfixH^FeZ-Ema}s;DQX2gY+7g0s(9;`8GyvPY1*vxiF&|w z>!vA~GA<~JUqH}d;DfBSi^IT*#lrzXl$fNpq0_T1tA+`A$1?(gLb?e#0>UELvljtQ zK+*74m0jn&)5yk8mLBv;=@}c{t0ztT<v;Avck$S6D`Z)^c0(jiwKhQsn|LDRY&w(Fmi91I7H6S;b0XM{e zXp0~(T@k_r-!jkLwd1_Vre^v$G4|kh4}=Gi?$AaJ)3I+^m|Zyj#*?Kp@w(lQdJZf4 z#|IJW5z+S^e9@(6hW6N~{pj8|NO*>1)E=%?nNUAkmv~OY&ZV;m-%?pQ_11)hAr0oAwILrlsGawpxx4D43J&K=n+p3WLnlDsQ$b(9+4 z?mO^hmV^F8MV{4Lx>(Q=aHhQ1){0d*(e&s%G=i5rq3;t{JC zmgbn5Nkl)t@fPH$v;af26lyhH!k+#}_&aBK4baYPbZy$5aF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sV+xS4E7aUn+U(K baj7?x%VD!5Cxk2YbYLNVeiXvvpMCWYo=by@ literal 0 HcmV?d00001 diff --git a/frontend/public/index.html b/frontend/public/index.html new file mode 100644 index 0000000..aa069f2 --- /dev/null +++ b/frontend/public/index.html @@ -0,0 +1,43 @@ + + + + + + + + + + + + + React App + + + +
+ + + diff --git a/frontend/src/ActivitiesList.jsx b/frontend/src/ActivitiesList.jsx new file mode 100644 index 0000000..79cc184 --- /dev/null +++ b/frontend/src/ActivitiesList.jsx @@ -0,0 +1,42 @@ +import React, { useEffect, useState } from 'react'; +import { Grid, Card, CardContent, CardActions, Button, Typography } from '@mui/material'; + +function ActivitiesList({ onSelect }) { + const [activities, setActivities] = useState([]); + const [loading, setLoading] = useState(true); + + useEffect(() => { + fetch('/api/agrotourism/all') + .then(res => res.json()) + .then(data => { + setActivities(data); + setLoading(false); + }); + }, []); + + //if (loading) return Loading activities...; + + return ( + + {activities.map(activity => ( + + + + {activity.title} + {activity.description} + Location: {activity.location} + Date: {activity.date} + Capacity: {activity.maxGuests} + Pricing: {activity.pricingTiers} + + + + + + + ))} + + ); +} + +export default ActivitiesList; \ No newline at end of file diff --git a/frontend/src/AgrotourismBookingDashboard.jsx b/frontend/src/AgrotourismBookingDashboard.jsx new file mode 100644 index 0000000..731d69e --- /dev/null +++ b/frontend/src/AgrotourismBookingDashboard.jsx @@ -0,0 +1,19 @@ +import React, { useState } from 'react'; +import ActivitiesList from './ActivitiesList'; +import BookingForm from './BookingForm'; +import ManageBookings from './ManageBookings'; + +function AgrotourismBookingDashboard() { + // const [selectedActivity, setSelectedActivity] = useState(null); + + // Remove selectedActivity logic + return ( +
+ + + +
+ ); +} + +export default AgrotourismBookingDashboard; \ No newline at end of file diff --git a/frontend/src/App.css b/frontend/src/App.css new file mode 100644 index 0000000..74b5e05 --- /dev/null +++ b/frontend/src/App.css @@ -0,0 +1,38 @@ +.App { + text-align: center; +} + +.App-logo { + height: 40vmin; + pointer-events: none; +} + +@media (prefers-reduced-motion: no-preference) { + .App-logo { + animation: App-logo-spin infinite 20s linear; + } +} + +.App-header { + background-color: #282c34; + min-height: 100vh; + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; + font-size: calc(10px + 2vmin); + color: white; +} + +.App-link { + color: #61dafb; +} + +@keyframes App-logo-spin { + from { + transform: rotate(0deg); + } + to { + transform: rotate(360deg); + } +} diff --git a/frontend/src/App.jsx b/frontend/src/App.jsx new file mode 100644 index 0000000..8b15b3e --- /dev/null +++ b/frontend/src/App.jsx @@ -0,0 +1,17 @@ +import React from 'react'; +import Container from '@mui/material/Container'; +import Typography from '@mui/material/Typography'; +import AgrotourismBookingDashboard from './AgrotourismBookingDashboard'; + +function App() { + return ( + + + Agrotourism Booking Platform + + + + ); +} + +export default App; \ No newline at end of file diff --git a/frontend/src/BookingForm.jsx b/frontend/src/BookingForm.jsx new file mode 100644 index 0000000..0baa860 --- /dev/null +++ b/frontend/src/BookingForm.jsx @@ -0,0 +1,205 @@ +import React, { useState } from 'react'; +import { + Box, TextField, Button, Typography, MenuItem, FormControlLabel, Checkbox, Select, InputLabel, FormControl, Divider +} from '@mui/material'; + +const activityTypes = [ + { value: 'farm_visit', label: 'Farm Visit' }, + { value: 'educational_tour', label: 'Educational Tour' }, + { value: 'agrotourism_activity', label: 'Agrotourism Activity' } +]; + +const pricingOptions = [ + { value: 'standard', label: 'Standard', price: 20 }, + { value: 'premium', label: 'Premium', price: 35 }, + { value: 'family_group', label: 'Family/Group', price: 15 }, + { value: 'student_educational', label: 'Student/Educational', price: 10 }, + { value: 'special_event', label: 'Special Event', price: 30 }, + { value: 'weekend_holiday', label: 'Weekend/Holiday', price: 25 } +]; + +const cancellationPolicyInfo = "24 hours before event for full refund"; + +function BookingForm({ onBooked }) { + const [activityType, setActivityType] = useState(''); + const [title, setTitle] = useState(''); + const [date, setDate] = useState(''); + const [guests, setGuests] = useState(1); + const [location, setLocation] = useState(''); + const [pricingTier, setPricingTier] = useState(''); + const [price, setPrice] = useState(''); + const [groupBooking, setGroupBooking] = useState(false); + const [specialEvent, setSpecialEvent] = useState(false); + // Payment fields + const [cardNumber, setCardNumber] = useState(''); + const [cardName, setCardName] = useState(''); + const [expiry, setExpiry] = useState(''); + const [cvc, setCvc] = useState(''); + const [loading, setLoading] = useState(false); + const [success, setSuccess] = useState(''); + + const handlePricingChange = (e) => { + const selected = pricingOptions.find(opt => opt.value === e.target.value); + setPricingTier(selected.value); + setPrice(selected.price); + }; + + const handleSubmit = async e => { + e.preventDefault(); + setLoading(true); + setSuccess(''); + // Simulate payment processing + await new Promise(res => setTimeout(res, 1200)); + // Send booking info to backend + await fetch('/api/bookings', { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({ + activityType, + title, + date, + guests, + location, + pricingTier, + price, + groupBooking, + specialEvent, + payment: { + cardNumber, + cardName, + expiry, + cvc + }, + cancellationPolicy: cancellationPolicyInfo + }) + }); + setLoading(false); + setSuccess('Booking & Payment successful!'); + if (onBooked) onBooked(); + }; + + return ( + + + Create Booking + + + Activity Type + + + setTitle(e.target.value)} + fullWidth + sx={{ my: 1 }} + required + /> + setDate(e.target.value)} + fullWidth + sx={{ my: 1 }} + InputLabelProps={{ shrink: true }} + required + /> + setGuests(e.target.value)} + fullWidth + sx={{ my: 1 }} + inputProps={{ min: 1 }} + required + /> + setLocation(e.target.value)} + fullWidth + sx={{ my: 1 }} + required + /> + + Pricing Tier + + + {price && ( + + Selected Price: ${price} per guest + + )} + + Cancellation Policy: {cancellationPolicyInfo} + + + + Payment Information + + setCardNumber(e.target.value)} + fullWidth + sx={{ my: 1 }} + required + inputProps={{ maxLength: 16 }} + /> + setCardName(e.target.value)} + fullWidth + sx={{ my: 1 }} + required + /> + setExpiry(e.target.value)} + fullWidth + sx={{ my: 1 }} + required + placeholder="MM/YY" + /> + setCvc(e.target.value)} + fullWidth + sx={{ my: 1 }} + required + inputProps={{ maxLength: 4 }} + /> + + {success && {success}} + + ); +} + +export default BookingForm; \ No newline at end of file diff --git a/frontend/src/ManageBookings.jsx b/frontend/src/ManageBookings.jsx new file mode 100644 index 0000000..a3af2ac --- /dev/null +++ b/frontend/src/ManageBookings.jsx @@ -0,0 +1,47 @@ +import React, { useEffect, useState } from 'react'; +import { Typography, List, ListItem, ListItemText, Button } from '@mui/material'; + +function ManageBookings() { + const [bookings, setBookings] = useState([]); + const [loading, setLoading] = useState(true); + + useEffect(() => { + fetch('/api/bookings/my') + .then(res => res.json()) + .then(data => { + setBookings(Array.isArray(data) ? data : []); + setLoading(false); + }); + }, []); + + const handleCancel = async id => { + await fetch(`/api/bookings/${id}/cancel`, { method: 'POST' }); + setBookings(bookings.map(b => b.id === id ? { ...b, status: 'Cancelled' } : b)); + }; + + //if (loading) return Loading bookings...; + + return ( +
+ My Bookings + + {bookings.map(b => ( + handleCancel(b.id)}> + Cancel + + ) + }> + + + ))} + +
+ ); +} + +export default ManageBookings; \ No newline at end of file diff --git a/frontend/src/index.css b/frontend/src/index.css new file mode 100644 index 0000000..ec2585e --- /dev/null +++ b/frontend/src/index.css @@ -0,0 +1,13 @@ +body { + margin: 0; + font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', + 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', + sans-serif; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; +} + +code { + font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', + monospace; +} diff --git a/frontend/src/index.js b/frontend/src/index.js new file mode 100644 index 0000000..c760e59 --- /dev/null +++ b/frontend/src/index.js @@ -0,0 +1,6 @@ +import React from 'react'; +import ReactDOM from 'react-dom/client'; +import App from './App'; + +const root = ReactDOM.createRoot(document.getElementById('root')); +root.render(); \ No newline at end of file