@shiva004/surveys 0.1.3 → 0.1.5
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.
- package/dist/index.cjs +109 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +403 -0
- package/dist/index.js +8716 -0
- package/dist/index.js.map +1 -0
- package/dist/style.css +1 -0
- package/package.json +33 -27
- package/src/Pages/Allsurvey/Allsurvey.tsx +0 -157
- package/src/Pages/Allsurvey/SurveyGridCard.tsx +0 -125
- package/src/Pages/Allsurvey/index.ts +0 -1
- package/src/Pages/Allsurvey/surveysTable.config.ts +0 -15
- package/src/Pages/Createsurvey/Createsurvey.tsx +0 -318
- package/src/Pages/Createsurvey/index.ts +0 -1
- package/src/Pages/NPStracker/NPStracker.tsx +0 -78
- package/src/Pages/NPStracker/index.ts +0 -1
- package/src/Pages/Responses/Responses.tsx +0 -61
- package/src/Pages/Responses/index.ts +0 -1
- package/src/Pages/Responses/responsesTable.config.ts +0 -74
- package/src/Pages/Surveyanalytics/Surveyanalytics.tsx +0 -154
- package/src/Pages/Surveyanalytics/analyticsTable.config.ts +0 -123
- package/src/Pages/Surveyanalytics/index.ts +0 -1
- package/src/Pages/Surveydetails/Surveydetails.tsx +0 -202
- package/src/Pages/Surveydetails/index.ts +0 -1
- package/src/Pages/Surveytemplates/Surveytemplates.tsx +0 -299
- package/src/Pages/Surveytemplates/index.ts +0 -1
- package/src/Pages/surveyPage.module.scss +0 -49
- package/src/cells/SurveyCells.tsx +0 -370
- package/src/hooks/useSurveyResponses.ts +0 -37
- package/src/hooks/useTableConfig.ts +0 -77
- package/src/hooks/useTableData.ts +0 -184
- package/src/index.ts +0 -24
- package/src/nav.ts +0 -55
- package/src/routes.ts +0 -98
- package/src/services/api/TableConfigDto.ts +0 -36
- package/src/services/api/TableQueryParams.ts +0 -10
- package/src/services/api/surveys.api.ts +0 -144
- package/src/services/api/types.ts +0 -113
- package/src/types/survey.types.ts +0 -175
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,403 @@
|
|
|
1
|
+
import { ComponentType } from 'react';
|
|
2
|
+
import { default as default_2 } from 'react';
|
|
3
|
+
import { Dispatch } from 'react';
|
|
4
|
+
import { InfiniteData } from '@tanstack/query-core';
|
|
5
|
+
import { LazyExoticComponent } from 'react';
|
|
6
|
+
import { NavigateOptions } from 'react-router-dom';
|
|
7
|
+
import { QueryObserverResult } from '@tanstack/query-core';
|
|
8
|
+
import { RefetchOptions } from '@tanstack/query-core';
|
|
9
|
+
import { SetStateAction } from 'react';
|
|
10
|
+
|
|
11
|
+
/** Renders the all surveys component. */
|
|
12
|
+
export declare const AllSurveys: default_2.FC;
|
|
13
|
+
|
|
14
|
+
/** Describes the api response. */
|
|
15
|
+
export declare interface ApiResponse<T> {
|
|
16
|
+
data: T;
|
|
17
|
+
success: boolean;
|
|
18
|
+
message?: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
declare interface CellRegistration {
|
|
22
|
+
type: string;
|
|
23
|
+
component: CellRenderer;
|
|
24
|
+
module?: string;
|
|
25
|
+
priority?: number;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
declare interface CellRenderContext<T extends RowData = RowData> {
|
|
29
|
+
value: unknown;
|
|
30
|
+
row: T;
|
|
31
|
+
column: ColumnDef<T>;
|
|
32
|
+
rowIndex: number;
|
|
33
|
+
currentPage: string;
|
|
34
|
+
extra: TableExtra<T>;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
declare type CellRenderer<T extends RowData = RowData> = ComponentType<CellRenderContext<T>>;
|
|
38
|
+
|
|
39
|
+
declare interface ColumnDef<T extends RowData = RowData> {
|
|
40
|
+
key: Extract<keyof T, string> | (string & {});
|
|
41
|
+
label: string;
|
|
42
|
+
cellType?: string | null;
|
|
43
|
+
align?: 'left' | 'center' | 'right';
|
|
44
|
+
width?: string | number;
|
|
45
|
+
minWidth?: string | number;
|
|
46
|
+
maxWidth?: string | number;
|
|
47
|
+
sortable?: boolean;
|
|
48
|
+
sortFn?(a: T, b: T, direction: SortDirection): number;
|
|
49
|
+
sticky?: boolean;
|
|
50
|
+
hidden?: boolean;
|
|
51
|
+
toggleable?: boolean;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** Renders the create survey component. */
|
|
55
|
+
export declare const CreateSurvey: default_2.FC;
|
|
56
|
+
|
|
57
|
+
/** Data transfer object for create survey. */
|
|
58
|
+
export declare interface CreateSurveyDto {
|
|
59
|
+
name: string;
|
|
60
|
+
description?: string;
|
|
61
|
+
targetResponses: number;
|
|
62
|
+
endsAt?: string;
|
|
63
|
+
questions: SurveyQuestionDto[];
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/** Type definition for create survey payload. */
|
|
67
|
+
export declare type CreateSurveyPayload = CreateSurveyDto;
|
|
68
|
+
|
|
69
|
+
declare interface NavItem {
|
|
70
|
+
id: string;
|
|
71
|
+
label: string;
|
|
72
|
+
icon: string;
|
|
73
|
+
module: string;
|
|
74
|
+
category: string;
|
|
75
|
+
section: string;
|
|
76
|
+
path: string;
|
|
77
|
+
order: number;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/** Describes the nps summary. */
|
|
81
|
+
export declare interface NpsSummary {
|
|
82
|
+
currentScore: number;
|
|
83
|
+
scoreDelta: number;
|
|
84
|
+
promotersPercent: number;
|
|
85
|
+
passivesPercent: number;
|
|
86
|
+
detractorsPercent: number;
|
|
87
|
+
totalResponses: number;
|
|
88
|
+
trend: NpsTrendPoint[];
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/** Renders the NPS tracker component. */
|
|
92
|
+
export declare const NPSTracker: default_2.FC;
|
|
93
|
+
|
|
94
|
+
/** Describes the nps trend point. */
|
|
95
|
+
export declare interface NpsTrendPoint {
|
|
96
|
+
period: string;
|
|
97
|
+
score: number;
|
|
98
|
+
responses: number;
|
|
99
|
+
promoters: number;
|
|
100
|
+
passives: number;
|
|
101
|
+
detractors: number;
|
|
102
|
+
trend: 'up' | 'down';
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/** Describes the paged response. */
|
|
106
|
+
export declare interface PagedResponse<T> {
|
|
107
|
+
items: T[];
|
|
108
|
+
totalCount: number;
|
|
109
|
+
page?: number;
|
|
110
|
+
pageSize: number;
|
|
111
|
+
hasMore: boolean;
|
|
112
|
+
nextCursor: string | null;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Registers the survey cells.
|
|
117
|
+
*
|
|
118
|
+
* @returns The `CellRegistration[]` result.
|
|
119
|
+
*/
|
|
120
|
+
export declare function registerSurveyCells(): CellRegistration[];
|
|
121
|
+
|
|
122
|
+
/** Renders the responses component. */
|
|
123
|
+
export declare const Responses: default_2.FC;
|
|
124
|
+
|
|
125
|
+
declare interface RouteConfig {
|
|
126
|
+
path: string;
|
|
127
|
+
element: LazyExoticComponent<ComponentType<any>>;
|
|
128
|
+
isPublic?: boolean;
|
|
129
|
+
meta?: {
|
|
130
|
+
title?: string;
|
|
131
|
+
module?: string;
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
declare interface RowData {
|
|
136
|
+
id: RowId;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
declare type RowId = string | number;
|
|
140
|
+
|
|
141
|
+
declare type SortDirection = 'asc' | 'desc';
|
|
142
|
+
|
|
143
|
+
/** Renders the survey analytics component. */
|
|
144
|
+
export declare const SurveyAnalytics: default_2.FC;
|
|
145
|
+
|
|
146
|
+
/** Describes the survey analytics item. */
|
|
147
|
+
export declare interface SurveyAnalyticsItem {
|
|
148
|
+
surveyId: string;
|
|
149
|
+
surveyName: string;
|
|
150
|
+
totalResponses: number;
|
|
151
|
+
completionRate: number;
|
|
152
|
+
avgCompletionTime: string;
|
|
153
|
+
npsScore?: number;
|
|
154
|
+
averageRating: number;
|
|
155
|
+
topTheme: string;
|
|
156
|
+
bottomTheme: string;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/** One row of the Survey Analytics table (DataTable rows need an `id`). */
|
|
160
|
+
export declare type SurveyAnalyticsRow = SurveyAnalyticsItem & {
|
|
161
|
+
id: string;
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
/** Renders the survey details component. */
|
|
165
|
+
export declare const SurveyDetails: default_2.FC;
|
|
166
|
+
|
|
167
|
+
/** Describes the survey list item. */
|
|
168
|
+
export declare interface SurveyListItem {
|
|
169
|
+
id: string;
|
|
170
|
+
name: string;
|
|
171
|
+
description: string | null;
|
|
172
|
+
status: SurveyStatus;
|
|
173
|
+
responses: number;
|
|
174
|
+
target: number;
|
|
175
|
+
createdAt: string;
|
|
176
|
+
endsAt: string | null;
|
|
177
|
+
npsScore: number | null;
|
|
178
|
+
questionCount: number;
|
|
179
|
+
createdByName: string;
|
|
180
|
+
updatedAt: string;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
export declare const surveyNav: NavItem[];
|
|
184
|
+
|
|
185
|
+
/** Data transfer object for survey question. */
|
|
186
|
+
export declare interface SurveyQuestionDto {
|
|
187
|
+
question: string;
|
|
188
|
+
type: 'nps' | 'rating' | 'multiple_choice' | 'open_text';
|
|
189
|
+
required: boolean;
|
|
190
|
+
options?: string[];
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/** Describes the survey response item. */
|
|
194
|
+
export declare interface SurveyResponseItem {
|
|
195
|
+
id: string;
|
|
196
|
+
surveyId: string;
|
|
197
|
+
surveyName: string;
|
|
198
|
+
userId: string;
|
|
199
|
+
npsScore?: number;
|
|
200
|
+
rating?: number;
|
|
201
|
+
responseText?: string;
|
|
202
|
+
createdAt: string;
|
|
203
|
+
npsCategory: 'promoter' | 'passive' | 'detractor';
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
export declare const surveyRoutes: RouteConfig[];
|
|
207
|
+
|
|
208
|
+
/** One row of the All-Surveys table. */
|
|
209
|
+
export declare type SurveyRow = SurveyListItem;
|
|
210
|
+
|
|
211
|
+
export declare const surveysApi: {
|
|
212
|
+
list: (params?: TableQueryParams | Record<string, unknown>) => Promise<PagedResponse<SurveyListItem>>;
|
|
213
|
+
getNps: (weeks?: number) => Promise<NpsSummary>;
|
|
214
|
+
getById: (id: string) => Promise<SurveyListItem | null>;
|
|
215
|
+
create: (body: CreateSurveyDto) => Promise<SurveyListItem>;
|
|
216
|
+
delete: (id: string) => Promise<void>;
|
|
217
|
+
getResponses: (params?: Record<string, unknown>) => Promise<PagedResponse<SurveyResponseItem>>;
|
|
218
|
+
getAnalytics: () => Promise<SurveyAnalyticsItem[]>;
|
|
219
|
+
getTemplates: () => Promise<SurveyTemplateItem[]>;
|
|
220
|
+
useTemplate: (templateId: string, body: {
|
|
221
|
+
name: string;
|
|
222
|
+
targetResponses: number;
|
|
223
|
+
}) => Promise<SurveyListItem>;
|
|
224
|
+
getNpsTrend: () => Promise<{
|
|
225
|
+
period: string;
|
|
226
|
+
score: number;
|
|
227
|
+
responses: number;
|
|
228
|
+
}[]>;
|
|
229
|
+
};
|
|
230
|
+
|
|
231
|
+
/** Allowed values for survey status. */
|
|
232
|
+
export declare type SurveyStatus = 'draft' | 'active' | 'paused' | 'closed';
|
|
233
|
+
|
|
234
|
+
/** Describes the survey template item. */
|
|
235
|
+
export declare interface SurveyTemplateItem {
|
|
236
|
+
id: string;
|
|
237
|
+
name: string;
|
|
238
|
+
description: string;
|
|
239
|
+
category: string;
|
|
240
|
+
questionCount: number;
|
|
241
|
+
isSystem: boolean;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
/** Renders the survey templates component. */
|
|
245
|
+
export declare const SurveyTemplates: () => default_2.JSX.Element;
|
|
246
|
+
|
|
247
|
+
/** Data transfer object for table config. */
|
|
248
|
+
export declare interface TableConfigDto {
|
|
249
|
+
tableName: string;
|
|
250
|
+
columns: {
|
|
251
|
+
key: string;
|
|
252
|
+
label: string;
|
|
253
|
+
cellType?: string | null;
|
|
254
|
+
align?: 'left' | 'center' | 'right';
|
|
255
|
+
width?: string;
|
|
256
|
+
minWidth?: string;
|
|
257
|
+
maxWidth?: string;
|
|
258
|
+
sortable: boolean;
|
|
259
|
+
hidden: boolean;
|
|
260
|
+
hideBelow?: 'sm' | 'md' | 'lg' | 'xl';
|
|
261
|
+
className?: string;
|
|
262
|
+
toggleable: boolean;
|
|
263
|
+
}[];
|
|
264
|
+
tabs: {
|
|
265
|
+
key: string;
|
|
266
|
+
label: string;
|
|
267
|
+
count?: number;
|
|
268
|
+
icon?: string;
|
|
269
|
+
}[];
|
|
270
|
+
controls: {
|
|
271
|
+
action: string;
|
|
272
|
+
label: string;
|
|
273
|
+
icon?: string;
|
|
274
|
+
variant: 'primary' | 'secondary' | 'ghost' | 'danger';
|
|
275
|
+
showOnSelection: boolean;
|
|
276
|
+
disabled: boolean;
|
|
277
|
+
}[];
|
|
278
|
+
defaultSortBy: string;
|
|
279
|
+
defaultSortOrder: 'asc' | 'desc';
|
|
280
|
+
defaultPageSize: number;
|
|
281
|
+
tabFilterKey?: string;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
declare interface TableExtra<T extends RowData = RowData> {
|
|
285
|
+
selectedIds: Set<RowId>;
|
|
286
|
+
onToggle: (id: RowId) => void;
|
|
287
|
+
onSelectAll: (checked: boolean) => void;
|
|
288
|
+
allChecked: boolean;
|
|
289
|
+
onActionClick?: (row: T) => void;
|
|
290
|
+
onEditRow?: (row: T) => void;
|
|
291
|
+
navigate?: (path: string, options?: NavigateOptions) => void;
|
|
292
|
+
currentPage: string;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
/** Parameters for table query. */
|
|
296
|
+
export declare interface TableQueryParams {
|
|
297
|
+
cursor?: string;
|
|
298
|
+
pageSize?: number;
|
|
299
|
+
search?: string;
|
|
300
|
+
sortBy?: string;
|
|
301
|
+
sortOrder?: 'asc' | 'desc';
|
|
302
|
+
tab?: string;
|
|
303
|
+
[key: string]: unknown;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
/** Cursor-paged survey responses, flattened for the DataTable. */
|
|
307
|
+
export declare function useSurveyResponses(pageSize?: number): {
|
|
308
|
+
items: SurveyResponseItem[];
|
|
309
|
+
totalCount: number;
|
|
310
|
+
isLoading: boolean;
|
|
311
|
+
isError: boolean;
|
|
312
|
+
hasMore: boolean;
|
|
313
|
+
loadMore: () => void;
|
|
314
|
+
};
|
|
315
|
+
|
|
316
|
+
/**
|
|
317
|
+
* Custom hook for table config.
|
|
318
|
+
*
|
|
319
|
+
* @param tableName - The table name.
|
|
320
|
+
* @returns The hook's state and actions.
|
|
321
|
+
*/
|
|
322
|
+
export declare function useTableConfig<T = any>(tableName: string): {
|
|
323
|
+
columns: {
|
|
324
|
+
key: keyof T & string;
|
|
325
|
+
label: string;
|
|
326
|
+
cellType: string | undefined;
|
|
327
|
+
align: "left" | "center" | "right";
|
|
328
|
+
width: string | undefined;
|
|
329
|
+
minWidth: string | undefined;
|
|
330
|
+
maxWidth: string | undefined;
|
|
331
|
+
sortable: boolean;
|
|
332
|
+
hidden: boolean;
|
|
333
|
+
hideBelow: "sm" | "md" | "lg" | "xl" | undefined;
|
|
334
|
+
className: string | undefined;
|
|
335
|
+
toggleable: boolean;
|
|
336
|
+
}[];
|
|
337
|
+
tabs: {
|
|
338
|
+
key: string;
|
|
339
|
+
label: string;
|
|
340
|
+
count: number | undefined;
|
|
341
|
+
icon: string | undefined;
|
|
342
|
+
}[];
|
|
343
|
+
controls: {
|
|
344
|
+
action: string;
|
|
345
|
+
label: string;
|
|
346
|
+
icon: string | undefined;
|
|
347
|
+
variant: "primary" | "secondary" | "ghost" | "danger";
|
|
348
|
+
showOnSelection: boolean;
|
|
349
|
+
disabled: boolean;
|
|
350
|
+
onClick: (() => void) | undefined;
|
|
351
|
+
}[];
|
|
352
|
+
defaultSortBy: string;
|
|
353
|
+
defaultSortOrder: "asc" | "desc";
|
|
354
|
+
defaultPageSize: number;
|
|
355
|
+
tabFilterKey: string | undefined;
|
|
356
|
+
isLoading: boolean;
|
|
357
|
+
isError: boolean;
|
|
358
|
+
};
|
|
359
|
+
|
|
360
|
+
/**
|
|
361
|
+
* Custom hook for table data.
|
|
362
|
+
*
|
|
363
|
+
* @param options - Options that customize the behavior.
|
|
364
|
+
* @returns The hook's state and actions.
|
|
365
|
+
*/
|
|
366
|
+
export declare function useTableData<T extends {
|
|
367
|
+
id: string | number;
|
|
368
|
+
}>(options: UseTableDataOptions<T>): {
|
|
369
|
+
items: T[];
|
|
370
|
+
totalCount: number;
|
|
371
|
+
hasMore: boolean;
|
|
372
|
+
isLoading: boolean;
|
|
373
|
+
isFetchingNextPage: boolean;
|
|
374
|
+
isRefetching: boolean;
|
|
375
|
+
isError: boolean;
|
|
376
|
+
refetch: (options?: RefetchOptions) => Promise<QueryObserverResult<InfiniteData<PagedResponse<T>, unknown>, Error>>;
|
|
377
|
+
search: string;
|
|
378
|
+
setSearch: Dispatch<SetStateAction<string>>;
|
|
379
|
+
sortBy: string;
|
|
380
|
+
sortOrder: "asc" | "desc";
|
|
381
|
+
setSortBy: Dispatch<SetStateAction<string>>;
|
|
382
|
+
setSortOrder: Dispatch<SetStateAction<"asc" | "desc">>;
|
|
383
|
+
handleSort: (key: string, order: "asc" | "desc") => void;
|
|
384
|
+
activeTab: string;
|
|
385
|
+
setActiveTab: Dispatch<SetStateAction<string>>;
|
|
386
|
+
handleTabChange: (tab: string) => void;
|
|
387
|
+
filters: Record<string, string>;
|
|
388
|
+
updateFilter: (key: string, value: string) => void;
|
|
389
|
+
loadMore: () => void;
|
|
390
|
+
optimisticUpdate: (id: string | number, updater: (item: T) => T) => void;
|
|
391
|
+
optimisticRemove: (id: string | number) => void;
|
|
392
|
+
};
|
|
393
|
+
|
|
394
|
+
declare interface UseTableDataOptions<T> {
|
|
395
|
+
resource: string;
|
|
396
|
+
queryKey: (string | number | Record<string, unknown>)[];
|
|
397
|
+
fetchFn: (params: Record<string, unknown>) => Promise<PagedResponse<T> | T[]>;
|
|
398
|
+
pageSize?: number;
|
|
399
|
+
defaultSortBy?: string;
|
|
400
|
+
defaultSortOrder?: 'asc' | 'desc';
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
export { }
|