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,
required: true,
},
renovationRisk:{
type: Number,
required: true, // Set to true if this field is mandatory
},
purchaseCost: {
type: Number,
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">
</head>

View File

@ -29,6 +29,18 @@ const Addproperty = () => {
],
images: [{ title: "", file: "" }], // Array to hold image objects
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: "",
costPaidAtoB: [
{ title: "Closing Fees - Settlement Fee", price: "" },
@ -586,6 +598,7 @@ const Addproperty = () => {
formData.extwall &&
formData.roofing &&
formData.totalSqft &&
formData.renovationRisk &&
formData.totalcashsurplus &&
formData.sellpricebtoc &&
formData.closeDateAtoB &&
@ -659,6 +672,28 @@ const Addproperty = () => {
}
}, [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 (
<>
<div className="container tabs-wrap">
@ -797,6 +832,7 @@ const Addproperty = () => {
<option value="South Dakota">South Dakota</option>
<option value="Tennessee">Tennessee</option>
<option value="Texas">Texas</option>
<option value="Texas">Travis</option>
<option value="Utah">Utah</option>
<option value="Virginia">Virginia</option>
<option value="Vermont">Vermont</option>
@ -1347,7 +1383,7 @@ const Addproperty = () => {
</div>
<div className="col-md-2">
<div className="form-floating mb-2">
Owed Year
Owned Year
<input
type="text"
className="form-control"
@ -1555,12 +1591,10 @@ const Addproperty = () => {
borderRadius: "8px",
}}
>
<br />
<div className="row gy-3">
{/* Close Date A to B */}
<div className="col-md-4">
<input
type="text"
@ -1582,6 +1616,7 @@ const Addproperty = () => {
...formData,
closeDateAtoB: value,
});
calculateTurnTime(value, formData.closeDateBtoC);
}}
placeholder="Close Date A to B"
style={{ textAlign: "right" }}
@ -1593,6 +1628,7 @@ const Addproperty = () => {
<br />
<div className="row gy-3">
{/* Close Date B to C */}
<div className="col-md-4">
<input
type="text"
@ -1615,6 +1651,7 @@ const Addproperty = () => {
...formData,
closeDateBtoC: value,
});
calculateTurnTime(formData.closeDateAtoB, value);
}}
placeholder="Close Date B to C"
style={{ textAlign: "right" }}
@ -1623,7 +1660,80 @@ const Addproperty = () => {
</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">
<input
type="text"
className="form-control"
value={turnTime}
readOnly
style={{
borderColor: "#fda417", // Custom border color for the input field
color: "#fda417", // Optionally apply text color to the input text
textAlign: "right",
}}
placeholder="Total Costs to Buy A to B"
required
/>
</div>
</div>
<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="col-md-7">
{formData.renovationRisk.map((option, index) => (
<div className="form-check form-check-inline" key={index}>
<input
className="form-check-input"
type="radio"
name="renovationRisk"
id={`renovationRisk${option.title}`}
value={option.title}
checked={option.selected}
onChange={() => {
const updatedRenovationRisk = formData.renovationRisk.map((risk) =>
risk.title === option.title
? { ...risk, selected: true }
: { ...risk, selected: false }
);
setFormData({
...formData,
renovationRisk: updatedRenovationRisk,
});
}}
/>
<label
className="form-check-label"
htmlFor={`renovationRisk${option.title}`}
>
{option.title}
</label>
</div>
))}
</div>
</div>
<hr
style={{