rasp-feedback 1.0.2 → 1.0.3

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.
@@ -0,0 +1,10 @@
1
+ declare function MainViewHandler({ form, mainTheme, fields, post, companyId, isLoadingFeedbackModal }: {
2
+ form: any;
3
+ mainTheme: any;
4
+ fields: any[];
5
+ post?: any;
6
+ companyId: string;
7
+ isLoadingFeedbackModal: boolean;
8
+ }): import("react/jsx-runtime").JSX.Element;
9
+ export default MainViewHandler;
10
+ //# sourceMappingURL=MainViewHandler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MainViewHandler.d.ts","sourceRoot":"","sources":["../../../src/nextjs/components/MainViewHandler.tsx"],"names":[],"mappings":"AAGA,iBAAS,eAAe,CAAC,EAAC,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,sBAAsB,EAAC,EAAC;IAAG,IAAI,EAAE,GAAG,CAAC;IACvG,SAAS,EAAE,GAAG,CAAC;IACf,MAAM,EAAE,GAAG,EAAE,CAAC;IACZ,IAAI,CAAC,EAAC,GAAG,CAAC;IACV,SAAS,EAAC,MAAM,CAAC;IACjB,sBAAsB,EAAC,OAAO,CAAC;CAClC,2CAuBA;AAED,eAAe,eAAe,CAAA"}
@@ -0,0 +1,17 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useEffect } from 'react';
3
+ function MainViewHandler({ form, mainTheme, fields, post, companyId, isLoadingFeedbackModal }) {
4
+ useEffect(() => {
5
+ if (typeof window === 'undefined')
6
+ return;
7
+ if (!document.getElementById('rasp-google-fonts')) {
8
+ const link = document.createElement('link');
9
+ link.id = 'rasp-google-fonts';
10
+ link.rel = 'stylesheet';
11
+ link.href = 'https://fonts.googleapis.com/css2?family=Inter:wght@600&family=Roboto:wght@600&family=Poppins:wght@800&family=Wix+Madefor+Text:wght@400&family=Montserrat:wght@600&family=Nunito:wght@600&family=Open+Sans:wght@600&family=Lato:wght@700&family=Work+Sans:wght@600&family=Source+Sans+3:wght@600&family=Rubik:wght@600&family=Playfair+Display:wght@700&family=Raleway:wght@700&family=DM+Serif+Display&family=Oswald:wght@600&family=Bebas+Neue&family=Merriweather:wght@700&family=Libre+Baskerville:wght@700&family=Cormorant+Garamond:wght@600&family=JetBrains+Mono:wght@600&family=Fira+Code:wght@600&display=swap';
12
+ document.head.appendChild(link);
13
+ }
14
+ }, []);
15
+ return (_jsx("div", {}));
16
+ }
17
+ export default MainViewHandler;
@@ -0,0 +1,7 @@
1
+ declare function PostItem({ post, setShowVoteUI, setCurrentPost }: {
2
+ post: any;
3
+ setShowVoteUI: any;
4
+ setCurrentPost: any;
5
+ }): import("react/jsx-runtime").JSX.Element;
6
+ export default PostItem;
7
+ //# sourceMappingURL=PostItem.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PostItem.d.ts","sourceRoot":"","sources":["../../../src/nextjs/components/PostItem.tsx"],"names":[],"mappings":"AAIA,iBAAS,QAAQ,CAAC,EAAC,IAAI,EAAE,aAAa,EAAE,cAAc,EAAC,EAAC;IACpD,IAAI,EAAC,GAAG,CAAC;IACT,aAAa,EAAC,GAAG,CAAC;IAClB,cAAc,EAAC,GAAG,CAAC;CAEtB,2CA2CA;AAED,eAAe,QAAQ,CAAA"}
@@ -0,0 +1,34 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { fontMap } from '../constants/fontexp';
3
+ import { CircleArrowDown, CircleArrowUp } from 'lucide-react';
4
+ function PostItem({ post, setShowVoteUI, setCurrentPost }) {
5
+ return (_jsxs("div", { onClick: () => {
6
+ setCurrentPost(post);
7
+ setShowVoteUI(true);
8
+ }, style: {
9
+ padding: "5px",
10
+ width: "100%",
11
+ display: "flex",
12
+ flexDirection: "row",
13
+ gap: "20px",
14
+ justifyContent: "start",
15
+ alignItems: "center",
16
+ borderBottom: "2px solid black",
17
+ cursor: "pointer"
18
+ }, children: [_jsxs("div", { style: {
19
+ display: "flex",
20
+ flexDirection: "row",
21
+ gap: "5px",
22
+ alignItems: "center"
23
+ }, children: [_jsx(CircleArrowUp, { size: 20 }), _jsx("p", { className: fontMap.wixmadefor.className, style: {
24
+ fontSize: "14px"
25
+ }, children: post.upvote_count }), _jsx(CircleArrowDown, { size: 20 }), _jsx("p", { className: fontMap.wixmadefor.className, style: {
26
+ fontSize: "14px"
27
+ }, children: post.downvote_count })] }), _jsxs("div", { children: [_jsx("h1", { className: fontMap.poppins.className, style: {
28
+ fontSize: "12px"
29
+ }, children: post.title }), _jsx("h2", { className: fontMap.wixmadefor.className, style: {
30
+ fontSize: "10px",
31
+ color: "gray"
32
+ }, children: post.subtitle.slice(0, 65) + "..." })] })] }));
33
+ }
34
+ export default PostItem;
@@ -0,0 +1,7 @@
1
+ declare function Posttem({ post, setShowVoteUI, setCurrentPost }: {
2
+ post: any;
3
+ setShowVoteUI: any;
4
+ setCurrentPost: any;
5
+ }): import("react/jsx-runtime").JSX.Element;
6
+ export default Posttem;
7
+ //# sourceMappingURL=Posttem.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Posttem.d.ts","sourceRoot":"","sources":["../../../src/nextjs/components/Posttem.tsx"],"names":[],"mappings":"AAGA,iBAAS,OAAO,CAAC,EAAC,IAAI,EAAE,aAAa,EAAE,cAAc,EAAC,EAAC;IACnD,IAAI,EAAC,GAAG,CAAC;IACT,aAAa,EAAC,GAAG,CAAC;IAClB,cAAc,EAAC,GAAG,CAAC;CAEtB,2CAeA;AAED,eAAe,OAAO,CAAA"}
@@ -0,0 +1,14 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { fontMap } from '../constants/fontexp';
3
+ function Posttem({ post, setShowVoteUI, setCurrentPost }) {
4
+ return (_jsxs("div", { onClick: () => {
5
+ setCurrentPost(post);
6
+ setShowVoteUI(true);
7
+ }, style: { padding: "5px" }, children: [_jsx("h1", { className: fontMap.poppins.className, style: {
8
+ fontSize: "12px"
9
+ }, children: post.title }), _jsx("h2", { className: fontMap.poppins.className, style: {
10
+ fontSize: "12px",
11
+ color: "gray"
12
+ }, children: post.subtitle.slice(0, 25) + "..." })] }));
13
+ }
14
+ export default Posttem;
@@ -1 +1 @@
1
- {"version":3,"file":"RaspProvider.d.ts","sourceRoot":"","sources":["../../../src/nextjs/components/RaspProvider.tsx"],"names":[],"mappings":"AAEA,OAAO,KAA6B,MAAM,OAAO,CAAC;AAKlD,OAAO,cAAc,CAAA;AAMrB,MAAM,WAAW,iBAAiB;IAChC,gBAAgB,CAAC,EAAC;QAChB,GAAG,CAAC,EAAC,MAAM,CAAC;QACZ,IAAI,CAAC,EAAC,MAAM,CAAA;KACb,CAAA;IACD,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B;AAGD,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC,iBAAiB,CAoNpD,CAAA"}
1
+ {"version":3,"file":"RaspProvider.d.ts","sourceRoot":"","sources":["../../../src/nextjs/components/RaspProvider.tsx"],"names":[],"mappings":"AAEA,OAAO,KAA6B,MAAM,OAAO,CAAC;AAKlD,OAAO,cAAc,CAAA;AAQrB,MAAM,WAAW,iBAAiB;IAChC,gBAAgB,CAAC,EAAC;QAChB,GAAG,CAAC,EAAC,MAAM,CAAC;QACZ,IAAI,CAAC,EAAC,MAAM,CAAA;KACb,CAAA;IACD,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B;AAGD,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC,iBAAiB,CA+cpD,CAAA"}
@@ -1,44 +1,51 @@
1
1
  'use client'; // Important for Next.js App Router
