This commit is contained in:
omkieit 2024-10-09 10:07:39 +05:30
parent 6c3f66fd35
commit 206a9aab09
4 changed files with 192 additions and 78 deletions

View File

@ -74,6 +74,10 @@ const propertySchema = mongoose.Schema({
type: Date, type: Date,
required: true, required: true,
}, },
renovationRisk:{
type: Number,
required: true, // Set to true if this field is mandatory
},
purchaseCost: { purchaseCost: {
type: Number, type: Number,
required: true, // Set to true if this field is mandatory required: true, // Set to true if this field is mandatory

File diff suppressed because one or more lines are too long

View File

@ -45,7 +45,7 @@
<script type="module" crossorigin src="/assets/index-BMPA1Ced.js"></script> <script type="module" crossorigin src="/assets/index-BNrhHLuI.js"></script>
<link rel="stylesheet" crossorigin href="/assets/index-iEl-il0E.css"> <link rel="stylesheet" crossorigin href="/assets/index-iEl-il0E.css">
</head> </head>

View File

@ -29,6 +29,18 @@ const Addproperty = () => {
], ],
images: [{ title: "", file: "" }], // Array to hold image objects images: [{ title: "", file: "" }], // Array to hold image objects
googleMapLink: "", // Field for Google Maps link googleMapLink: "", // Field for Google Maps link
renovationRisk: [
{ title: "1", selected: false },
{ title: "2", selected: false },
{ title: "3", selected: false },
{ title: "4", selected: false },
{ title: "5", selected: false },
{ title: "6", selected: false },
{ title: "7", selected: false },
{ title: "8", selected: false },
{ title: "9", selected: false },
{ title: "10", selected: false },
],
purchaseCost: "", purchaseCost: "",
costPaidAtoB: [ costPaidAtoB: [
{ title: "Closing Fees - Settlement Fee", price: "" }, { title: "Closing Fees - Settlement Fee", price: "" },
@ -586,10 +598,11 @@ const Addproperty = () => {
formData.extwall && formData.extwall &&
formData.roofing && formData.roofing &&
formData.totalSqft && formData.totalSqft &&
formData.renovationRisk &&
formData.totalcashsurplus && formData.totalcashsurplus &&
formData.sellpricebtoc && formData.sellpricebtoc &&
formData.closeDateAtoB && formData.closeDateAtoB &&
formData.closeDateBtoC formData.closeDateBtoC
) { ) {
const totalCostsAtoB = calculateTotalCosts(); const totalCostsAtoB = calculateTotalCosts();
const totalCostsAtoBaftercredits = calculateTotalCostsWithCredits(); const totalCostsAtoBaftercredits = calculateTotalCostsWithCredits();
@ -659,6 +672,28 @@ const Addproperty = () => {
} }
}, [status, error, submitted]); }, [status, error, submitted]);
const [turnTime, setTurnTime] = useState("0 days"); // Store the calculated turn time
const calculateTurnTime = (closeDateAtoB, closeDateBtoC) => {
if (closeDateAtoB && closeDateBtoC) {
const dateA = new Date(closeDateAtoB);
const dateB = new Date(closeDateBtoC);
// Calculate difference in time
const diffTime = Math.abs(dateB - dateA);
// Calculate difference in days
const diffDays = Math.ceil(diffTime / (1000 * 60 * 60 * 24));
// Update state with the calculated turn time
// setTurnTime(diffDays);
setTurnTime(`${diffDays} days`);
} else {
setTurnTime("0 days"); // Reset if dates are not available
}
};
return ( return (
<> <>
<div className="container tabs-wrap"> <div className="container tabs-wrap">
@ -797,6 +832,7 @@ const Addproperty = () => {
<option value="South Dakota">South Dakota</option> <option value="South Dakota">South Dakota</option>
<option value="Tennessee">Tennessee</option> <option value="Tennessee">Tennessee</option>
<option value="Texas">Texas</option> <option value="Texas">Texas</option>
<option value="Texas">Travis</option>
<option value="Utah">Utah</option> <option value="Utah">Utah</option>
<option value="Virginia">Virginia</option> <option value="Virginia">Virginia</option>
<option value="Vermont">Vermont</option> <option value="Vermont">Vermont</option>
@ -1347,7 +1383,7 @@ const Addproperty = () => {
</div> </div>
<div className="col-md-2"> <div className="col-md-2">
<div className="form-floating mb-2"> <div className="form-floating mb-2">
Owed Year Owned Year
<input <input
type="text" type="text"
className="form-control" className="form-control"
@ -1555,75 +1591,149 @@ const Addproperty = () => {
borderRadius: "8px", borderRadius: "8px",
}} }}
> >
<br /> <br />
<div className="row gy-3"> <div className="row gy-3">
{/* Close Date A to B */}
<div className="col-md-4">
<input
type="text"
className="form-control"
placeholder="Close Date A to B"
required
disabled
/>
</div>
<div className="col-md-4">
<input
type="date"
className="form-control"
name="closeDateAtoB"
value={formData.closeDateAtoB}
onChange={(e) => {
const value = e.target.value;
setFormData({
...formData,
closeDateAtoB: value,
});
calculateTurnTime(value, formData.closeDateBtoC);
}}
placeholder="Close Date A to B"
style={{ textAlign: "right" }}
required
/>
</div>
</div>
<br />
<div className="row gy-3">
{/* Close Date B to C */}
<div className="col-md-4">
<input
type="text"
className="form-control"
placeholder="Close Date B to C"
required
disabled
/>
</div>
<div className="col-md-4">
<input
type="date"
className="form-control"
name="closeDateBtoC"
value={formData.closeDateBtoC}
onChange={(e) => {
const value = e.target.value;
setFormData({
...formData,
closeDateBtoC: value,
});
calculateTurnTime(formData.closeDateAtoB, value);
}}
placeholder="Close Date B to C"
style={{ textAlign: "right" }}
required
/>
</div>
</div>
<br />
<div className="row gy-3 align-items-center">
<span
className="col-md-4"
style={{
color: "#fda417",
fontSize: "14px",
fontWeight: "bold",
}}
>
Turn Time
</span>
<div className="col-md-4"> <div className="col-md-4">
<input <input
type="text" type="text"
className="form-control" className="form-control"
placeholder="Close Date A to B" value={turnTime}
required readOnly
disabled style={{
/> borderColor: "#fda417", // Custom border color for the input field
</div> color: "#fda417", // Optionally apply text color to the input text
<div className="col-md-4"> textAlign: "right",
<input
type="date"
className="form-control"
name="closeDateAtoB"
value={formData.closeDateAtoB}
onChange={(e) => {
const value = e.target.value;
setFormData({
...formData,
closeDateAtoB: value,
});
}} }}
placeholder="Close Date A to B" placeholder="Total Costs to Buy A to B"
style={{ textAlign: "right" }}
required required
/> />
</div> </div>
</div> </div>
<br /> <br />
<div className="row gy-3 align-items-center">
<span
className="col-md-4"
style={{
color: "#fda417",
fontSize: "14px",
fontWeight: "bold",
}}
>
Renovation Risk
</span>
<div className="row gy-3"> <div className="col-md-7">
<div className="col-md-4"> {formData.renovationRisk.map((option, index) => (
<input <div className="form-check form-check-inline" key={index}>
type="text" <input
className="form-control" className="form-check-input"
placeholder="Close Date B to C" type="radio"
required name="renovationRisk"
disabled id={`renovationRisk${option.title}`}
/> value={option.title}
</div> checked={option.selected}
onChange={() => {
<div className="col-md-4"> const updatedRenovationRisk = formData.renovationRisk.map((risk) =>
<input risk.title === option.title
type="date" ? { ...risk, selected: true }
className="form-control" : { ...risk, selected: false }
name="closeDateBtoC" );
value={formData.closeDateBtoC} setFormData({
onChange={(e) => { ...formData,
const value = e.target.value; renovationRisk: updatedRenovationRisk,
setFormData({ });
...formData, }}
closeDateBtoC: value, />
}); <label
}} className="form-check-label"
placeholder="Close Date B to C" htmlFor={`renovationRisk${option.title}`}
style={{ textAlign: "right" }} >
required {option.title}
/> </label>
</div> </div>
</div> ))}
</div>
</div>
<hr <hr
style={{ style={{