rasp-feedback 1.0.1 → 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.
Files changed (29) hide show
  1. package/dist/nextjs/components/MainViewHandler.d.ts +10 -0
  2. package/dist/nextjs/components/MainViewHandler.d.ts.map +1 -0
  3. package/dist/nextjs/components/MainViewHandler.js +17 -0
  4. package/dist/nextjs/components/PostItem.d.ts +7 -0
  5. package/dist/nextjs/components/PostItem.d.ts.map +1 -0
  6. package/dist/nextjs/components/PostItem.js +34 -0
  7. package/dist/nextjs/components/Posttem.d.ts +7 -0
  8. package/dist/nextjs/components/Posttem.d.ts.map +1 -0
  9. package/dist/nextjs/components/Posttem.js +14 -0
  10. package/dist/nextjs/components/RaspForm.d.ts.map +1 -1
  11. package/dist/nextjs/components/RaspForm.js +11 -0
  12. package/dist/nextjs/components/RaspProvider.d.ts.map +1 -1
  13. package/dist/nextjs/components/RaspProvider.js +220 -49
  14. package/dist/nextjs/components/StaticFormComponent.d.ts.map +1 -1
  15. package/dist/nextjs/components/StaticFormComponent.js +31 -12
  16. package/dist/nextjs/functions/functionsexp.d.ts +3 -0
  17. package/dist/nextjs/functions/functionsexp.d.ts.map +1 -1
  18. package/dist/nextjs/functions/functionsexp.js +71 -0
  19. package/dist/vue/components/PostItem.vue.d.ts +20 -0
  20. package/dist/vue/components/PostItem.vue.d.ts.map +1 -0
  21. package/dist/vue/components/RaspProvider.vue.d.ts.map +1 -1
  22. package/dist/vue/components/StaticFormComponent.vue.d.ts.map +1 -1
  23. package/dist/vue/functions/functionsexp.d.ts +3 -0
  24. package/dist/vue/functions/functionsexp.d.ts.map +1 -1
  25. package/dist/vue/index.js +692 -299
  26. package/dist/vue/index.umd.cjs +1 -1
  27. package/package.json +97 -73
  28. package/dist/nextjs/images/rasp_logo.png +0 -0
  29. package/dist/vue/images/rasp_logo.png +0 -0
@@ -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":"RaspForm.d.ts","sourceRoot":"","sources":["../../../src/nextjs/components/RaspForm.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAS3C,UAAU,KAAK;IACb,WAAW,CAAC,EAAE,aAAa,CAAC;CAC7B;AAED,wBAAgB,QAAQ,CAAC,EAAE,WAAW,EAAE,EAAE,KAAK,2CAwJ9C"}
1
+ {"version":3,"file":"RaspForm.d.ts","sourceRoot":"","sources":["../../../src/nextjs/components/RaspForm.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAS3C,UAAU,KAAK;IACb,WAAW,CAAC,EAAE,aAAa,CAAC;CAC7B;AAED,wBAAgB,QAAQ,CAAC,EAAE,WAAW,EAAE,EAAE,KAAK,2CAmK9C"}
@@ -29,6 +29,17 @@ export function RaspForm({ otherStyles }) {
29
29
  setCurrentUrl(window.location.href);
30
30
  }
31
31
  }, []);