2
- import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { useEffect, useState } from 'react';
4
4
  { /*@ts-ignore*/ }
5
- import { getFormByDomainOrCompany, getBrandTheme, getFormTheme } from '../functions/functionsexp';
5
+ import { getFormByDomainOrCompany, getBrandTheme, getFormTheme, getBoardPosts, upvoteBoardPost, downvoteBoardPost } from '../functions/functionsexp';
6
6
  import { MessageSquare } from 'lucide-react';
7
7
  import "../index.css";
8
8
  import StaticFormComponent from './StaticFormComponent';
9
9
  import Skeleton from './Skeleton';
10
10
  import { fontMap } from '../constants/fontexp';
11
11
  import { RASP_LOGO_BASE64 } from '../constants/baserasplogo';
12
+ import { CircleArrowUp, CircleArrowDown, MessageCircle } from 'lucide-react';
13
+ import PostItem from './PostItem';
12
14
  export const RaspProvider = ({ children, launcherPosition }) => {
13
15
  const [companyId, setCompanyId] = useState(null);
14
16
  const [currentUrl, setCurrentUrl] = useState('');
15
17
  const [form, setForm] = useState(null);
16
18
  const [fields, setFields] = useState(null);
17
19
  const [mainTheme, setMainTheme] = useState(null);
18
- const [showForm, setShowForm] = useState(false);
19
- const [isLoading, setIsLoading] = useState(true);
20
- const [showFormSkeleton, setShowFormSkeleton] = useState(false);
21
- useEffect(() => {
22
- if (typeof window === 'undefined')
23
- return;
24
- if (!document.getElementById('rasp-google-fonts')) {
25
- const link = document.createElement('link');
26
- link.id = 'rasp-google-fonts';
27
- link.rel = 'stylesheet';
28
- link.href = 'https://fonts.googleapis.com/css2?family=Inter:wght@600&family=Roboto:wght@600&family=Poppins:wght@800&family=Wix+Madefor+Text:wght@400&family=Montserrat:wght@600&family=Nunito:wght@600&family=Open+Sans:wght@600&family=Lato:wght@700&family=Work+Sans:wght@600&family=Source+Sans+3:wght@600&family=Rubik:wght@600&family=Playfair+Display:wght@700&family=Raleway:wght@700&family=DM+Serif+Display&family=Oswald:wght@600&family=Bebas+Neue&family=Merriweather:wght@700&family=Libre+Baskerville:wght@700&family=Cormorant+Garamond:wght@600&family=JetBrains+Mono:wght@600&family=Fira+Code:wght@600&display=swap';
29
- document.head.appendChild(link);
30
- }
31
- }, []);
20
+ const [showController, setShowController] = useState(false);
21
+ const [showFeedbackModal, setShowFeedbackModal] = useState(false);
22
+ const [showBoardModal, setShowBoardModal] = useState(false);
23
+ const [isLoadingFeedbackModal, setIsLoadingFeedbackModal] = useState(false);
24
+ const [isLoadingBoardModal, setIsLoadingBoardModal] = useState(false);
25
+ const [showFeedbackModalSkeleton, setShowFeedbackModalSkeleton] = useState(false);
26
+ const [showBoardModalSkeleton, setShowBoardModalSkeleton] = useState(false);
27
+ const [posts, setPosts] = useState(null);
28
+ const [showVoteUI, setShowVoteUI] = useState(false);
29
+ const [currentPost, setCurrentPost] = useState(null);
32
30
  const getForm = async () => {
33
- setIsLoading(true);
31
+ setIsLoadingFeedbackModal(true);
34
32
  const f = await getFormByDomainOrCompany(companyId, currentUrl);
35
33
  if (!f) {
36
34
  setForm(f);
37
- setIsLoading(false);
35
+ setIsLoadingFeedbackModal(false);
38
36
  return;
39
37
  }
40
38
  setForm(f[0]);
41
39
  };
40
+ const getPosts = async () => {
41
+ setIsLoadingBoardModal(true);
42
+ const p = await getBoardPosts(companyId);
43
+ if (p) {
44
+ setPosts(p);
45
+ setIsLoadingBoardModal(false);
46
+ return;
47
+ }
48
+ };
42
49
  useEffect(() => {
43
50
  if (typeof window !== 'undefined') {
44
51
  setCompanyId(process.env.NEXT_PUBLIC_RASP_COMPANY_ID);
@@ -52,20 +59,63 @@ export const RaspProvider = ({ children, launcherPosition }) => {
52
59
  if (form.usebrandtheme === true) {
53
60
  getBrandTheme(companyId).then((brandTheme) => {
54
61
  setMainTheme(brandTheme);
62
+ setShowFeedbackModalSkeleton(false);
55
63
  });
56
64
  }
57
65
  if (form.usebrandtheme === false) {
58
66
  getFormTheme(form.formId).then((formTheme) => {
59
67
  setMainTheme(formTheme);
68
+ setShowFeedbackModalSkeleton(false);
60
69
  });
61
70
  }
62
71
  }
63
72
  }
64
73
  }, [form]);
65
- return (_jsxs("div", { children: [children, form && _jsx(_Fragment, { children: showForm && form.active && mainTheme && fields && _jsx("div", { id: "rasp-form-div", style: {
74
+ useEffect(() => {
75
+ if (typeof window === 'undefined')
76
+ return;
77
+ if (!document.getElementById('rasp-google-fonts')) {
78
+ const link = document.createElement('link');
79
+ link.id = 'rasp-google-fonts';
80
+ link.rel = 'stylesheet';
81
+ link.href = 'https://fonts.googleapis.com/css2?family=Inter:wght@600&family=Roboto:wght@600&family=Poppins:wght@800&family=Wix+Madefor+Text:wght@400&family=Montserrat:wght@600&family=Nunito:wght@600&family=Open+Sans:wght@600&family=Lato:wght@700&family=Work+Sans:wght@600&family=Source+Sans+3:wght@600&family=Rubik:wght@600&family=Playfair+Display:wght@700&family=Raleway:wght@700&family=DM+Serif+Display&family=Oswald:wght@600&family=Bebas+Neue&family=Merriweather:wght@700&family=Libre+Baskerville:wght@700&family=Cormorant+Garamond:wght@600&family=JetBrains+Mono:wght@600&family=Fira+Code:wght@600&display=swap';
82
+ document.head.appendChild(link);
83
+ }
84
+ }, []);
85
+ async function VoteFor(boardPostConvexId, vote) {
86
+ try {
87
+ const voteKey = `voted_${boardPostConvexId}`;
88
+ if (localStorage.getItem(voteKey)) {
89
+ alert("You already voted. Please view other features");
90
+ setShowVoteUI(false);
91
+ setCurrentPost(null);
92
+ return;
93
+ }
94
+ let result;
95
+ if (vote === true) {
96
+ result = await upvoteBoardPost(boardPostConvexId);
97
+ }
98
+ else if (vote === false) {
99
+ result = await downvoteBoardPost(boardPostConvexId);
100
+ }
101
+ // Only mark as voted if the API call succeeded
102
+ if (result) {
103
+ localStorage.setItem(voteKey, vote ? 'up' : 'down');
104
+ }
105
+ setShowVoteUI(false);
106
+ setCurrentPost(null);
107
+ await getPosts();
108
+ }
109
+ catch (error) {
110
+ console.error("Error in VoteFor:", error);
111
+ // If vote fails, localStorage won't be set, so user can retry
112
+ }
113
+ }
114
+ return (_jsxs("div", { children: [children, showFeedbackModal && form && !isLoadingFeedbackModal && form.active && mainTheme && fields &&
115
+ _jsx("div", { id: "rasp-form-div", style: {
66
116
  position: "fixed",
67
- top: "15%",
68
- left: "60%",
117
+ bottom: "8%",
118
+ right: "3%",
69
119
  zIndex: 1000000000000000,
70
120
  padding: 0,
71
121
  margin: 0,
@@ -76,10 +126,10 @@ export const RaspProvider = ({ children, launcherPosition }) => {
76
126
  display: "inline-block",
77
127
  transform: "translate(-50%, -25%)",
78
128
  overflow: "visible"
79
- }, children: _jsx(StaticFormComponent, { form: form, mainTheme: mainTheme, fields: fields }) }) }), !isLoading && !form && _jsxs("div", { style: {
129
+ }, children: _jsx(StaticFormComponent, { form: form, mainTheme: mainTheme, fields: fields }) }), !isLoadingFeedbackModal && showFeedbackModal && !form && _jsxs("div", { style: {
80
130
  position: "fixed",
81
- top: "19%",
82
- left: "60%",
131
+ bottom: "8%",
132
+ right: "3%",
83
133
  zIndex: 1000000000000000,
84
134
  display: 'flex',
85
135
  flexDirection: 'column',
@@ -88,19 +138,18 @@ export const RaspProvider = ({ children, launcherPosition }) => {
88
138
  backgroundColor: 'white',
89
139
  margin: '1.25rem',
90
140
  width: '470px',
91
- minHeight: '400px',
141
+ minHeight: '300px',
92
142
  border: '1px solid black',
93
143
  padding: '1rem',
94
144
  boxShadow: '0 1px 3px 0 rgba(0, 0, 0, 1), 0 1px 2px 0 rgba(0, 0, 0, 0.06)'
95
- }, children: [_jsx("br", {}), _jsx("br", {}), _jsx("img", { src: RASP_LOGO_BASE64, width: "150px", height: "150px", alt: "rasp logo" }), _jsx("h1", { className: `${fontMap.poppins.className}`, children: "404" }), _jsx("h2", { className: `${fontMap.wixmadefor.className}`, style: { textAlign: 'center' }, children: !companyId ? "CompanyId is not provided. Please provide companyId in your env file." : "No forms found for this URL." }), !companyId && _jsxs("p", { className: `${fontMap.wixmadefor.className}`, style: { textAlign: 'center' }, children: [" Refer to Rasp docs for help: ", _jsx("a", { href: 'https://tryrasp.online/docs', style: { textDecoration: "underline" }, children: "https://tryrasp.online/docs" })] }), companyId && _jsxs("p", { className: `${fontMap.wixmadefor.className}`, style: { textAlign: 'center' }, children: [" Set this as your form domain url: ", currentUrl] })] }), isLoading && showFormSkeleton && !form && !mainTheme &&
145
+ }, children: [_jsx("br", {}), _jsx("br", {}), _jsx("img", { src: RASP_LOGO_BASE64, width: "150px", height: "150px", alt: "rasp logo" }), _jsx("h1", { className: `${fontMap.poppins.className}`, children: "404" }), _jsx("h2", { className: `${fontMap.wixmadefor.className}`, style: { textAlign: 'center' }, children: !companyId ? "CompanyId is not provided. Please provide companyId in your env file." : "No forms found for this URL." }), !companyId && _jsxs("p", { className: `${fontMap.wixmadefor.className}`, style: { textAlign: 'center' }, children: [" Refer to Rasp docs for help: ", _jsx("a", { href: 'https://www.tryrasp.online/docs', style: { textDecoration: "underline" }, children: "https://www.tryrasp.online/docs" })] }), companyId && _jsxs("p", { className: `${fontMap.wixmadefor.className}`, style: { textAlign: 'center' }, children: [" Set this as your form domain url: ", currentUrl] })] }), isLoadingFeedbackModal && showFeedbackModalSkeleton && !form && !mainTheme &&
96
146
  _jsx("div", { id: "rasp-form-div", style: {
97
147
  position: "fixed",
98
- top: "18%",
99
- left: "60%",
148
+ bottom: "8%",
149
+ right: "3%",
100
150
  zIndex: 1000000000000000,
101
151
  padding: 0,
102
152
  margin: 0,
103
- border: 0,
104
153
  background: "transparent",
105
154
  width: "auto",
106
155
  height: "auto",
@@ -111,51 +160,162 @@ export const RaspProvider = ({ children, launcherPosition }) => {
111
160
  display: 'flex',
112
161
  flexDirection: "column",
113
162
  justifyContent: 'center',
114
- borderRadius: '0.75rem',
115
163
  backgroundColor: "white",
116
164
  margin: '1.25rem',
117
165
  width: '470px',
118
- minHeight: '400px',
119
- border: '1px solid whitesmoke',
166
+ height: 'auto',
167
+ border: "2px solid black",
168
+ borderRadius: "20px",
120
169
  padding: '2rem',
121
170
  paddingTop: "0px"
122
- }, children: _jsxs("div", { style: { marginTop: "-30px" }, children: [_jsx(Skeleton, { width: 400, height: 40 }), _jsx(Skeleton, { width: 400, height: 30 }), _jsx("br", {}), _jsx(Skeleton, { width: 400, height: 70 }), _jsx(Skeleton, { width: 400, height: 100 })] }) }) }), _jsx("div", { id: "rasp-launcher", onClick: () => {
123
- if (!currentUrl.trim() || !companyId)
124
- return;
125
- // If the form is visible, play exit animation then hide
126
- if (showForm) {
127
- const el = document.getElementById('rasp-form-div');
128
- if (el) {
129
- el.classList.add('rasp-exit');
130
- // match animation duration (250ms) + small buffer
131
- setTimeout(() => {
132
- setShowForm(false);
133
- el.classList.remove('rasp-exit');
134
- }, 300);
135
- return;
136
- }
137
- // fallback: just hide
138
- setShowForm(false);
139
- return;
140
- }
141
- setIsLoading(true);
142
- setShowFormSkeleton(true);
143
- // If the form is not visible, fetch then show it
144
- getForm().then(() => {
145
- setShowForm(true);
146
- setIsLoading(false);
147
- setShowFormSkeleton(false);
148
- });
171
+ }, children: _jsxs("div", { children: [_jsx("br", {}), _jsx(Skeleton, { width: 400, height: 40 }), _jsx(Skeleton, { width: 400, height: 30 }), _jsx("br", {}), _jsx(Skeleton, { width: 400, height: 70 }), _jsx(Skeleton, { width: 400, height: 90 }), _jsx("br", {}), _jsx("br", {})] }) }) }), showBoardModalSkeleton &&
172
+ _jsxs("div", { style: {
173
+ display: "flex",
174
+ flexDirection: "column",
175
+ gap: "5px",
176
+ width: "470px",
177
+ height: "400px",
178
+ position: "fixed",
179
+ border: "2px solid black",
180
+ borderRadius: "20px",
181
+ alignItems: 'center',
182
+ top: "22%",
183
+ left: "61%",
184
+ zIndex: 1000000000000000,
185
+ backgroundColor: "white"
186
+ }, children: [_jsx("br", {}), _jsx(Skeleton, { width: 440, height: 70 }), _jsx(Skeleton, { width: 440, height: 70 }), _jsx(Skeleton, { width: 440, height: 70 }), _jsx(Skeleton, { width: 440, height: 70 })] }), showBoardModal && !isLoadingBoardModal &&
187
+ _jsxs("div", { style: {
188
+ width: "470px",
189
+ height: "400px",
190
+ position: "fixed",
191
+ border: "2px solid black",
192
+ borderRadius: "20px",
193
+ alignItems: 'center',
194
+ top: "22%",
195
+ left: "61%",
196
+ zIndex: 1000000000000000,
197
+ backgroundColor: "white",
198
+ boxShadow: '0 1px 3px 0 rgba(0, 0, 0, 1), 0 1px 2px 0 rgba(0, 0, 0, 0.06)',
199
+ overflow: "hidden"
200
+ }, children: [_jsx("div", { style: {
201
+ display: "flex",
202
+ flexDirection: "column",
203
+ alignItems: "center",
204
+ justifyContent: "center",
205
+ borderBottom: "2px solid black",
206
+ height: "50px",
207
+ backgroundColor: "#9e54df",
208
+ }, children: _jsx("h1", { className: fontMap.poppins.className, style: {
209
+ color: "white"
210
+ }, children: "Vote for New Potential Features" }) }), _jsxs("div", { style: {
211
+ display: "flex",
212
+ flexDirection: "column",
213
+ gap: "5px",
214
+ margin: "10px",
215
+ height: "260px"
216
+ }, children: [posts && posts.length === 0 && _jsx(CircleArrowUp, { size: 100, color: "black", style: {
217
+ marginTop: '40px',
218
+ marginLeft: '40%'
219
+ } }), posts && posts.length === 0 && _jsx("h1", { className: fontMap.poppins.className, style: {
220
+ color: 'black',
221
+ textAlign: 'center',
222
+ fontSize: '16px',
223
+ marginTop: '40px'
224
+ }, children: "No New Features in the works at the moment. Please Check in later..." }), !showVoteUI && posts && posts.map((post, index) => (_jsx(PostItem, { post: post, setShowVoteUI: setShowVoteUI, setCurrentPost: setCurrentPost }, index))), showVoteUI && currentPost && _jsxs("div", { style: {
225
+ margin: "10px"
226
+ }, children: [_jsx("h1", { className: fontMap.poppins.className, style: {
227
+ fontSize: "20px"
228
+ }, children: currentPost.title }), _jsx("h2", { className: fontMap.wixmadefor.className, style: {
229
+ fontSize: "15px",
230
+ color: "gray"
231
+ }, children: currentPost.subtitle }), _jsx("p", { className: fontMap.wixmadefor.className, style: {
232
+ fontSize: "11px",
233
+ marginTop: "10px"
234
+ }, children: currentPost.description })] })] }), showVoteUI && currentPost &&
235
+ _jsx("div", { style: {
236
+ height: "70px",
237
+ borderTop: "2px solid black",
238
+ display: "flex",
239
+ flexDirection: "column",
240
+ alignItems: "center",
241
+ justifyContent: "center"
242
+ }, children: _jsxs("div", { style: {
243
+ display: "flex",
244
+ flexDirection: "row",
245
+ alignItems: "center",
246
+ gap: "20px"
247
+ }, children: [_jsx("div", { title: "Upvote this feature", style: {
248
+ cursor: "pointer"
249
+ }, onClick: () => VoteFor(currentPost._id, true), children: _jsx(CircleArrowUp, { color: "#52f052", size: 30 }) }), _jsx("div", { title: "Downvote this feature", style: {
250
+ cursor: "pointer"
251
+ }, onClick: () => VoteFor(currentPost._id, false), children: _jsx(CircleArrowDown, { color: "red", size: 30 }) })] }) })] }), showController && _jsxs("div", { style: {
252
+ border: "2px solid black",
253
+ borderWidth: "1px",
254
+ borderRadius: "30px",
255
+ width: "240px",
256
+ height: "40px",
257
+ zIndex: 100000000000000,
258
+ padding: "10px",
259
+ display: "flex",
260
+ flexDirection: "row",
261
+ backgroundColor: "white",
262
+ position: "fixed",
263
+ gap: "10px",
264
+ top: "84%",
265
+ left: "77%"
266
+ }, children: [_jsxs("div", { style: {
267
+ display: "flex",
268
+ alignItems: "center",
269
+ gap: "10px",
270
+ flex: 0.8,
271
+ cursor: "pointer",
272
+ }, onClick: () => {
273
+ if (!currentUrl.trim() || !companyId)
274
+ return;
275
+ setShowController(false);
276
+ setShowFeedbackModalSkeleton(true);
277
+ // If the form is not visible, fetch then show it
278
+ getForm().then(() => {
279
+ setIsLoadingFeedbackModal(false);
280
+ setShowFeedbackModal(true);
281
+ });
282
+ }, children: [_jsx(MessageCircle, { size: 15 }), _jsx("b", { className: fontMap.poppins.className, style: {
283
+ fontSize: "10px"
284
+ }, children: "Feedback" })] }), _jsx("div", { style: {
285
+ width: "1px",
286
+ height: "100%",
287
+ backgroundColor: "black",
288
+ } }), _jsxs("div", { onClick: () => {
289
+ setShowController(false);
290
+ setShowBoardModalSkeleton(true);
291
+ getPosts().then(() => {
292
+ setShowBoardModalSkeleton(false);
293
+ setShowBoardModal(true);
294
+ });
295
+ }, style: {
296
+ display: "flex",
297
+ alignItems: "center",
298
+ gap: "10px",
299
+ flex: 1,
300
+ cursor: "pointer",
301
+ }, children: [_jsx(CircleArrowUp, { size: 15 }), _jsx("b", { className: fontMap.poppins.className, style: {
302
+ fontSize: "10px"
303
+ }, children: "Feature Vote" })] })] }), _jsx("div", { id: "rasp-launcher", onClick: () => {
304
+ setShowController(!showController);
305
+ setShowFeedbackModal(false);
306
+ setShowBoardModal(false);
149
307
  }, style: {
150
308
  backgroundColor: "white",
151
309
  padding: 15,
152
310
  borderWidth: 1,
153
311
  borderColor: "black",
154
312
  borderRadius: "100%",
313
+ width: "50px",
314
+ height: "50px",
155
315
  position: "fixed",
156
316
  zIndex: 1000000000000000,
157
317
  cursor: "pointer",
158
- top: launcherPosition ? launcherPosition.top : "90%",
318
+ top: launcherPosition ? launcherPosition.top : "89%",
159
319
  left: launcherPosition ? launcherPosition.left : "95%"
160
320
  }, children: _jsx(MessageSquare, { color: 'black', size: 20 }) })] }));
161
321
  };
@@ -1 +1 @@
1
- {"version":3,"file":"StaticFormComponent.d.ts","sourceRoot":"","sources":["../../../src/nextjs/components/StaticFormComponent.tsx"],"names":[],"mappings":"AAMA,iBAAS,mBAAmB,CAAC,EAAC,IAAI,EAAE,SAAS,EAAE,MAAM,EAAC,EAAC;IAAG,IAAI,EAAE,GAAG,CAAC;IAClE,SAAS,EAAE,GAAG,CAAC;IACf,MAAM,EAAE,GAAG,EAAE,CAAC;CAAC,2CAoMhB;AAED,eAAe,mBAAmB,CAAA"}
1
+ {"version":3,"file":"StaticFormComponent.d.ts","sourceRoot":"","sources":["../../../src/nextjs/components/StaticFormComponent.tsx"],"names":[],"mappings":"AAMA,iBAAS,mBAAmB,CAAC,EAAC,IAAI,EAAE,SAAS,EAAE,MAAM,EAAC,EAAC;IAAG,IAAI,EAAE,GAAG,CAAC;IAClE,SAAS,EAAE,GAAG,CAAC;IACf,MAAM,EAAE,GAAG,EAAE,CAAC;CAAC,2CA2MhB;AAED,eAAe,mBAAmB,CAAA"}
@@ -4,6 +4,7 @@ import { iconMap } from '../constants/iconexp';
4
4
  import { fontMap } from '../constants/fontexp';
5
5
  import { addFeedback } from '../functions/functionsexp';
6
6
  function StaticFormComponent({ form, mainTheme, fields }) {
7
+ const [disabled, setDisabled] = useState(false);
7
8
  useEffect(() => {
8
9
  if (typeof window === 'undefined')
9
10
  return;
@@ -32,18 +33,25 @@ function StaticFormComponent({ form, mainTheme, fields }) {
32
33
  const handleSubmit = async (e) => {
33
34
  e.preventDefault();
34
35
  try {
35
- await addFeedback(form.companyId, form.formId, responses);
36
- // Clear fields
37
- setResponses(form.fieldsResponseObj.map((field) => ({
38
- ...field,
39
- response: ""
40
- })));
41
- // Show success UI
42
- setSubmitted(true);
36
+ if (form.companyId && form.formId && responses) {
37
+ setDisabled(true);
38
+ // Debug: log the actual field structure
39
+ //console.log('Fields structure:', props.fields);
40
+ //console.log('Responses:', responses.value);
41
+ // Transform responses to match the expected schema
42
+ const formattedResponses = responses.map((field, index) => ({
43
+ name: field.name || field.placeholder || `field_${index}`, // Fallback if name doesn't exist
44
+ response: field.response || ""
45
+ }));
46
+ //console.log('Formatted responses:', formattedResponses);
47
+ await addFeedback(form.companyId, form.formId, formattedResponses);
48
+ setSubmitted(true);
49
+ }
43
50
  }
44
51
  catch (error) {
45
52
  console.error('Error submitting feedback:', error);
46
53
  alert('Failed to submit feedback. Please try again.');
54
+ setDisabled(false); // Re-enable button on error
47
55
  }
48
56
  };
49
57
  return (_jsx(_Fragment, { children: mainTheme && mainTheme.data && _jsx("div", { style: {
@@ -53,7 +61,7 @@ function StaticFormComponent({ form, mainTheme, fields }) {
53
61
  backgroundColor: mainTheme.data.background,
54
62
  margin: '1.25rem',
55
63
  width: '470px',
56
- minHeight: '400px',
64
+ height: 'auto',
57
65
  border: '1px solid black',
58
66
  padding: '1rem',
59
67
  boxShadow: '0 1px 3px 0 rgba(0, 0, 0, 1), 0 1px 2px 0 rgba(0, 0, 0, 0.06)'
@@ -74,7 +82,7 @@ function StaticFormComponent({ form, mainTheme, fields }) {
74
82
  return (_jsx("div", { style: { display: "flex", gap: "10px", marginTop: "10px" }, children: [1, 2, 3, 4, 5].map((num) => (_jsx("div", { style: { cursor: "pointer" }, onClick: () => updateResponse(index, String(num)), children: currentRating >= num ? iconMap.starActive : iconMap.starUnactive }, num))) }, index));
75
83
  }
76
84
  if (field._type === 'textarea') {
77
- return (_jsx("textarea", { required: true, className: fontMap.wixmadefor.className, value: responses[index]?.response || "", placeholder: field.placeholder, onChange: (e) => updateResponse(index, e.target.value), style: {
85
+ return (_jsx("textarea", { required: true, className: `${fontMap.wixmadefor.className} rasp-input`, value: responses[index]?.response || "", placeholder: field.placeholder, onChange: (e) => updateResponse(index, e.target.value), style: {
78
86
  height: '7.5rem',
79
87
  marginTop: '5px',
80
88
  borderWidth: 1,
@@ -95,6 +103,6 @@ function StaticFormComponent({ form, mainTheme, fields }) {
95
103
  fontSize: "13px",
96
104
  cursor: "pointer",
97
105
  border: "none"
98
- }, children: "Send Feedback" })] }), submitted && _jsxs("div", { id: successContainerId, style: { display: "flex", flexDirection: 'column', alignItems: 'center', width: '100%' }, children: [_jsx("br", {}), _jsx("br", {}), _jsx("br", {}), form.success_icon && iconMap[form.success_icon] ? iconMap[form.success_icon] : iconMap.circleCheckBig, _jsx("h2", { className: fontMap[form.success_heading_font].className, style: { marginTop: '1rem', fontSize: form.design.title.size + "px", color: mainTheme.data.text.title }, children: form.success_heading }), _jsx("p", { className: fontMap[form.success_message_font].className, style: { marginTop: '1rem', fontSize: '0.875rem', textAlign: 'center', color: mainTheme.data.text.subtitle }, children: form.success_message })] })] }) }) }));
106
+ }, children: "Send Feedback" })] }), submitted && _jsxs("div", { id: successContainerId, style: { display: "flex", flexDirection: 'column', alignItems: 'center', width: '100%' }, children: [_jsx("br", {}), form.success_icon && iconMap[form.success_icon] ? iconMap[form.success_icon] : iconMap.circleCheckBig, _jsx("h2", { className: fontMap[form.success_heading_font].className, style: { marginTop: '1rem', fontSize: form.design.title.size + "px", color: mainTheme.data.text.title }, children: form.success_heading }), _jsx("p", { className: fontMap[form.success_message_font].className, style: { marginTop: '1rem', fontSize: '0.875rem', textAlign: 'center', color: mainTheme.data.text.subtitle }, children: form.success_message })] })] }) }) }));
99
107
  }
