-
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.
added blockchain and many things...codebase is distorted :|
- Loading branch information
1 parent
428f7f0
commit 71cf83b
Showing
28 changed files
with
23,488 additions
and
125 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
|
||
export default function Download() { | ||
return ( | ||
<div> | ||
|
||
</div> | ||
) | ||
} |
105 changes: 105 additions & 0 deletions
105
client/src/components/Buyer/Contract/GenerateContract.jsx
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 |
---|---|---|
@@ -0,0 +1,105 @@ | ||
import { useState } from "react"; | ||
import { MdDone } from "react-icons/md"; | ||
import PdfDetails from "./PdfDetails"; | ||
import Metamask from "./Metamask"; | ||
import Download from "./Download"; | ||
export default function GenerateContract() { | ||
|
||
const steps = ["Fill Details", "Connect to Metamask", "Download Pdf"]; | ||
const [currentStep, setCurrentStep] = useState(1); | ||
// const [complete, setComplete] = useState(false); | ||
|
||
const handleNext = () => { | ||
if (currentStep === steps.length) { | ||
// setComplete(true); | ||
} else { | ||
setCurrentStep((prev) => prev + 1); | ||
} | ||
}; | ||
|
||
const handleBack = () => { | ||
if (currentStep > 1) { | ||
setCurrentStep((prev) => prev - 1); | ||
} | ||
}; | ||
return ( | ||
<> | ||
<div className="w-3/4 p-4 h-full shadow rounded-4 flex flex-col self-start items-start justify-start gap-2"> | ||
<div className="flex w-full justify-between"> | ||
{steps?.map((step, i) => ( | ||
<div | ||
key={i} | ||
className={`relative flex flex-col w-full justify-center items-center ${ | ||
currentStep === i + 1 ? "active" : "" | ||
}`} | ||
> | ||
<div | ||
className={`w-10 h-10 flex items-center justify-center z-10 relative rounded-full font-semibold text-white ${ | ||
currentStep === i + 1 | ||
? "bg-sky-600" | ||
: i < currentStep | ||
? "bg-green-600" | ||
: "bg-slate-700" | ||
}`} | ||
> | ||
{i + 1 < currentStep ? ( | ||
<MdDone size={24} /> | ||
) : ( | ||
i + 1 | ||
)} | ||
</div> | ||
<p | ||
className={`mt-2 ${ | ||
i + 1 < currentStep ? "text-white" : "text-gray-500" | ||
}`} | ||
> | ||
{step} | ||
</p> | ||
{i !== 0 && ( | ||
<div | ||
className={`absolute w-full h-[3px] top-1/2 transform -translate-y-1/2 ${ | ||
i < currentStep ? "bg-green-600" : "bg-slate-200" | ||
}`} | ||
style={{ right: "50%" }} | ||
/> | ||
)} | ||
</div> | ||
))} | ||
</div> | ||
{steps[currentStep-1] === 'Fill Details' && ( | ||
<> | ||
<PdfDetails /> | ||
</> | ||
)} | ||
{currentStep === 'Connect to Metamask' && ( | ||
<> | ||
<Metamask/> | ||
</> | ||
)} | ||
{currentStep === 'Download Pdf' && ( | ||
<> | ||
<Download/> | ||
</> | ||
)} | ||
|
||
|
||
<div className="mt-4 flex justify-around w-full space-x-2"> | ||
<button | ||
className="px-4 py-2 bg-blue-500 text-white rounded hover:bg-blue-600" | ||
onClick={handleBack} | ||
disabled={currentStep === 1} | ||
> | ||
Back | ||
</button> | ||
<button | ||
className="px-4 py-2 bg-green-500 text-white rounded hover:bg-green-600" | ||
onClick={handleNext} | ||
> | ||
{currentStep === steps.length ? "Generate Another" : "Next"} | ||
</button> | ||
</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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export default function Metamask() { | ||
return ( | ||
<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 |
---|---|---|
@@ -0,0 +1,81 @@ | ||
import { useState } from 'react'; | ||
import jsPDF from 'jspdf'; | ||
// import 'jspdf-autotable'; // Optional: if you want to use table features | ||
|
||
const Pdf = () => { | ||
const [contractDetails, setContractDetails] = useState({ | ||
buyerName: '', | ||
sellerName: '', | ||
contractDate: '', | ||
details: '' | ||
}); | ||
|
||
const handleChange = (e) => { | ||
const { name, value } = e.target; | ||
setContractDetails({ ...contractDetails, [name]: value }); | ||
}; | ||
|
||
const generatePDF = () => { | ||
const doc = new jsPDF(); | ||
|
||
doc.setFontSize(16); | ||
doc.text('Contract Details', 20, 20); | ||
|
||
doc.setFontSize(12); | ||
doc.text(`Buyer Name: ${contractDetails.buyerName}`, 20, 30); | ||
doc.text(`Seller Name: ${contractDetails.sellerName}`, 20, 40); | ||
doc.text(`Contract Date: ${contractDetails.contractDate}`, 20, 50); | ||
doc.text('Details:', 20, 60); | ||
doc.text(contractDetails.details, 20, 70); | ||
|
||
doc.save('contract.pdf'); | ||
}; | ||
|
||
return ( | ||
<div> | ||
<h2>Contract Form</h2> | ||
<form> | ||
<div> | ||
<label>Buyer Name:</label> | ||
<input | ||
type="text" | ||
name="buyerName" | ||
value={contractDetails.buyerName} | ||
onChange={handleChange} | ||
/> | ||
</div> | ||
<div> | ||
<label>Seller Name:</label> | ||
<input | ||
type="text" | ||
name="sellerName" | ||
value={contractDetails.sellerName} | ||
onChange={handleChange} | ||
/> | ||
</div> | ||
<div> | ||
<label>Contract Date:</label> | ||
<input | ||
type="date" | ||
name="contractDate" | ||
value={contractDetails.contractDate} | ||
onChange={handleChange} | ||
/> | ||
</div> | ||
<div> | ||
<label>Details:</label> | ||
<textarea | ||
name="details" | ||
value={contractDetails.details} | ||
onChange={handleChange} | ||
/> | ||
</div> | ||
<button type="button" onClick={generatePDF}> | ||
Generate PDF | ||
</button> | ||
</form> | ||
</div> | ||
); | ||
}; | ||
|
||
export default Pdf; |
Oops, something went wrong.