nestiq-component-library 1.1.54 → 1.1.56

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.
@@ -12,15 +12,7 @@ interface PopupProps {
12
12
  handleSendMessage: any;
13
13
  onClick: any;
14
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
+ sendDataToParent: any;
24
16
  }
25
17
 
26
18
  export default function MessagePopUp(props: PopupProps) {
@@ -32,31 +24,15 @@ export default function MessagePopUp(props: PopupProps) {
32
24
  const [messageText, setMessageText] = useState("");
33
25
  const [firstName, setFirstName] = useState("");
34
26
  const [lastName, setLastName] = useState("");
35
- const [id, setId] = useState("");
27
+
36
28
 
37
29
  const handleClose = () => {
38
30
  props.onClick();
39
31
  };
40
- const handleSendMessage = () => {
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
- };
32
+ function handleSendMessage() {
33
+ props.sendDataToParent(themeId, subject, messageText, firstName, lastName);
59
34
  };
35
+
60
36
  useEffect(() => {
61
37
  const user = JSON.parse(localStorage.getItem("user") || "{}");
62
38
  if (user) {
@@ -9,10 +9,9 @@ import moreIcon from "../../assets/Images/more.svg";
9
9
  import arrowLeft from "../../assets/Images/card-arrow-left.svg";
10
10
  import arrowRight from "../../assets/Images/card-arrow-right.svg";
11
11
  import iconLayers from "../../assets/Images/layer_icon.svg";
12
- import FloorPlanPopup from "../FloorPlanPopup/FloorPlanPopup";
12
+ import FloorPlanPopup from "../FloorPlanPopup/FloorPlanPopup";
13
13
  import MessagePopUp from "../MessagePopup/MessagePopUp";
14
- import SharePopup from "../SharePopup/SharePopup";
15
-
14
+ import SharePopup from "../SharePopup/SharePopup";
16
15
 
17
16
  interface PopupProps {
18
17
  property: {
@@ -47,15 +46,7 @@ interface PopupProps {
47
46
  firstname: any;
48
47
  lastname: any;
49
48
  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
- };
49
+ sendData: any;
59
50
  }
60
51
  export default function PropertyCard(props: PopupProps) {
61
52
  const [liked, setLiked] = useState(false);
@@ -65,6 +56,11 @@ export default function PropertyCard(props: PopupProps) {
65
56
  const [floorPlan, setFloorPlan] = useState(false);
66
57
  const [messagePopUp, setMessagPopUp] = useState(false);
67
58
  const [sharePopUp, setSharePopUp] = useState(false);
59
+ const [themeId, setThemeId] = useState("");
60
+ const [subject, setSubject] = useState("");
61
+ const [messageText, setMessageText] = useState("");
62
+ const [firstName, setFirstName] = useState("");
63
+ const [lastName, setLastName] = useState("");
68
64
 
69
65
  const pictureUrls =
70
66
  props.property?.pictures?.length > 0
@@ -88,14 +84,30 @@ export default function PropertyCard(props: PopupProps) {
88
84
  setSharePopUp(true);
89
85
  console.log("sharePopUp", sharePopUp);
90
86
  };
91
- const handleClosePopup = () =>{
87
+ const handleClosePopup = () => {
92
88
  setFloorPlan(false);
93
89
  setMessagPopUp(false);
94
- }
95
- const messagePopupClose = () =>{
90
+ };
91
+ const messagePopupClose = () => {
96
92
  setMessagPopUp(false);
93
+ };
94
+ function handleDataFromChild(
95
+ firstName: string,
96
+ lastName: string,
97
+ themeId: string,
98
+ subject: string,
99
+ messageText: string
100
+ ) {
101
+ setFirstName(firstName);
102
+ setLastName(lastName);
103
+ setThemeId(themeId);
104
+ setSubject(subject);
105
+ setMessageText(messageText);
106
+ }
107
+ function handleSendMessage() {
108
+ props.sendData(themeId, subject, messageText, firstName, lastName);
97
109
  }
98
-
110
+
99
111
  const handleArrowClickInMainImage = (direction: string) => {
100
112
  if (!props.property || pictureUrls.length === 0) return;
101
113
 
@@ -294,7 +306,7 @@ export default function PropertyCard(props: PopupProps) {
294
306
  firstname={props.firstname}
295
307
  lastname={props.lastname}
296
308
  themesList={props.themesList}
297
- requestObj={props.requestObj}
309
+ sendDataToParent={handleDataFromChild}
298
310
  />
299
311
  )}
300
312
  {sharePopUp && <SharePopup onClick={() => setSharePopUp(false)} />}