This commit is contained in:
omkieit 2024-10-07 19:53:54 +05:30
parent d4170a12d9
commit 26533eb6df
4 changed files with 114 additions and 26 deletions

View File

@ -178,6 +178,10 @@ const propertySchema = mongoose.Schema({
type: Number, type: Number,
required: true, // Set to true if this field is mandatory required: true, // Set to true if this field is mandatory
}, },
sellpricebtoc:{
type: Number,
required: true, // Set to true if this field is mandatory
},
}); });
const PropertyModal = mongoose.model("property", propertySchema); 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-P2J43GlO.js"></script> <script type="module" crossorigin src="/assets/index-CfFcG7AV.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

@ -585,7 +585,8 @@ const Addproperty = () => {
formData.extwall && formData.extwall &&
formData.roofing && formData.roofing &&
formData.totalSqft && formData.totalSqft &&
formData.totalcashsurplus formData.totalcashsurplus &&
formData.sellpricebtoc
) { ) {
const totalCostsAtoB = calculateTotalCosts(); const totalCostsAtoB = calculateTotalCosts();
const totalCostsAtoBaftercredits = calculateTotalCostsWithCredits(); const totalCostsAtoBaftercredits = calculateTotalCostsWithCredits();
@ -1595,19 +1596,39 @@ const Addproperty = () => {
<div className="col-md-4"> <div className="col-md-4">
<input <input
type="text" type="text"
className="form-control" className={`form-control ${formData.isPurchaseCostInvalid ? "is-invalid" : ""}`}
value={formData.purchaseCost} value={formData.purchaseCost}
onChange={(e) => onChange={(e) => {
const value = e.target.value;
const isValid = /^\d*\.?\d*$/.test(value); // Regex to allow only numbers and decimal points
setFormData({ setFormData({
...formData, ...formData,
purchaseCost: e.target.value, purchaseCost: value,
}) isPurchaseCostInvalid: !isValid, // Set isPurchaseCostInvalid to true if the value is not a valid number
});
}}
onKeyPress={(e) => {
const charCode = e.charCode;
// Allow only numbers and decimal points
if ((charCode < 48 || charCode > 57) && charCode !== 46) {
e.preventDefault(); // Prevent non-numeric input
setFormData({
...formData,
isPurchaseCostInvalid: true, // Set isPurchaseCostInvalid to true to show the alert
});
} }
}}
placeholder="Enter Purchase Cost" placeholder="Enter Purchase Cost"
style={{ textAlign: "right" }} style={{ textAlign: "right" }}
required required
/> />
{formData.isPurchaseCostInvalid && (
<div className="invalid-feedback">
Please enter a valid number.
</div> </div>
)}
</div>
</div> </div>
<hr <hr
style={{ style={{
@ -2421,6 +2442,69 @@ const Addproperty = () => {
/> />
<div className="row gy-3 align-items-center">
<span
className="col-md-4"
style={{
color: "#fda417",
fontSize: "14px",
fontWeight: "bold",
}}
>
Selling Price B to C
</span>
<div className="col-md-4">
<input
type="text"
className={`form-control ${formData.isInvalid ? "is-invalid" : ""}`}
name="sellpricebtoc"
value={formData.sellpricebtoc}
onChange={(e) => {
const value = e.target.value;
const isValid = /^\d*\.?\d*$/.test(value); // Allow only numbers and decimal points
setFormData({
...formData,
sellpricebtoc: value,
isInvalid: !isValid, // Set isInvalid to true if the value is not a valid number
});
}}
onKeyPress={(e) => {
const charCode = e.charCode;
// Allow only numbers and decimal point
if ((charCode < 48 || charCode > 57) && charCode !== 46) {
e.preventDefault(); // Prevent non-numeric input
setFormData({
...formData,
isInvalid: true, // Set isInvalid to true to show the alert
});
}
}}
placeholder="Selling Price B to C"
style={{ textAlign: "right" }}
required
/>
{formData.isInvalid && (
<div className="invalid-feedback">
Please enter a valid number.
</div>
)}
</div>
</div>
<hr
style={{
borderColor: "#fda417", // Set the color of the line
borderWidth: "1px", // Optional: Adjust the thickness of the line
backgroundColor: "#fda417", // Optional: Apply color if using for background
height: "1px", // Optional: Set height to match the border width
}}
/>