@shiva004/surveys 0.1.3 → 0.1.6

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 (37) hide show
  1. package/README.md +38 -38
  2. package/dist/assets/index-BPe2owrS.js +40 -0
  3. package/dist/assets/index-Chkvn1aI.css +1 -0
  4. package/dist/index.html +13 -0
  5. package/package.json +13 -36
  6. package/LICENSE +0 -9
  7. package/src/Pages/Allsurvey/Allsurvey.tsx +0 -157
  8. package/src/Pages/Allsurvey/SurveyGridCard.tsx +0 -125
  9. package/src/Pages/Allsurvey/index.ts +0 -1
  10. package/src/Pages/Allsurvey/surveysTable.config.ts +0 -15
  11. package/src/Pages/Createsurvey/Createsurvey.tsx +0 -318
  12. package/src/Pages/Createsurvey/index.ts +0 -1
  13. package/src/Pages/NPStracker/NPStracker.tsx +0 -78
  14. package/src/Pages/NPStracker/index.ts +0 -1
  15. package/src/Pages/Responses/Responses.tsx +0 -61
  16. package/src/Pages/Responses/index.ts +0 -1
  17. package/src/Pages/Responses/responsesTable.config.ts +0 -74
  18. package/src/Pages/Surveyanalytics/Surveyanalytics.tsx +0 -154
  19. package/src/Pages/Surveyanalytics/analyticsTable.config.ts +0 -123
  20. package/src/Pages/Surveyanalytics/index.ts +0 -1
  21. package/src/Pages/Surveydetails/Surveydetails.tsx +0 -202
  22. package/src/Pages/Surveydetails/index.ts +0 -1
  23. package/src/Pages/Surveytemplates/Surveytemplates.tsx +0 -299
  24. package/src/Pages/Surveytemplates/index.ts +0 -1
  25. package/src/Pages/surveyPage.module.scss +0 -49
  26. package/src/cells/SurveyCells.tsx +0 -370
  27. package/src/hooks/useSurveyResponses.ts +0 -37
  28. package/src/hooks/useTableConfig.ts +0 -77
  29. package/src/hooks/useTableData.ts +0 -184
  30. package/src/index.ts +0 -24
  31. package/src/nav.ts +0 -55
  32. package/src/routes.ts +0 -98
  33. package/src/services/api/TableConfigDto.ts +0 -36
  34. package/src/services/api/TableQueryParams.ts +0 -10
  35. package/src/services/api/surveys.api.ts +0 -144
  36. package/src/services/api/types.ts +0 -113
  37. package/src/types/survey.types.ts +0 -175
