done
This commit is contained in:
parent
6c3f66fd35
commit
206a9aab09
|
@ -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
|
@ -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>
|
||||
|
||||
|
|
|
@ -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,10 +598,11 @@ const Addproperty = () => {
|
|||
formData.extwall &&
|
||||
formData.roofing &&
|
||||
formData.totalSqft &&
|
||||
formData.renovationRisk &&
|
||||
formData.totalcashsurplus &&
|
||||
formData.sellpricebtoc &&
|
||||
formData.closeDateAtoB &&
|
||||
formData.closeDateBtoC
|
||||
formData.closeDateAtoB &&
|
||||
formData.closeDateBtoC
|
||||
) {
|
||||
const totalCostsAtoB = calculateTotalCosts();
|
||||
const totalCostsAtoBaftercredits = calculateTotalCostsWithCredits();
|
||||
|
@ -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,75 +1591,149 @@ const Addproperty = () => {
|
|||
borderRadius: "8px",
|
||||
}}
|
||||
>
|
||||
|
||||
|
||||
<br />
|
||||
|
||||
|
||||
<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">
|
||||
<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,
|
||||
});
|
||||
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="Close Date A to B"
|
||||
style={{ 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="row gy-3">
|
||||
<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,
|
||||
});
|
||||
}}
|
||||
placeholder="Close Date B to C"
|
||||
style={{ textAlign: "right" }}
|
||||
required
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<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={{
|
||||
|
|
Loading…
Reference in New Issue