100
108
  export default StaticFormComponent;
@@ -2,4 +2,7 @@ export declare function addFeedback(companyId: string, formId: string, fieldsRes
2
2
  export declare function getFormByDomainOrCompany(companyId: string, domainUrl: string): Promise<any>;
3
3
  export declare function getBrandTheme(companyId: string): Promise<any>;
4
4
  export declare function getFormTheme(formId: string): Promise<any>;
5
+ export declare function getBoardPosts(companyId: string): Promise<any>;
6
+ export declare function upvoteBoardPost(postId: string): Promise<any>;
7
+ export declare function downvoteBoardPost(postId: string): Promise<any>;
5
8
  //# sourceMappingURL=functionsexp.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"functionsexp.d.ts","sourceRoot":"","sources":["../../../src/nextjs/functions/functionsexp.ts"],"names":[],"mappings":"AAAA,wBAAsB,WAAW,CAC/B,SAAS,EAAC,MAAM,EAChB,MAAM,EAAC,MAAM,EACb,iBAAiB,EAAC,GAAG,gBAqCtB;AAED,wBAAsB,wBAAwB,CAC5C,SAAS,EAAC,MAAM,EAChB,SAAS,EAAC,MAAM,gBAqCjB;AAED,wBAAsB,aAAa,CAAC,SAAS,EAAC,MAAM,gBAqBnD;AAED,wBAAsB,YAAY,CAAC,MAAM,EAAC,MAAM,gBAuB/C"}
1
+ {"version":3,"file":"functionsexp.d.ts","sourceRoot":"","sources":["../../../src/nextjs/functions/functionsexp.ts"],"names":[],"mappings":"AAAA,wBAAsB,WAAW,CAC/B,SAAS,EAAC,MAAM,EAChB,MAAM,EAAC,MAAM,EACb,iBAAiB,EAAC,GAAG,gBAqCtB;AAED,wBAAsB,wBAAwB,CAC5C,SAAS,EAAC,MAAM,EAChB,SAAS,EAAC,MAAM,gBAqCjB;AAED,wBAAsB,aAAa,CAAC,SAAS,EAAC,MAAM,gBAqBnD;AAED,wBAAsB,YAAY,CAAC,MAAM,EAAC,MAAM,gBAuB/C;AAGD,wBAAsB,aAAa,CAAC,SAAS,EAAE,MAAM,gBAwCpD;AAGD,wBAAsB,eAAe,CAAC,MAAM,EAAE,MAAM,gBAqBnD;AAGD,wBAAsB,iBAAiB,CAAC,MAAM,EAAE,MAAM,gBAqBrD"}