@@ -1,299 +0,0 @@
1
- // src/features/surveys/pages/SurveyTemplates.tsx
2
- import { Header } from '@/shared/components/layout/Header';
3
- import { Icon } from '@/shared/components/ui/Icon/Icon';
4
- import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
5
- import React, { useState } from 'react';
6
- import { useNavigate } from 'react-router-dom';
7
- import { surveysApi } from '../../services/api/surveys.api';
8
- import type { SurveyTemplateItem } from '../../types/survey.types';
9
- import styles from '../surveyPage.module.scss';
10
- import { Card } from '@/modules/queue/components/ui';
11
-
12
- /* ─── constants ─── */
13
- const CATEGORY_STYLES: Record<string, string> = {
14
- Product: 'bg-[#7c3aed]/10 text-[color:var(--th-accent-soft)]',
15
- Loyalty: 'bg-[color:color-mix(in_srgb,var(--th-success)_10%,transparent)] text-[color:var(--th-success)]',
16
- UX: 'bg-[color:color-mix(in_srgb,var(--th-info-soft)_10%,transparent)] text-[color:var(--th-info-soft)]',
17
- Retention: 'bg-[color:color-mix(in_srgb,var(--th-warning-soft)_10%,transparent)] text-[color:var(--th-warning-soft)]',
18
- Revenue: 'bg-[color:color-mix(in_srgb,var(--th-danger-soft)_10%,transparent)] text-[color:var(--th-danger-soft)]',
19
- };
20
-
21
- /* ─── use-template modal ─── */
22
- interface UseTemplateModalProps {
23
- template: SurveyTemplateItem;
24
- onClose: () => void;
25
- }
26
-
27
- const UseTemplateModal = ({ template, onClose }: UseTemplateModalProps) => {
28
- const navigate = useNavigate();
29
- const queryClient = useQueryClient();
30
- const [name, setName] = useState(template.name);
31
- const [target, setTarget] = useState(500);
32
-
33
- const mutation = useMutation({
34
- mutationFn: () =>
35
- surveysApi.useTemplate(template.id, { name, targetResponses: target }),
36
- onSuccess: () => {
37
- queryClient.invalidateQueries({ queryKey: ['surveys'] });
38
- onClose();
39
- navigate('/analytics/surveys');
40
- },
41
- });
42
-
43
- const handleBackdrop = (e: React.MouseEvent<HTMLDivElement>) => {
44
- if (e.target === e.currentTarget) onClose();
45
- };
46
-
47
- return (
48
- <div
49
- className="fixed inset-0 z-50 flex items-center justify-center"
50
- onClick={handleBackdrop}
51
- >
52
- <div className="absolute inset-0 bg-black/60 backdrop-blur-sm" />
53
-
54
- <Card className="relative p-8 w-full max-w-md mx-4 shadow-2xl">
55
- <button
56
- onClick={onClose}
57
- className="absolute top-4 right-4 p-1.5 rounded-lg hover:bg-[color:color-mix(in_srgb,var(--th-ov-base)_5%,transparent)]
58
- text-[color:var(--th-text-3)] hover:text-[color:var(--th-text-1)] transition-colors"
59
- >
60
- <Icon icon="X" size={16} />
61
- </button>
62
-
63
- <div className="flex items-center gap-3 mb-6">
64
- <div className="w-10 h-10 rounded-xl bg-[#7c3aed]/20 flex items-center justify-center">
65
- <Icon icon="ClipboardCopy" size={18} className="text-[color:var(--th-accent-soft)]" />
66
- </div>
67
- <div>
68
- <h2 className="text-[16px] font-semibold text-white">
69
- Use Template
70
- </h2>
71
- <p className="text-[12px] text-[color:var(--th-text-3)]">{template.name}</p>
72
- </div>
73
- </div>
74
-
75
- <div className="space-y-4">
76
- <div>
77
- <label className="block text-[12px] text-[color:var(--th-text-3)] mb-1.5">
78
- Survey Name
79
- </label>
80
- <input
81
- value={name}
82
- onChange={(e) => setName(e.target.value)}
83
- placeholder="My survey"
84
- className="w-full px-3.5 py-2.5 rounded-lg bg-[color:color-mix(in_srgb,var(--th-ov-base)_5%,transparent)] border border-[color:color-mix(in_srgb,var(--th-ov-base)_8%,transparent)]
85
- text-[13px] text-[color:var(--th-text-1)] placeholder:text-[color:color-mix(in_srgb,var(--th-text-3)_60%,transparent)]
86
- focus:border-[#7c3aed] outline-none transition-colors"
87
- />
88
- </div>
89
- <div>
90
- <label className="block text-[12px] text-[color:var(--th-text-3)] mb-1.5">
91
- Target Responses
92
- </label>
93
- <input
94
- type="number"
95
- value={target}
96
- onChange={(e) => setTarget(parseInt(e.target.value) || 500)}
97
- className="w-full px-3.5 py-2.5 rounded-lg bg-[color:color-mix(in_srgb,var(--th-ov-base)_5%,transparent)] border border-[color:color-mix(in_srgb,var(--th-ov-base)_8%,transparent)]
98
- text-[13px] text-[color:var(--th-text-1)]
99
- focus:border-[#7c3aed] outline-none transition-colors"
100
- />
101
- </div>
102
- </div>
103
-
104
- <div className="flex gap-3 mt-6">
105
- <button
106
- onClick={onClose}
107
- className="flex-1 py-2.5 rounded-lg bg-[color:color-mix(in_srgb,var(--th-ov-base)_5%,transparent)] hover:bg-[color:color-mix(in_srgb,var(--th-ov-base)_10%,transparent)]
108
- text-[color:var(--th-text-3)] text-[13px] font-medium transition-colors"
109
- >
110
- Cancel
111
- </button>
112
- <button
113
- onClick={() => mutation.mutate()}
114
- disabled={!name.trim() || mutation.isPending}
115
- className="flex-1 py-2.5 rounded-lg bg-[#7c3aed] hover:bg-[#8b4df0]
116
- disabled:opacity-40 text-white text-[13px] font-medium
117
- transition-colors flex items-center justify-center gap-2"
118
- >
119
- {mutation.isPending && (
120
- <Icon icon="Loader2" size={14} className="animate-spin" />
121
- )}
122
- {mutation.isPending ? 'Creating…' : 'Create Survey'}
123
- </button>
124
- </div>
125
- </Card>
126
- </div>
127
- );
128
- };
129
-
130
- /* ─── template card ─── */
131
- const TemplateCard = ({
132
- t,
133
- onUse,
134
- }: {
135
- t: SurveyTemplateItem;
136
- onUse: (t: SurveyTemplateItem) => void;
137
- }) => (
138
- <Card className="p-5 hover:border-[#7c3aed]/30 transition-all group">
139
- <div className="flex items-start justify-between mb-3">
140
- <div className="flex-1 min-w-0 pr-3">
141
- <h3 className="text-[14px] font-semibold text-white group-hover:text-[color:var(--th-accent-soft)] transition-colors">
142
- {t.name}
143
- </h3>
144
- <p className="text-[12px] text-[color:var(--th-text-3)] mt-1 leading-relaxed">
145
- {t.description}
146
- </p>
147
- </div>
148
- {t.isSystem && (
149
- <span
150
- className="shrink-0 text-[9px] px-1.5 py-0.5 rounded
151
- bg-[#7c3aed]/20 text-[color:var(--th-accent-soft)] font-medium"
152
- >
153
- OFFICIAL
154
- </span>
155
- )}
156
- </div>
157
-
158
- <div className="flex items-center gap-3 mb-5 text-[11px] text-[color:var(--th-text-3)]">
159
- <span className="flex items-center gap-1">
160
- <Icon icon="FileText" size={11} />
161
- {t.questionCount ?? 0} questions
162
- </span>
163
- {t.category && (
164
- <span
165
- className={`px-2 py-0.5 rounded text-[10px] font-medium ${CATEGORY_STYLES[t.category] ?? 'bg-[color:color-mix(in_srgb,var(--th-ov-base)_5%,transparent)] text-[color:var(--th-text-3)]'
166
- }`}
167
- >
168
- {t.category}
169
- </span>
170
- )}
171
- </div>
172
-
173
- <button
174
- onClick={() => onUse(t)}
175
- className="flex items-center gap-2 px-4 py-2 rounded-lg
176
- bg-[#7c3aed] hover:bg-[#8b4df0]
177
- text-white text-[12px] font-medium transition-colors"
178
- >
179
- <Icon icon="ClipboardCopy" size={12} />
180
- Use Template
181
- </button>
182
- </Card>
183
- );
184
-
185
- /* ─── skeleton ─── */
186
- const Skeleton = () => (
187
- <div className={styles.cards}>
188
- {Array.from({ length: 6 }).map((_, i) => (
189
- <Card key={i} className="p-5 animate-pulse h-44">{null}</Card>
190
- ))}
191
- </div>
192
- );
193
-
194
- /* ─── page ─── */
195
- /** Renders the survey templates component. */
196
- export const SurveyTemplates = () => {
197
- const [activeCategory, setActiveCategory] = useState<string | null>(null);
198
- const [selected, setSelected] = useState<SurveyTemplateItem | null>(null);
199
-
200
- const {
201
- data: templates,
202
- isLoading,
203
- isError,
204
- refetch,
205
- } = useQuery({
206
- queryKey: ['survey-templates'],
207
- queryFn: surveysApi.getTemplates,
208
- staleTime: 5 * 60 * 1000,
209
- });
210
-
211
- /* ── bulletproof list extraction ── */
212
- const list: SurveyTemplateItem[] = Array.isArray(templates)
213
- ? templates.filter((t): t is SurveyTemplateItem => Boolean(t?.id))
214
- : [];
215
-
216
- const categories = [
217
- ...new Set(list.map((t) => t.category).filter(Boolean) as string[]),
218
- ];
219
-
220
- const filtered = activeCategory
221
- ? list.filter((t) => t.category === activeCategory)
222
- : list;
223
-
224
- return (
225
- <div className={styles.wrapper}>
226
- <Header
227
- title="Survey Templates"
228
- subtitle="Analytics · pre-built templates to get started quickly"
229
- />
230
-
231
- {/* category tabs */}
232
- <div className="flex flex-wrap gap-2">
233
- {['All', ...categories].map((cat) => {
234
- const isActive =
235
- cat === 'All' ? !activeCategory : activeCategory === cat;
236
- return (
237
- <button
238
- key={cat}
239
- onClick={() => setActiveCategory(cat === 'All' ? null : cat)}
240
- className={`px-3.5 py-1.5 rounded-lg text-[12px] font-medium transition-colors ${isActive
241
- ? 'bg-[#7c3aed] text-white'
242
- : 'bg-[color:color-mix(in_srgb,var(--th-ov-base)_5%,transparent)] text-[color:var(--th-text-3)] hover:text-[color:var(--th-text-1)] hover:bg-[color:color-mix(in_srgb,var(--th-ov-base)_10%,transparent)]'
243
- }`}
244
- >
245
- {cat}
246
- </button>
247
- );
248
- })}
249
- </div>
250
-
251
- {/* content */}
252
- {isLoading ? (
253
- <Skeleton />
254
- ) : isError ? (
255
- <Card className="p-20 text-center space-y-3">
256
- <Icon
257
- icon="AlertTriangle"
258
- size={40}
259
- className="text-[color:var(--th-danger-soft)] mx-auto"
260
- />
261
- <p className="text-[15px] text-[color:var(--th-text-3)]">Failed to load templates</p>
262
- <button
263
- onClick={() => refetch()}
264
- className="text-[13px] text-[#7c3aed] hover:text-[#8b4df0] underline"
265
- >
266
- Retry
267
- </button>
268
- </Card>
269
- ) : filtered.length === 0 ? (
270
- <Card className="p-20 text-center">
271
- <Icon
272
- icon="FileText"
273
- size={40}
274
- className="text-[color:var(--th-text-3)] mx-auto mb-4"
275
- />
276
- <p className="text-[15px] text-[color:var(--th-text-3)]">
277
- {activeCategory
278
- ? 'No templates in this category'
279
- : 'No templates available yet'}
280
- </p>
281
- </Card>
282
- ) : (
283
- <div className={styles.cards}>
284
- {filtered.map((t) => (
285
- <TemplateCard key={t.id} t={t} onUse={setSelected} />
286
- ))}
287
- </div>
288
- )}
289
-
290
- {/* modal */}
291
- {selected && (
292
- <UseTemplateModal
293
- template={selected}
294
- onClose={() => setSelected(null)}
295
- />
296
- )}
297
- </div>
298
- );
299
- };
@@ -1 +0,0 @@
1
- export {SurveyTemplates} from'./Surveytemplates'
@@ -1,49 +0,0 @@
1
- /* Shared layout for all Survey pages. Mirrors queue/pages/queuePage.module.scss
2
- (.wrapper / .statsgrid) so Header + StatCard + DataTable line up the same way. */
3
- .wrapper {
4
- display: flex;
5
- flex-direction: column;
6
- gap: 16px;
7
- padding: 20px;
8
- min-width: 0;
9
- }
10
-
11
- .statsgrid {
12
- display: grid;
13
- gap: 16px;
14
- grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
15
- }
16
-
17
- /* card grids (templates, analytics) */
18
- .cards {
19
- display: grid;
20
- gap: 16px;
21
- grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
22
- }
23
-
24
- .stack {
25
- display: flex;
26
- flex-direction: column;
27
- gap: 16px;
28
- }
29
-
30
- /* table + optional detail drawer (row click) */
31
- .split {
32
- display: flex;
33
- align-items: flex-start;
34
- gap: 20px;
35
- }
36
- .main {
37
- flex: 1;
38
- min-width: 0;
39
- }
40
- .detail {
41
- display: none;
42
- width: 320px;
43
- flex-shrink: 0;
44
- align-self: flex-start;
45
-
46
- @media (min-width: 1280px) {
47
- display: block;
48
- }
49
- }