nestiq-component-library 1.1.53 → 1.1.54

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,19 +4,27 @@ import mail_icon from "../../assets/Images/mail-icon.png";
4
4
  import SuccessPopUp from "../MessagePopup/SuccessPopup";
5
5
  import ErrorPopUp from "../MessagePopup/ErrorPopup";
6
6
  import "../MessagePopup/MessagePopUp.css";
7
- // import { showToast } from "nestiq-component-library";
7
+ import showToast from "../ToastWrapper/ToastWrapper";
8
8
 
9
9
  interface PopupProps {
10
10
  firstname: string;
11
11
  lastname: string;
12
12
  handleSendMessage: any;
13
13
  onClick: any;
14
- themesList:any;
14
+ themesList: any;
15
+ requestObj: {
16
+ fromUser: string;
17
+ property: string;
18
+ text: string;
19
+ firstName: string;
20
+ lastName: string;
21
+ theme: string;
22
+ subject: string;
23
+ };
15
24
  }
16
25
 
17
- export default function MessagePopUp(props:PopupProps) {
18
-
19
- const [showMessagePopUp, setshowMessagePopUp]= useState();
26
+ export default function MessagePopUp(props: PopupProps) {
27
+ const [showMessagePopUp, setshowMessagePopUp] = useState();
20
28
  const [showSuccessPopUp, setShowSuccessPopUp] = useState(false);
21
29
  const [showErrorPopUp, setShowErrorPopUp] = useState(false);
22
30
  const [themeId, setThemeId] = useState("");
@@ -24,22 +32,40 @@ export default function MessagePopUp(props:PopupProps) {
24
32
  const [messageText, setMessageText] = useState("");
25
33
  const [firstName, setFirstName] = useState("");
26
34
  const [lastName, setLastName] = useState("");
35
+ const [id, setId] = useState("");
27
36
 
28
37
  const handleClose = () => {
29
38
  props.onClick();
30
39
  };
31
40
  const handleSendMessage = () => {
32
- props.handleSendMessage();
33
- }
34
- useEffect(() => {
35
- const user = JSON.parse(localStorage.getItem("user") || "{}");
36
- if (user) {
37
- setFirstName(user.firstname || "");
38
- setLastName(user.lastname || "");
39
- } else if (!user) {
40
- console.log("no user");
41
- }
42
- }, []);
41
+ if (!messageText || !subject || !firstName || !lastName || !themeId) {
42
+ // toast.warning("Please fill in all fields.");
43
+ showToast("Please fill in all fields.", "warning");
44
+ return;
45
+ }
46
+
47
+ const user = JSON.parse(localStorage.getItem("user" ) || "{}");
48
+ const userId = user.id;
49
+
50
+ const requestObj = {
51
+ fromUser: `/users/${userId}`,
52
+ property: `/properties/${id}`,
53
+ text: messageText,
54
+ firstName,
55
+ lastName,
56
+ theme: `/themes/${themeId}`,
57
+ subject: subject,
58
+ };
59
+ };
60
+ useEffect(() => {
61
+ const user = JSON.parse(localStorage.getItem("user") || "{}");
62
+ if (user) {
63
+ setFirstName(user.firstname || "");
64
+ setLastName(user.lastname || "");
65
+ } else if (!user) {
66
+ console.log("no user");
67
+ }
68
+ }, []);
43
69
  return (
44
70
  <div>
45
71
  <div className="popup-overlay">
@@ -47,6 +47,15 @@ interface PopupProps {
47
47
  firstname: any;
48
48
  lastname: any;
49
49
  themesList: any;
50
+ requestObj: {
51
+ fromUser: string;
52
+ property: string;
53
+ text: string;
54
+ firstName: string;
55
+ lastName: string;
56
+ theme: string;
57
+ subject: string;
58
+ };
50
59
  }
51
60
  export default function PropertyCard(props: PopupProps) {
52
61
  const [liked, setLiked] = useState(false);
@@ -285,6 +294,7 @@ export default function PropertyCard(props: PopupProps) {
285
294
  firstname={props.firstname}
286
295
  lastname={props.lastname}
287
296
  themesList={props.themesList}
297
+ requestObj={props.requestObj}
288
298
  />
289
299
  )}
290
300
  {sharePopUp && <SharePopup onClick={() => setSharePopUp(false)} />}