done
This commit is contained in:
parent
fe8d8c7772
commit
4448c7560f
|
@ -5,8 +5,14 @@ const propertySchema = mongoose.Schema({
|
|||
title: {type: String, required: true },
|
||||
yearBuild: {type: String, required: true },
|
||||
totalSqft: {type: String, required: true },
|
||||
userfirstname: String,
|
||||
usermiddlename: String,
|
||||
userlastname: String,
|
||||
usertitle: String,
|
||||
creator: String,
|
||||
useremail: String,
|
||||
propertyId: String,
|
||||
userId:String,
|
||||
createdAt: {
|
||||
type: Date,
|
||||
default: new Date(),
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -42,7 +42,7 @@
|
|||
<!-- <script src="https://stackpath.bootstrapcdn.com/bootstrap/5.1.3/js/bootstrap.bundle.min.js"></script> -->
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0/dist/js/bootstrap.bundle.min.js"></script>
|
||||
|
||||
<script type="module" crossorigin src="/assets/index-DP5Z5_jo.js"></script>
|
||||
<script type="module" crossorigin src="/assets/index-0-EQa57V.js"></script>
|
||||
<link rel="stylesheet" crossorigin href="/assets/index-BrT2kTNU.css">
|
||||
</head>
|
||||
|
||||
|
|
|
@ -11,26 +11,24 @@ const Addproperty = () => {
|
|||
|
||||
const handleContinue = () => {
|
||||
if (activeTab === "propertydetails") setActiveTab("shipping");
|
||||
// else if (activeTab === 'shipping') setActiveTab('review');
|
||||
};
|
||||
|
||||
const handleBack = () => {
|
||||
// if (activeTab === 'review') setActiveTab('shipping');
|
||||
// else if (activeTab === 'shipping') setActiveTab('propertydetails');
|
||||
if (activeTab === "shipping") setActiveTab("propertydetails");
|
||||
};
|
||||
|
||||
const dispatch = useDispatch();
|
||||
const { status, error } = useSelector((state) => state.property); // Assuming propertySlice handles status and error
|
||||
const { status, error } = useSelector((state) => state.property);
|
||||
const { user } = useSelector((state) => ({ ...state.auth }));
|
||||
|
||||
const [formData, setFormData] = useState({
|
||||
propertyType: "",
|
||||
title: "",
|
||||
yearBuild: "",
|
||||
totalSqft: "", // This will now be used in the shipping tab
|
||||
totalSqft: "", // Used in the shipping tab
|
||||
});
|
||||
|
||||
const [submitted, setSubmitted] = useState(false); // Track if the form was submitted
|
||||
const [submitted, setSubmitted] = useState(false);
|
||||
|
||||
const handleInputChange = (e) => {
|
||||
setFormData({
|
||||
|
@ -46,9 +44,20 @@ const Addproperty = () => {
|
|||
formData.yearBuild &&
|
||||
formData.totalSqft
|
||||
) {
|
||||
// Dispatch the form data only if all fields are filled
|
||||
dispatch(submitProperty(formData));
|
||||
setSubmitted(true); // Mark the form as submitted
|
||||
// Add user info to formData
|
||||
const formDataWithUserInfo = {
|
||||
...formData,
|
||||
userfirstname: user?.result?.firstName,
|
||||
usermiddlename: user?.result?.middleName,
|
||||
userlastname: user?.result?.lastName,
|
||||
usertitle: user?.result?.title,
|
||||
useremail: user?.result?.email,
|
||||
userId:user?.result?.userId,
|
||||
};
|
||||
|
||||
// Dispatch the form data with user info
|
||||
dispatch(submitProperty(formDataWithUserInfo));
|
||||
setSubmitted(true);
|
||||
} else {
|
||||
toast.error("Please fill all fields before submitting", {
|
||||
position: "top-right",
|
||||
|
@ -57,7 +66,6 @@ const Addproperty = () => {
|
|||
}
|
||||
};
|
||||
|
||||
// Show toast after form submission, based on status and error from Redux
|
||||
useEffect(() => {
|
||||
if (submitted) {
|
||||
if (status === "succeeded") {
|
||||
|
@ -65,13 +73,13 @@ const Addproperty = () => {
|
|||
position: "top-right",
|
||||
autoClose: 3000,
|
||||
});
|
||||
setSubmitted(false); // Reset after showing toast
|
||||
setSubmitted(false);
|
||||
} else if (status === "failed") {
|
||||
toast.error(`Failed to submit: ${error}`, {
|
||||
position: "top-right",
|
||||
autoClose: 3000,
|
||||
});
|
||||
setSubmitted(false); // Reset after showing toast
|
||||
setSubmitted(false);
|
||||
}
|
||||
}
|
||||
}, [status, error, submitted]);
|
||||
|
|
Loading…
Reference in New Issue