32
+ useEffect(() => {
33
+ if (typeof window === 'undefined')
34
+ return;
35
+ if (!document.getElementById('rasp-google-fonts')) {
36
+ const link = document.createElement('link');
37
+ link.id = 'rasp-google-fonts';
38
+ link.rel = 'stylesheet';
39
+ 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';
40
+ document.head.appendChild(link);
41
+ }
42
+ }, []);
32
43
  useEffect(() => {
33
44
  if (companyId) {
34
45
  if (form) {
@@ -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,CA2MpD,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,33 +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);
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);
21
30
  const getForm = async () => {
22
- setIsLoading(true);
31
+ setIsLoadingFeedbackModal(true);
23
32
  const f = await getFormByDomainOrCompany(companyId, currentUrl);
24
33
  if (!f) {
25
34
  setForm(f);
26
- setIsLoading(false);
35
+ setIsLoadingFeedbackModal(false);
27
36
  return;
28
37
  }
29
38
  setForm(f[0]);
30
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
+ };
31
49
  useEffect(() => {
32
50
  if (typeof window !== 'undefined') {
33
51
  setCompanyId(process.env.NEXT_PUBLIC_RASP_COMPANY_ID);
@@ -41,20 +59,63 @@ export const RaspProvider = ({ children, launcherPosition }) => {
41
59
  if (form.usebrandtheme === true) {
42
60
  getBrandTheme(companyId).then((brandTheme) => {
43
61
  setMainTheme(brandTheme);
62
+ setShowFeedbackModalSkeleton(false);
44
63
  });
45
64
  }
46
65
  if (form.usebrandtheme === false) {
47
66
  getFormTheme(form.formId).then((formTheme) => {
48
67
  setMainTheme(formTheme);
68
+ setShowFeedbackModalSkeleton(false);
49
69
  });
50
70
  }
51
71
  }
52
72
  }
53
73
  }, [form]);
54
- 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: {
55
116
  position: "fixed",
56
- top: "15%",
57
- left: "60%",
117
+ bottom: "8%",
118
+ right: "3%",
58
119
  zIndex: 1000000000000000,
59
120
  padding: 0,
60
121
  margin: 0,
@@ -65,10 +126,10 @@ export const RaspProvider = ({ children, launcherPosition }) => {
65
126
  display: "inline-block",
66
127
  transform: "translate(-50%, -25%)",
67
128
  overflow: "visible"
68
- }, 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: {
69
130
  position: "fixed",
70
- top: "19%",
71
- left: "60%",
131
+ bottom: "8%",
132
+ right: "3%",
72
133
  zIndex: 1000000000000000,
73
134
  display: 'flex',
74
135
  flexDirection: 'column',
@@ -77,19 +138,18 @@ export const RaspProvider = ({ children, launcherPosition }) => {
77
138
  backgroundColor: 'white',
78
139
  margin: '1.25rem',
79
140
  width: '470px',
80
- minHeight: '400px',
141
+ minHeight: '300px',
81
142
  border: '1px solid black',
82
143
  padding: '1rem',
83
144
  boxShadow: '0 1px 3px 0 rgba(0, 0, 0, 1), 0 1px 2px 0 rgba(0, 0, 0, 0.06)'
84
- }, 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 &&
85
146
  _jsx("div", { id: "rasp-form-div", style: {
86
147
  position: "fixed",
87
- top: "18%",
88
- left: "60%",
148
+ bottom: "8%",
149
+ right: "3%",
89
150
  zIndex: 1000000000000000,
90
151
  padding: 0,
91
152
  margin: 0,
92
- border: 0,
93
153
  background: "transparent",
94
154
  width: "auto",
95
155
  height: "auto",
@@ -100,51 +160,162 @@ export const RaspProvider = ({ children, launcherPosition }) => {
100
160
  display: 'flex',
101
161
  flexDirection: "column",
102
162
  justifyContent: 'center',
103
- borderRadius: '0.75rem',
104
163
  backgroundColor: "white",
105
164
  margin: '1.25rem',
106
165
  width: '470px',
107
- minHeight: '400px',
108
- border: '1px solid whitesmoke',
166
+ height: 'auto',
167
+ border: "2px solid black",
168
+ borderRadius: "20px",
109
169
  padding: '2rem',
110
170
  paddingTop: "0px"
111
- }, 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: () => {
112
- if (!currentUrl.trim() || !companyId)
113
- return;
114
- // If the form is visible, play exit animation then hide
115
- if (showForm) {
116
- const el = document.getElementById('rasp-form-div');
117
- if (el) {
118
- el.classList.add('rasp-exit');
119
- // match animation duration (250ms) + small buffer
120
- setTimeout(() => {
121
- setShowForm(false);
122
- el.classList.remove('rasp-exit');
123
- }, 300);
124
- return;
125
- }
126
- // fallback: just hide
127
- setShowForm(false);
128
- return;
129
- }
130
- setIsLoading(true);
131
- setShowFormSkeleton(true);
132
- // If the form is not visible, fetch then show it
133
- getForm().then(() => {
134
- setShowForm(true);
135
- setIsLoading(false);
136
- setShowFormSkeleton(false);
137
- });
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);
138
307
  }, style: {
139
308
  backgroundColor: "white",
140
309
  padding: 15,
141
310
  borderWidth: 1,
142
311
  borderColor: "black",
143
312
  borderRadius: "100%",
313
+ width: "50px",
314
+ height: "50px",
144
315
  position: "fixed",
145
316
  zIndex: 1000000000000000,
146
317
  cursor: "pointer",
147
- top: launcherPosition ? launcherPosition.top : "90%",
318
+ top: launcherPosition ? launcherPosition.top : "89%",
148
319
  left: launcherPosition ? launcherPosition.left : "95%"
149
320
  }, children: _jsx(MessageSquare, { color: 'black', size: 20 }) })] }));
