done
This commit is contained in:
parent
fe8d8c7772
commit
4448c7560f
|
@ -5,8 +5,14 @@ const propertySchema = mongoose.Schema({
|
||||||
title: {type: String, required: true },
|
title: {type: String, required: true },
|
||||||
yearBuild: {type: String, required: true },
|
yearBuild: {type: String, required: true },
|
||||||
totalSqft: {type: String, required: true },
|
totalSqft: {type: String, required: true },
|
||||||
|
userfirstname: String,
|
||||||
|
usermiddlename: String,
|
||||||
|
userlastname: String,
|
||||||
|
usertitle: String,
|
||||||
creator: String,
|
creator: String,
|
||||||
|
useremail: String,
|
||||||
propertyId: String,
|
propertyId: String,
|
||||||
|
userId:String,
|
||||||
createdAt: {
|
createdAt: {
|
||||||
type: Date,
|
type: Date,
|
||||||
default: new 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://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 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">
|
<link rel="stylesheet" crossorigin href="/assets/index-BrT2kTNU.css">
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
|
|
|
@ -11,26 +11,24 @@ const Addproperty = () => {
|
||||||
|
|
||||||
const handleContinue = () => {
|
const handleContinue = () => {
|
||||||
if (activeTab === "propertydetails") setActiveTab("shipping");
|
if (activeTab === "propertydetails") setActiveTab("shipping");
|
||||||
// else if (activeTab === 'shipping') setActiveTab('review');
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleBack = () => {
|
const handleBack = () => {
|
||||||
// if (activeTab === 'review') setActiveTab('shipping');
|
|
||||||
// else if (activeTab === 'shipping') setActiveTab('propertydetails');
|
|
||||||
if (activeTab === "shipping") setActiveTab("propertydetails");
|
if (activeTab === "shipping") setActiveTab("propertydetails");
|
||||||
};
|
};
|
||||||
|
|
||||||
const dispatch = useDispatch();
|
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({
|
const [formData, setFormData] = useState({
|
||||||
propertyType: "",
|
propertyType: "",
|
||||||
title: "",
|
title: "",
|
||||||
yearBuild: "",
|
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) => {
|
const handleInputChange = (e) => {
|
||||||
setFormData({
|
setFormData({
|
||||||
|
@ -46,9 +44,20 @@ const Addproperty = () => {
|
||||||
formData.yearBuild &&
|
formData.yearBuild &&
|
||||||
formData.totalSqft
|
formData.totalSqft
|
||||||
) {
|
) {
|
||||||
// Dispatch the form data only if all fields are filled
|
// Add user info to formData
|
||||||
dispatch(submitProperty(formData));
|
const formDataWithUserInfo = {
|
||||||
setSubmitted(true); // Mark the form as submitted
|
...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 {
|
} else {
|
||||||
toast.error("Please fill all fields before submitting", {
|
toast.error("Please fill all fields before submitting", {
|
||||||
position: "top-right",
|
position: "top-right",
|
||||||
|
@ -57,7 +66,6 @@ const Addproperty = () => {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Show toast after form submission, based on status and error from Redux
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (submitted) {
|
if (submitted) {
|
||||||
if (status === "succeeded") {
|
if (status === "succeeded") {
|
||||||
|
@ -65,13 +73,13 @@ const Addproperty = () => {
|
||||||
position: "top-right",
|
position: "top-right",
|
||||||
autoClose: 3000,
|
autoClose: 3000,
|
||||||
});
|
});
|
||||||
setSubmitted(false); // Reset after showing toast
|
setSubmitted(false);
|
||||||
} else if (status === "failed") {
|
} else if (status === "failed") {
|
||||||
toast.error(`Failed to submit: ${error}`, {
|
toast.error(`Failed to submit: ${error}`, {
|
||||||
position: "top-right",
|
position: "top-right",
|
||||||
autoClose: 3000,
|
autoClose: 3000,
|
||||||
});
|
});
|
||||||
setSubmitted(false); // Reset after showing toast
|
setSubmitted(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, [status, error, submitted]);
|
}, [status, error, submitted]);
|
||||||
|
|
Loading…
Reference in New Issue