-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #40 from ShinichiShi/Shinichi
Shinichi
- Loading branch information
Showing
26 changed files
with
768 additions
and
367 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,51 @@ | ||
import { useContext, useEffect, useState } from 'react'; | ||
import { AuthContext } from '../../context/Authcontext'; | ||
import { db } from '../../../../firebase'; | ||
import { getDoc, doc } from 'firebase/firestore'; | ||
import ContractStatus from './ContractStatus'; | ||
export default function BContract() { | ||
const { currentUser } = useContext(AuthContext); | ||
const [contracts, setContracts] = useState([]); // Initialize state to store contracts | ||
|
||
useEffect(() => { | ||
const fetchDetails = async () => { | ||
if (currentUser) { | ||
const buyerRef = doc(db, 'buyers', currentUser.uid); | ||
const docSnap = await getDoc(buyerRef); | ||
|
||
if (docSnap.exists()) { | ||
const data = docSnap.data(); | ||
const contractsData = data.contracts | ||
? Object.values(data.contracts) | ||
: []; // Convert map to array | ||
setContracts(contractsData); // Update state with contracts | ||
} | ||
} | ||
}; | ||
|
||
fetchDetails(); // Fetch details on component mount | ||
}, [currentUser]); | ||
|
||
return ( | ||
<div className="w-full flex justify-center bg-slate-50"> | ||
<div className="w-3/4 p-4 container h-full shadow flex flex-col items-center justify-center gap-2"> | ||
<div className="font-bold text-xl self-start">Contract History :</div> | ||
<div className="w-full h-8 bg-slate-400 flex flex-row items-center justify-around"> | ||
<div>Order ID</div> | ||
<div>Date</div> | ||
<div>Total</div> | ||
<div>Status</div> | ||
<div></div> | ||
</div> | ||
<ContractStatus /> | ||
<ContractStatus /> | ||
<ContractStatus /> | ||
<ContractStatus /> | ||
</div> | ||
<div className="w-full h-[100vh] flex self-start justify-center"> | ||
<div className="w-3/4 p-4 h-full shadow flex flex-col self-start items-start justify-start gap-2"> | ||
<div className="font-bold text-xl self-start mb-2">Contract History :</div> | ||
<div className="w-full h-8 bg-slate-400 flex flex-row items-center justify-between px-4"> | ||
<div className="flex-1 text-center">Date</div> | ||
<div className="flex-1 text-center">Total</div> | ||
<div className="flex-1 text-center">Status</div> | ||
<div className="flex-1 text-center">Details</div> | ||
</div> | ||
); | ||
<div className="w-full flex flex-col items-start justify-start mt-2"> | ||
{contracts.length > 0 ? ( | ||
contracts.map((contract, index) => ( | ||
<ContractStatus key={index} contract={contract} /> | ||
)) | ||
) : ( | ||
<p className='flex-1 w-full flex text-center'>No contracts found</p> | ||
)} | ||
</div> | ||
</div> | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,13 @@ | ||
export default function ContractStatus() { | ||
export default function ContractStatus({ contract, key }) { | ||
return ( | ||
<div className="w-full h-10 bg-green-200 flex flex-row items-center justify-around" > | ||
<div>Order ID</div> | ||
<div>Date</div> | ||
<div>Total</div> | ||
<div>Status</div> | ||
<div className="text-green-800">View Details</div> | ||
</div> | ||
) | ||
<div className="w-full h-12 bg-green-200 flex flex-row items-center justify-between px-4 mb-2"> | ||
{/* Assuming `contract.id` is available */} | ||
<div className="flex-1 text-center">{contract.date || 'N/A'}</div> | ||
<div className="flex-1 text-center">{contract.total || 'N/A'}</div> | ||
<div className="flex-1 text-center">{contract.status || 'N/A'}</div> | ||
<div className="flex-1 text-center text-green-800 cursor-pointer"> | ||
View Details | ||
</div> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.