From 5b77ff503a7316b3962f9c541e6fc446f3939aaa Mon Sep 17 00:00:00 2001 From: ShinichiShi Date: Sat, 14 Sep 2024 01:28:10 +0530 Subject: [PATCH] sm more files --- .../Buyer/Contract/ContractList.jsx | 70 +++++ client/src/components/Farmer/FarmSell.jsx | 69 ----- .../components/LandingPage/AgriConnect.jsx | 276 ------------------ client/src/components/Negotiate/chat.css | 26 -- 4 files changed, 70 insertions(+), 371 deletions(-) create mode 100644 client/src/components/Buyer/Contract/ContractList.jsx delete mode 100644 client/src/components/LandingPage/AgriConnect.jsx delete mode 100644 client/src/components/Negotiate/chat.css diff --git a/client/src/components/Buyer/Contract/ContractList.jsx b/client/src/components/Buyer/Contract/ContractList.jsx new file mode 100644 index 0000000..43be031 --- /dev/null +++ b/client/src/components/Buyer/Contract/ContractList.jsx @@ -0,0 +1,70 @@ +import { useContext, useEffect, useState } from 'react'; +import { AuthContext } from '../../context/Authcontext'; +import { db } from '../../../../firebase'; +import { doc, getDoc } from 'firebase/firestore'; +import ContractStatus from './ContractStatus'; + +const ContractList = () => { + const [contracts, setContracts] = useState([]); + const [loading, setLoading] = useState(true); + const [error, setError] = useState(null); + const { currentUser } = useContext(AuthContext); + + useEffect(() => { + const fetchContracts = async () => { + if (!currentUser) { + setError('User not authenticated'); + setLoading(false); + return; + } + + try { + const buyerRef = doc(db, 'buyers', currentUser.uid); + const docSnap = await getDoc(buyerRef); + + if (docSnap.exists()) { + const contractsData = docSnap.data().contracts || []; + setContracts(contractsData); + } else { + setError('No buyer profile found'); + } + } catch (err) { + console.error('Error fetching contracts:', err); + setError('Failed to fetch contracts'); + } finally { + setLoading(false); + } + }; + + fetchContracts(); + }, [currentUser]); + + if (loading) { + return
Loading contracts...
; + } + + if (error) { + return
{error}
; + } + + return ( +
+
+ Your Contracts +
+ {contracts.length === 0 ? ( +

No contracts found.

+ ) : ( +
+ {contracts + .sort((a, b) => b.contractId - a.contractId) // Sort contracts by contractId in decreasing order + .map((contract) => ( + + ))} +
+ )} +
+ ); +}; + +export default ContractList; diff --git a/client/src/components/Farmer/FarmSell.jsx b/client/src/components/Farmer/FarmSell.jsx index 6510f7b..d71e728 100644 --- a/client/src/components/Farmer/FarmSell.jsx +++ b/client/src/components/Farmer/FarmSell.jsx @@ -15,7 +15,6 @@ function Box({ crop }) { @@ -27,11 +26,6 @@ function Details({ crops, setSelectedCrop, handleInputChange }) {
{crops.map((crop, index) => ( -
setSelectedCrop(crop)} - >
setSelectedCrop(crop)} /> {' ' + crop.name} - setSelectedCrop(crop)} - /> - {' ' + crop.name}
@@ -114,14 +101,6 @@ function Details({ crops, setSelectedCrop, handleInputChange }) { onChange={handleInputChange} required /> -
@@ -134,14 +113,6 @@ function Details({ crops, setSelectedCrop, handleInputChange }) { onChange={handleInputChange} required /> -
@@ -154,14 +125,6 @@ function Details({ crops, setSelectedCrop, handleInputChange }) { onChange={handleInputChange} required /> -
@@ -174,14 +137,6 @@ function Details({ crops, setSelectedCrop, handleInputChange }) { onChange={handleInputChange} required /> -
@@ -218,27 +173,6 @@ function Search({ searchQuery, setSearchQuery, handleSearch }) { onChange={(e) => setSearchQuery(e.target.value)} /> - -
-
-
-
-
-
-
-
Secure Income, Grow with Confidence
-

- Connect directly with reliable buyers, negotiate - contracts, and ensure timely payments. -

-

- - Signup|Login as farmer - -

-
-
-
-
- -
-
-
-
-
-
-
-
-
-
-
Source Quality Produce, Hassle-Free
-

- Find trusted farmers, negotiate prices, and secure your - supply chain with ease. -

-

- - Signup|Login as buyer - -

-
-
-
-
- -
-
-
-
-
-
- - -
- -
-

Why Choose AgriConnect?

-
-
- Guaranteed Market Access -

Guaranteed Market Access

-

- Connect with verified buyers and secure a steady market for your - produce. -

-
-
- Transparent Negotiation -

Transparent Negotiation

-

Discuss terms in real-time and reach agreements with ease.

-
-
- Secure Contracts -

Secure Contracts

-

Legal assurance with securely stored contracts.

-
-
- Timely Payments -

Timely Payments

-

- Get paid on time, every time with our integrated payment system. -

-
-
- End-to-End Support -

End-to-End Support

-

- From initial contact to final delivery, we ensure smooth - transactions. -

-
-
-
- -
-

How AgriConnect Works: A Simple 3-Step Process

-
    -
  1. - Sign Up & Create Your Profile: Farmers and buyers - can easily sign up and create a profile tailored to their needs. -
  2. -
  3. - Connect & Negotiate: Use our platform to discover - potential partners and establish secure contracts. -
  4. -
  5. - Deliver & Get Paid: Farmers deliver the produce as - per the contract and receive timely payments. -
  6. -
-
- -
-

Join a Growing Community of Successful Farmers and Buyers

-
- - - - ); -}; - -export default AgriConnect; - diff --git a/client/src/components/Negotiate/chat.css b/client/src/components/Negotiate/chat.css deleted file mode 100644 index 9d6942d..0000000 --- a/client/src/components/Negotiate/chat.css +++ /dev/null @@ -1,26 +0,0 @@ -header { - border: 2px solid black; - height: 10vh; - background-color: aqua; -} -.chats-display { - width: 99.5%; - height: 79vh; - position: absolute; - text-align: center; - border: 2px solid red; - overflow: scroll; -} -footer { - position: relative; - top: 82vh; - display: flex; - justify-content: space-around; -} -footer > textarea { - width: 80vw; - text-align: center; - font-size: 19px; - color: black; -} -