150
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,2CA0LhB;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"}
@@ -1,9 +1,21 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
- import { useState } from 'react';
2
+ import { useEffect, useState } from 'react';
3
3
  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);
8
+ useEffect(() => {
9
+ if (typeof window === 'undefined')
10
+ return;
11
+ if (!document.getElementById('rasp-google-fonts')) {
12
+ const link = document.createElement('link');
13
+ link.id = 'rasp-google-fonts';
14
+ link.rel = 'stylesheet';
15
+ 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';
16
+ document.head.appendChild(link);
17
+ }
18
+ }, []);
7
19
  const [responses, setResponses] = useState(() => form.fieldsResponseObj.map((field) => ({
8
20
  ...field,
9
21
  response: ""
@@ -21,18 +33,25 @@ function StaticFormComponent({ form, mainTheme, fields }) {
21
33
  const handleSubmit = async (e) => {
22
34
  e.preventDefault();
23
35
  try {
24
- await addFeedback(form.companyId, form.formId, responses);
25
- // Clear fields
26
- setResponses(form.fieldsResponseObj.map((field) => ({
27
- ...field,
28
- response: ""
29
- })));
30
- // Show success UI
31
- 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
+ }
32
50
  }
33
51
  catch (error) {
34
52
  console.error('Error submitting feedback:', error);
35
53
  alert('Failed to submit feedback. Please try again.');
54
+ setDisabled(false); // Re-enable button on error
36
55
  }
37
56
  };
38
57
  return (_jsx(_Fragment, { children: mainTheme && mainTheme.data && _jsx("div", { style: {
@@ -42,7 +61,7 @@ function StaticFormComponent({ form, mainTheme, fields }) {
42
61
  backgroundColor: mainTheme.data.background,
43
62
  margin: '1.25rem',
44
63
  width: '470px',
45
- minHeight: '400px',
64
+ height: 'auto',
46
65
  border: '1px solid black',
47
66
  padding: '1rem',
48
67
  boxShadow: '0 1px 3px 0 rgba(0, 0, 0, 1), 0 1px 2px 0 rgba(0, 0, 0, 0.06)'
@@ -63,7 +82,7 @@ function StaticFormComponent({ form, mainTheme, fields }) {
63
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));
64
83
  }
65
84
  if (field._type === 'textarea') {
66
- 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: {
67
86
  height: '7.5rem',
68
87
  marginTop: '5px',
69
88
  borderWidth: 1,
@@ -84,6 +103,6 @@ function StaticFormComponent({ form, mainTheme, fields }) {
84
103
  fontSize: "13px",
85
104
  cursor: "pointer",
86
105
  border: "none"
87
- }, 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 })] })] }) }) }));
88
107
  }
89
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"}