This commit is contained in:
omkieit 2024-10-07 12:01:08 +05:30
parent 14fd066fe0
commit ff5192bb80
6 changed files with 814 additions and 3063 deletions

View File

@ -102,6 +102,22 @@ const propertySchema = mongoose.Schema({
type: Number,
required: true, // Set to true if this field is mandatory
},
incidentalCost:[
{
title: {
type: String,
required: true, // Set to true if this field is mandatory
},
price: {
type: Number,
required: true, // Set to true if this field is mandatory
},
},
],
totalincidentalCost: {
type: Number,
required: true, // Set to true if this field is mandatory
},
});
const PropertyModal = mongoose.model("property", propertySchema);

File diff suppressed because one or more lines are too long

View File

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

File diff suppressed because it is too large Load Diff

View File

@ -24,7 +24,6 @@ const Addproperty = () => {
const { user } = useSelector((state) => ({ ...state.auth }));
const [formData, setFormData] = useState({
poolspa: "",
propertyTaxInfo: [
{ propertytaxowned: "", ownedyear: "", taxassessed: "", taxyear: "" },
],
@ -41,6 +40,13 @@ const Addproperty = () => {
{ title: "Property Tax", price: "" },
],
credits: [{ title: "Credits received on settlement", price: "" }],
incidentalCost: [
{ title: "Accounting Fees", price: "" },
{ title: "Bank Charges", price: "" },
{ title: "Legal Fees", price: "" },
{ title: "Property Taxes", price: "" },
{ title: "Travel Expenses", price: "" },
],
});
const [submitted, setSubmitted] = useState(false);
@ -226,8 +232,68 @@ const Addproperty = () => {
return totalCostsFromArray + totalCreditsFromArray + purchaseCost;
};
const addincidentalCost = () => {
setFormData((prevData) => ({
...prevData,
incidentalCost: [...prevData.incidentalCost, { title: "", price: "" }],
}));
};
const deleteincidentalCost = (index) => {
const updatedincidentalCost = formData.incidentalCost.filter((_, i) => i !== index);
setFormData((prevData) => ({
...prevData,
incidentalCost: updatedincidentalCost,
}));
};
// Function to handle changes to incidentalCost title and price
const handleincidentalCostTitle = (index, field, value) => {
const updatedincidentalCost = [...formData.incidentalCost];
updatedincidentalCost[index][field] = value;
setFormData((prevData) => ({
...prevData,
incidentalCost: updatedincidentalCost,
}));
};
const handleincidentalCostChange = (e, index) => {
const value = e.target.value;
// Regular expression to allow only numbers and optional decimals
const isNumber = /^\d*\.?\d*$/.test(value);
// If valid number, update state, otherwise show the alert
if (isNumber || value === "") {
const updatedincidentalCost = formData.incidentalCost.map((incidentalCost, i) =>
i === index
? { ...incidentalCost, price: value, isInvalid: false } // Reset isInvalid if valid number
: incidentalCost
);
setFormData({ ...formData, incidentalCost: updatedincidentalCost });
} else {
const updatedincidentalCost = formData.incidentalCost.map((incidentalCost, i) =>
i === index
? { ...incidentalCost, isInvalid: true } // Set isInvalid true for invalid input
: incidentalCost
);
setFormData({ ...formData, incidentalCost: updatedincidentalCost });
}
};
// Calculate total from incidentalCost array
const calculateTotalincidentalCost = () => {
return formData.incidentalCost.reduce((total, incidentalCost) => {
const price = parseFloat(incidentalCost.price);
return total + (isNaN(price) ? 0 : price); // Ensure only valid numbers are added
}, 0);
};
const handleSubmit = () => {
if (formData.address &&
if (
formData.address &&
formData.city &&
formData.state &&
formData.county &&
@ -257,6 +323,8 @@ const Addproperty = () => {
) {
const totalCostsAtoB = calculateTotalCosts();
const totalCostsAtoBaftercredits = calculateTotalCostsWithCredits();
const totalincidentalCost = calculateTotalincidentalCost();
// Add user info to formData, including the propertyTaxInfo array
const formDataWithUserInfo = {
...formData,
@ -268,6 +336,7 @@ const Addproperty = () => {
userId: user?.result?.userId,
totalCostsAtoB: totalCostsAtoB,
totalCostsAtoBaftercredits: totalCostsAtoBaftercredits,
totalincidentalCost:totalincidentalCost,
};
// Check if propertyTaxInfo is an array and has values
@ -1441,13 +1510,119 @@ const Addproperty = () => {
color: "#fda417", // Optionally apply text color to the input text
textAlign: "right",
}}
placeholder="Total Costs to Buy A to B After credits"
// placeholder="Total Costs to Buy A to B After credits"
required
/>
</div>
</div>
<hr />
<span
style={{
color: "#fda417",
fontSize: "14px",
fontWeight: "bold",
}}
>
Incidental Cost:
</span>
{formData.incidentalCost.map((cost, index) => (
<div key={index} className="row gy-3 align-items-center">
<div className="col-md-4">
<input
type="text"
className="form-control"
value={cost.title}
onChange={(e) =>
handleincidentalCostTitle(index, "title", e.target.value)
}
placeholder="Title"
required
/>
</div>
<div className="col-md-4">
<input
type="text"
className={`form-control ${
cost.isInvalid ? "is-invalid" : ""
}`} // Apply 'is-invalid' class when invalid
value={cost.price}
onChange={(e) => handleincidentalCostChange(e, index)} // Use a new handler for price validation
placeholder="Price"
style={{ textAlign: "right" }}
required
/>
{cost.isInvalid && (
<div className="invalid-feedback">
Please enter a valid number.
</div>
)}
</div>
<div className="col-md-2 d-flex justify-content-start">
<button
className="btn btn-danger"
onClick={() => deleteincidentalCost (index)}
style={{ marginLeft: "5px" }}
>
x
</button>
</div>
</div>
))}
<div className="col-md-4">
<button
className="btn btn-primary back"
onClick={addincidentalCost}
style={{ backgroundColor: "#fda417", border: "#fda417" }}
>
<span
style={{
fontSize: "20px",
fontWeight: "normal",
}}
>
+
</span>{" "}
Add Incidental Cost
</button>
</div>
<div className="row gy-3 align-items-center">
<span
className="col-md-4"
style={{
color: "#fda417",
fontSize: "14px",
fontWeight: "bold",
}}
>
Total Incidental Cost
</span>
<div className="col-md-4">
<input
type="text"
className="form-control"
name="totalincidentalCost"
value={calculateTotalincidentalCost()}
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 Incidental Cost"
required
/>
</div>
</div>
<div className="col-md-4">
<button
className="btn btn-primary back"

View File

@ -227,7 +227,35 @@ const Addproperty = () => {
};
const handleSubmit = () => {
if (formData.poolspa) {
if (
formData.address &&
formData.city &&
formData.state &&
formData.county &&
formData.zip &&
formData.parcel &&
formData.subdivision &&
formData.legal &&
formData.costpersqft &&
formData.propertyType &&
formData.lotacres &&
formData.yearBuild &&
formData.totallivingsqft &&
formData.beds &&
formData.baths &&
formData.stories &&
formData.garage &&
formData.garagesqft &&
formData.poolspa &&
formData.fireplaces &&
formData.ac &&
formData.heating &&
formData.buildingstyle &&
formData.sitevacant &&
formData.extwall &&
formData.roofing &&
formData.totalSqft
) {
const totalCostsAtoB = calculateTotalCosts();
const totalCostsAtoBaftercredits = calculateTotalCostsWithCredits();
// Add user info to formData, including the propertyTaxInfo array
@ -330,10 +358,379 @@ const Addproperty = () => {
Property Location
</h3>
<hr />
<div className="row gy-3">
<div className="col-md-4">
<div className="form-floating mb-3">
Property Address
<input
type="text"
className="form-control"
name="address"
value={formData.address}
onChange={handleInputChange}
required
/>
</div>
</div>
<div className="col-md-4">
<div className="form-floating mb-3">
City
<input
type="text"
className="form-control"
name="city"
value={formData.city}
onChange={handleInputChange}
required
/>
</div>
</div>
<div className="col-md-4">
<div className="form-floating mb-3">
State
<select
className="form-floating mb-3 form-control"
name="state"
value={formData.state}
onChange={handleInputChange}
required
>
<option value="">Please Select</option>
<option value="Alaska">Alaska</option>
<option value="Alabama">Alabama</option>
<option value="Arkansas">Arkansas</option>
<option value="Arizona">Arizona</option>
<option value="California">California</option>
<option value="Colorado">Colorado</option>
<option value="Connecticut">Connecticut</option>
<option value="District Of Columbia">
District Of Columbia
</option>
<option value="Delaware">Delaware</option>
<option value="Florida">Florida</option>
<option value="Georgia">Georgia</option>
<option value="Hawaii">Hawaii</option>
<option value="Iowa">Iowa</option>
<option value="Idaho">Idaho</option>
<option value="Illinois">Illinois</option>
<option value="Indiana">Indiana</option>
<option value="Kansas">Kansas</option>
<option value="Kentucky">Kentucky</option>
<option value="Louisiana">Louisiana</option>
<option value="Massachusetts">Massachusetts</option>
<option value="Maryland">Maryland</option>
<option value="Michigan">Michigan</option>
<option value="Minnesota">Minnesota</option>
<option value="Missouri">Missouri</option>
<option value="Mississippi">Mississippi</option>
<option value="Montana">Montana</option>
<option value="North Carolina">North Carolina</option>
<option value="North Dakota">North Dakota</option>
<option value="Nebraska">Nebraska</option>
<option value="New Hampshire">New Hampshire</option>
<option value="New Jersey">New Jersey</option>
<option value="New Mexico">New Mexico</option>
<option value="Nevada">Nevada</option>
<option value="New York">New York</option>
<option value="Ohio">Ohio</option>
<option value="Oklahoma">Oklahoma</option>
<option value="Oregon">Oregon</option>
<option value="Pennsylvania">Pennsylvania</option>
<option value="Rhode Island">Rhode Island</option>
<option value="South Carolina">South Carolina</option>
<option value="South Dakota">South Dakota</option>
<option value="Tennessee">Tennessee</option>
<option value="Texas">Texas</option>
<option value="Utah">Utah</option>
<option value="Virginia">Virginia</option>
<option value="Vermont">Vermont</option>
<option value="Washington">Washington</option>
<option value="Wisconsin">Wisconsin</option>
<option value="West Virginia">West Virginia</option>
<option value="Wyoming">Wyoming</option>
</select>
</div>
</div>
</div>
<div className="row gy-3">
<div className="col-md-4">
Please Select Pool/SPA
County
<select
className="form-floating mb-3 form-control"
name="county"
value={formData.county}
onChange={handleInputChange}
required
>
<option value="">Please Select</option>
<option value="Abbeville">Abbeville</option>
<option value="Aiken">Aiken</option>
<option value="Allendale">Allendale</option>
<option value="Anderson">Anderson</option>
<option value="Bamberg">Bamberg</option>
<option value="Barnwell">Barnwell</option>
<option value="Beaufort">Beaufort</option>
<option value="Berkeley">Berkeley</option>
<option value="Calhoun">Calhoun</option>
<option value="Charleston">Charleston</option>
<option value="Cherokee">Cherokee</option>
<option value="Chester">Chester</option>
<option value="Chesterfield">Chesterfield</option>
<option value="Clarendon">Clarendon</option>
<option value="Colleton">Colleton</option>
<option value="Darlington">Darlington</option>
<option value="Dillon">Dillon</option>
<option value="Dorchester">Dorchester</option>
<option value="Edgefield">Edgefield</option>
<option value="Fairfield">Fairfield</option>
<option value="Florence">Florence</option>
<option value="Georgetown">Georgetown</option>
<option value="Greenville">Greenville</option>
<option value="Greenwood">Greenwood</option>
<option value="Hampton">Hampton</option>
<option value="Horry">Horry</option>
<option value="Jasper">Jasper</option>
<option value="Kershaw">Kershaw</option>
<option value="Lancaster">Lancaster</option>
<option value="Laurens">Laurens</option>
<option value="Lee">Lee</option>
<option value="Lexington">Lexington</option>
<option value="Marion">Marion</option>
<option value="Marlboro">Marlboro</option>
<option value="McCormick">McCormick</option>
<option value="Newberry">Newberry</option>
<option value="Oconee">Oconee</option>
<option value="Orangeburg">Orangeburg</option>
<option value="Pickens">Pickens</option>
<option value="Richland">Richland</option>
<option value="Saluda">Saluda</option>
<option value="Spartanburg">Spartanburg</option>
<option value="Sumter">Sumter</option>
<option value="Union">Union</option>
<option value="Williamsburg">Williamsburg</option>
<option value="York">York</option>
</select>
</div>
<div className="col-md-4">
<div className="form-floating mb-3">
Zip
<input
type="text"
className="form-control"
name="zip"
value={formData.zip}
onChange={handleInputChange}
required
/>
</div>
</div>
<div className="col-md-4">
<div className="form-floating mb-3">
Parcel
<input
type="text"
className="form-control"
name="parcel"
value={formData.parcel}
onChange={handleInputChange}
required
/>
</div>
</div>
</div>
<div className="row gy-3">
<div className="col-md-4">
<div className="form-floating mb-3">
Sub division
<input
type="text"
className="form-control"
name="subdivision"
value={formData.subdivision}
onChange={handleInputChange}
required
/>
</div>
</div>
<div className="col-md-4">
<div className="form-floating mb-3">
Legal Description
<textarea
type="text"
className="form-control"
name="legal"
value={formData.legal}
onChange={handleInputChange}
required
/>
</div>
</div>
<div className="col-md-4">
<div className="form-floating mb-3">
Cost per SQFT
<input
type="text"
className="form-control"
name="costpersqft"
value={formData.costpersqft}
onChange={handleInputChange}
required
/>
</div>
</div>
</div>
<div className="row gy-3">
<div className="col-md-4">
Property Type
<select
className="form-floating mb-3 form-control"
name="propertyType"
value={formData.propertyType}
onChange={handleInputChange}
required
>
<option value="">Please Select</option>
<option value="Residential">Residential</option>
<option value="Land">Land</option>
<option value="Commercial">Commercial</option>
<option value="Industrial">Industrial</option>
<option value="Water">Water</option>
</select>
</div>
<div className="col-md-4">
<div className="form-floating mb-3">
Lot Acres/Sqft
<input
type="text"
className="form-control"
name="lotacres"
value={formData.lotacres}
onChange={handleInputChange}
required
/>
</div>
</div>
<div className="col-md-4">
<div className="form-floating mb-3">
Year Build
<input
type="text"
className="form-control"
name="yearBuild"
value={formData.yearBuild}
onChange={handleInputChange}
required
/>
</div>
</div>
</div>
<div className="row gy-3">
<div className="col-md-4">
<div className="form-floating mb-3">
Total Living SQFT
<input
type="text"
className="form-control"
name="totallivingsqft"
value={formData.totallivingsqft}
onChange={handleInputChange}
required
/>
</div>
</div>
<div className="col-md-4">
<div className="form-floating mb-3">
Beds
<input
type="text"
className="form-control"
name="beds"
value={formData.beds}
onChange={handleInputChange}
required
/>
</div>
</div>
<div className="col-md-4">
<div className="form-floating mb-3">
Baths
<input
type="text"
className="form-control"
name="baths"
value={formData.baths}
onChange={handleInputChange}
required
/>
</div>
</div>
</div>
<div className="row gy-3">
<div className="col-md-4">
Stories
<select
className="form-floating mb-3 form-control"
name="stories"
value={formData.stories}
onChange={handleInputChange}
required
>
<option value="">Please Select</option>
<option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
</select>
</div>
<div className="col-md-4">
Garage
<select
className="form-floating mb-3 form-control"
name="garage"
value={formData.garage}
onChange={handleInputChange}
required
>
<option value="">Please Select</option>
<option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
</select>
</div>
<div className="col-md-4">
<div className="form-floating mb-3">
Garage SQFT
<input
type="text"
className="form-control"
name="garagesqft"
value={formData.garagesqft}
onChange={handleInputChange}
required
/>
</div>
</div>
</div>
<div className="row gy-3">
<div className="col-md-4">
Pool/SPA
<select
className="form-floating mb-3 form-control"
name="poolspa"
@ -351,9 +748,210 @@ const Addproperty = () => {
<option value="4">None</option>
</select>
</div>
<div className="col-md-4">
Fire places
<select
className="form-floating mb-3 form-control"
name="fireplaces"
value={formData.fireplaces}
onChange={handleInputChange}
required
>
<option value="">Please Select</option>
<option value="N/A">N/A</option>
<option value="yes">Yes</option>
<option value="no">No</option>
</select>
</div>
<div className="col-md-4">
A/C
<select
className="form-floating mb-3 form-control"
name="ac"
value={formData.ac}
onChange={handleInputChange}
required
>
<option value="">Please Select</option>
<option value="N/A">N/A</option>
<option value="Central">Central</option>
<option value="Heat Pump">Heat Pump</option>
<option value="Warm Air">Warm Air</option>
<option value="Forced Air">Forced Air</option>
<option value="Gas">Gas</option>
</select>
</div>
</div>
<div className="row gy-3">
<div className="col-md-4">
Heating
<select
className="form-floating mb-3 form-control"
name="heating"
value={formData.heating}
onChange={handleInputChange}
required
>
<option value="">Please Select</option>
<option value="N/A">N/A</option>
<option value="Central">Central</option>
<option value="Heat Pump">Heat Pump</option>
<option value="Warm Air">Warm Air</option>
<option value="Forced Air">Forced Air</option>
<option value="Gas">Gas</option>
</select>
</div>
<div className="col-md-4">
Building Style
<select
className="form-floating mb-3 form-control"
name="buildingstyle"
value={formData.buildingstyle}
onChange={handleInputChange}
required
>
<option value="">Please Select</option>
<option value="One Story">One Story</option>
<option value="Craftsman">Craftsman</option>
<option value="Log/Cabin">Log/Cabin</option>
<option value="Split-Level">Split-Level</option>
<option value="Split-Foyer">Split-Foyer</option>
<option value="Stick Built">Stick Built</option>
<option value="Single wide">Single wide</option>
<option value="Double wide">Double wide</option>
<option value="Duplex">Duplex</option>
<option value="Triplex">Triplex</option>
<option value="Quadruplex">Quadruplex</option>
<option value="Two Story">Two Story</option>
<option value="Victorian">Victorian</option>
<option value="Tudor">Tudor</option>
<option value="Modern">Modern</option>
<option value="Art Deco">Art Deco</option>
<option value="Bungalow">Bungalow</option>
<option value="Mansion">Mansion</option>
<option value="Farmhouse">Farmhouse</option>
<option value="Conventional">Conventional</option>
<option value="Ranch">Ranch</option>
<option value="Ranch with Basement">
Ranch with Basement
</option>
<option value="Cape Cod">Cape Cod</option>
<option value="Contemporary">Contemporary</option>
<option value="Colonial">Colonial</option>
<option value="Mediterranean">Mediterranean</option>
</select>
</div>
<div className="col-md-4">
Site Vacant
<select
className="form-floating mb-3 form-control"
name="sitevacant"
value={formData.sitevacant}
onChange={handleInputChange}
required
>
<option value="">Please select</option>
<option value="Yes">Yes</option>
<option value="No">No</option>
</select>
</div>
</div>
<div className="row gy-3">
<div className="col-md-4">
Ext Wall
<select
className="form-floating mb-3 form-control"
name="extwall"
value={formData.extwall}
onChange={handleInputChange}
required
>
<option value="">Please Select</option>
<option value="N/A">N/A</option>
<option value="Brick">Brick</option>
<option value="Brick/Vinyl Siding">
Brick/Vinyl Siding
</option>
<option value="Wood/Vinyl Siding">
Wood/Vinyl Siding
</option>
<option value="Brick/Wood Siding">
Brick/Wood Siding
</option>
<option value="Stone">Stone</option>
<option value="Masonry">Masonry</option>
<option value="Metal">Metal</option>
<option value="Fiberboard">Fiberboard</option>
<option value="Asphalt Siding">Asphalt Siding</option>
<option value="Concrete Block">Concrete Block</option>
<option value="Gable">Gable</option>
<option value="Brick Veneer">Brick Veneer</option>
<option value="Frame">Frame</option>
<option value="Siding">Siding</option>
<option value="Cement/Wood Fiber Siding">
Cement/Wood Fiber Siding
</option>
<option value="Fiber/Cement Siding">
Fiber/Cement Siding
</option>
<option value="Wood Siding">Wood Siding</option>
<option value="Vinyl Siding">Vinyl Siding</option>
<option value="Aluminium Siding">Aluminium Siding</option>
<option value="Wood/Vinyl Siding">
Alum/Vinyl Siding
</option>
</select>
</div>
<div className="col-md-4">
Roofing
<select
className="form-floating mb-3 form-control"
name="roofing"
value={formData.roofing}
onChange={handleInputChange}
required
>
<option value="">Please Select</option>
<option value="N/A">N/A</option>
<option value="Asphalt Shingle">Asphalt Shingle</option>
<option value="Green Roofs">Green Roofs</option>
<option value="Built-up Roofing">Built-up Roofing</option>
<option value="Composition Shingle">
Composition Shingle
</option>
<option value="Composition Shingle Heavy">
Composition Shingle Heavy
</option>
<option value="Solar tiles">Solar tiles</option>
<option value="Metal">Metal</option>
<option value="Stone-coated steel">
Stone-coated steel
</option>
<option value="Slate">Slate</option>
<option value="Rubber Slate">Rubber Slate</option>
<option value="Clay and Concrete tiles">
Clay and Concrete tiles
</option>
</select>
</div>
<div className="col-md-4">
<div className="form-floating mb-3">
Total SQFT
<input
type="text"
className="form-control"
name="totalSqft"
value={formData.totalSqft}
onChange={handleInputChange}
required
/>
</div>
</div>
</div>
<div className="row gy-3"></div>
<h3
style={{
color: "#fda417",