@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.
- package/README.md +38 -38
- package/dist/assets/index-BPe2owrS.js +40 -0
- package/dist/assets/index-Chkvn1aI.css +1 -0
- package/dist/index.html +13 -0
- package/package.json +13 -36
- package/LICENSE +0 -9
- 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/src/nav.ts
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { NavItem } from '@/app/navigation/types';
|
|
2
|
-
|
|
3
|
-
const surveyNav: NavItem[] = [
|
|
4
|
-
{
|
|
5
|
-
id: 'all-surveys',
|
|
6
|
-
label: 'All Surveys',
|
|
7
|
-
icon: 'LayoutDashboard',
|
|
8
|
-
module: 'Survey',
|
|
9
|
-
category: 'All Surveys',
|
|
10
|
-
section: 'survey',
|
|
11
|
-
path: '/app/all-surveys',
|
|
12
|
-
order: 1,
|
|
13
|
-
},
|
|
14
|
-
{
|
|
15
|
-
id: 'survey-templates',
|
|
16
|
-
label: 'Survey Templates',
|
|
17
|
-
icon: 'LayoutDashboard',
|
|
18
|
-
module: 'Survey',
|
|
19
|
-
category: 'Survey Templates',
|
|
20
|
-
section: 'survey',
|
|
21
|
-
path: '/app/survey-templates',
|
|
22
|
-
order: 2,
|
|
23
|
-
},
|
|
24
|
-
{
|
|
25
|
-
id: 'responses',
|
|
26
|
-
label: 'Responses',
|
|
27
|
-
icon: 'LayoutDashboard',
|
|
28
|
-
module: 'Survey',
|
|
29
|
-
category: 'Responses',
|
|
30
|
-
section: 'survey',
|
|
31
|
-
path: '/app/responses',
|
|
32
|
-
order: 3,
|
|
33
|
-
},
|
|
34
|
-
{
|
|
35
|
-
id: 'nps-tracker',
|
|
36
|
-
label: 'NPS Tracker',
|
|
37
|
-
icon: 'LayoutDashboard',
|
|
38
|
-
module: 'Survey',
|
|
39
|
-
category: 'NPS Tracker',
|
|
40
|
-
section: 'survey',
|
|
41
|
-
path: '/app/nps-tracker',
|
|
42
|
-
order: 4,
|
|
43
|
-
},
|
|
44
|
-
{
|
|
45
|
-
id: 'survey-analytics',
|
|
46
|
-
label: 'Survey Analytics',
|
|
47
|
-
icon: 'LayoutDashboard',
|
|
48
|
-
module: 'Survey',
|
|
49
|
-
category: 'Survey Analytics',
|
|
50
|
-
section: 'survey',
|
|
51
|
-
path: '/app/survey-analytics',
|
|
52
|
-
order: 5,
|
|
53
|
-
}
|
|
54
|
-
];
|
|
55
|
-
export default surveyNav;
|
package/src/routes.ts
DELETED
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
// src/modules/survey/routes.ts
|
|
2
|
-
import type { RouteConfig } from '@/app/router/types';
|
|
3
|
-
import { lazy } from 'react';
|
|
4
|
-
|
|
5
|
-
const AllSurveys = lazy(() =>
|
|
6
|
-
import('./Pages/Allsurvey/Allsurvey').then((module) => ({
|
|
7
|
-
default: module.AllSurveys,
|
|
8
|
-
}))
|
|
9
|
-
);
|
|
10
|
-
|
|
11
|
-
const SurveyDetails = lazy(() =>
|
|
12
|
-
import('./Pages/Surveydetails/Surveydetails').then((module) => ({
|
|
13
|
-
default: module.SurveyDetails,
|
|
14
|
-
}))
|
|
15
|
-
);
|
|
16
|
-
|
|
17
|
-
const CreateSurvey = lazy(() =>
|
|
18
|
-
import('./Pages/Createsurvey/Createsurvey').then((module) => ({
|
|
19
|
-
default: module.CreateSurvey,
|
|
20
|
-
}))
|
|
21
|
-
);
|
|
22
|
-
|
|
23
|
-
const SurveyTemplates = lazy(() =>
|
|
24
|
-
import('./Pages/Surveytemplates/Surveytemplates').then((module) => ({
|
|
25
|
-
default: module.SurveyTemplates,
|
|
26
|
-
}))
|
|
27
|
-
);
|
|
28
|
-
|
|
29
|
-
const Responses = lazy(() =>
|
|
30
|
-
import('./Pages/Responses/Responses').then((module) => ({
|
|
31
|
-
default: module.Responses,
|
|
32
|
-
}))
|
|
33
|
-
);
|
|
34
|
-
|
|
35
|
-
const NPSTracker = lazy(() =>
|
|
36
|
-
import('./Pages/NPStracker/NPStracker').then((module) => ({
|
|
37
|
-
default: module.NPSTracker,
|
|
38
|
-
}))
|
|
39
|
-
);
|
|
40
|
-
|
|
41
|
-
const SurveyAnalytics = lazy(() =>
|
|
42
|
-
import('./Pages/Surveyanalytics/Surveyanalytics').then((module) => ({
|
|
43
|
-
default: module.SurveyAnalytics,
|
|
44
|
-
}))
|
|
45
|
-
);
|
|
46
|
-
|
|
47
|
-
const SurveyRoutes: RouteConfig[] = [
|
|
48
|
-
{
|
|
49
|
-
path: '/all-surveys',
|
|
50
|
-
element: AllSurveys,
|
|
51
|
-
isPublic: false,
|
|
52
|
-
meta: { title: 'All Surveys', module: 'survey' },
|
|
53
|
-
},
|
|
54
|
-
{
|
|
55
|
-
path: '/all-surveys/create-survey',
|
|
56
|
-
element: CreateSurvey,
|
|
57
|
-
isPublic: false,
|
|
58
|
-
meta: { title: 'Create Survey', module: 'survey' },
|
|
59
|
-
},
|
|
60
|
-
{
|
|
61
|
-
path: '/surveys/:surveyId',
|
|
62
|
-
element: SurveyDetails,
|
|
63
|
-
isPublic: false,
|
|
64
|
-
meta: { title: 'Survey Details', module: 'survey' },
|
|
65
|
-
},
|
|
66
|
-
{
|
|
67
|
-
path: '/survey-templates',
|
|
68
|
-
element: SurveyTemplates,
|
|
69
|
-
isPublic: false,
|
|
70
|
-
meta: { title: 'Survey Templates', module: 'survey' },
|
|
71
|
-
},
|
|
72
|
-
{
|
|
73
|
-
path: '/responses',
|
|
74
|
-
element: Responses,
|
|
75
|
-
isPublic: false,
|
|
76
|
-
meta: { title: 'Responses', module: 'survey' },
|
|
77
|
-
},
|
|
78
|
-
{
|
|
79
|
-
path: '/nps-tracker',
|
|
80
|
-
element: NPSTracker,
|
|
81
|
-
isPublic: false,
|
|
82
|
-
meta: { title: 'NPS Tracker', module: 'survey' },
|
|
83
|
-
},
|
|
84
|
-
{
|
|
85
|
-
path: '/survey-analytics',
|
|
86
|
-
element: SurveyAnalytics,
|
|
87
|
-
isPublic: false,
|
|
88
|
-
meta: { title: 'Survey Analytics', module: 'survey' },
|
|
89
|
-
},
|
|
90
|
-
{
|
|
91
|
-
path: '/survey-analytics/:surveyId',
|
|
92
|
-
element: SurveyAnalytics,
|
|
93
|
-
isPublic: false,
|
|
94
|
-
meta: { title: 'Survey Analytics', module: 'survey' },
|
|
95
|
-
},
|
|
96
|
-
];
|
|
97
|
-
|
|
98
|
-
export default SurveyRoutes;
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
/** Data transfer object for table config. */
|
|
2
|
-
export interface TableConfigDto {
|
|
3
|
-
tableName: string;
|
|
4
|
-
columns: {
|
|
5
|
-
key: string;
|
|
6
|
-
label: string;
|
|
7
|
-
cellType?: string | null;
|
|
8
|
-
align?: 'left' | 'center' | 'right';
|
|
9
|
-
width?: string;
|
|
10
|
-
minWidth?: string;
|
|
11
|
-
maxWidth?: string;
|
|
12
|
-
sortable: boolean;
|
|
13
|
-
hidden: boolean;
|
|
14
|
-
hideBelow?: 'sm' | 'md' | 'lg' | 'xl';
|
|
15
|
-
className?: string;
|
|
16
|
-
toggleable: boolean;
|
|
17
|
-
}[];
|
|
18
|
-
tabs: {
|
|
19
|
-
key: string;
|
|
20
|
-
label: string;
|
|
21
|
-
count?: number;
|
|
22
|
-
icon?: string;
|
|
23
|
-
}[];
|
|
24
|
-
controls: {
|
|
25
|
-
action: string;
|
|
26
|
-
label: string;
|
|
27
|
-
icon?: string;
|
|
28
|
-
variant: 'primary' | 'secondary' | 'ghost' | 'danger';
|
|
29
|
-
showOnSelection: boolean;
|
|
30
|
-
disabled: boolean;
|
|
31
|
-
}[];
|
|
32
|
-
defaultSortBy: string;
|
|
33
|
-
defaultSortOrder: 'asc' | 'desc';
|
|
34
|
-
defaultPageSize: number;
|
|
35
|
-
tabFilterKey?: string;
|
|
36
|
-
}
|
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
// src/services/api/surveys.api.ts
|
|
2
|
-
import axios from 'axios';
|
|
3
|
-
import type {
|
|
4
|
-
NpsSummary,
|
|
5
|
-
SurveyListItem,
|
|
6
|
-
CreateSurveyDto,
|
|
7
|
-
SurveyResponseItem,
|
|
8
|
-
SurveyAnalyticsItem,
|
|
9
|
-
SurveyTemplateItem,
|
|
10
|
-
PagedResponse,
|
|
11
|
-
TableQueryParams,
|
|
12
|
-
} from '../../types/survey.types';
|
|
13
|
-
|
|
14
|
-
const BASE = import.meta.env.VITE_API_URL;
|
|
15
|
-
|
|
16
|
-
const getHeaders = () => ({
|
|
17
|
-
Authorization: `Bearer ${localStorage.getItem('zelisy_access_token')}`,
|
|
18
|
-
'X-Organization-Id': localStorage.getItem('zelisy_org_id') ?? '',
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
export const surveysApi = {
|
|
22
|
-
// list: async (params?: TableQueryParams | Record<string, unknown>) => {
|
|
23
|
-
// const res = await axios.get<PagedResponse<SurveyListItem>>(
|
|
24
|
-
// `${BASE}/surveys`,
|
|
25
|
-
// { params, headers: getHeaders() }
|
|
26
|
-
// );
|
|
27
|
-
// return res.data;
|
|
28
|
-
// },
|
|
29
|
-
list: async (params?: TableQueryParams | Record<string, unknown>) => {
|
|
30
|
-
const res = await axios.get<{
|
|
31
|
-
success: boolean;
|
|
32
|
-
data: PagedResponse<SurveyListItem>;
|
|
33
|
-
}>('/JSON/surveys/GetSurveysQuery.json', {
|
|
34
|
-
params,
|
|
35
|
-
headers: getHeaders(),
|
|
36
|
-
});
|
|
37
|
-
return res.data.data;
|
|
38
|
-
},
|
|
39
|
-
// getNps: async (weeks = 12) => {
|
|
40
|
-
// const res = await axios.get<NpsSummary>(`${BASE}/surveys/nps`, {
|
|
41
|
-
// params: { weeks },
|
|
42
|
-
// headers: getHeaders(),
|
|
43
|
-
// });
|
|
44
|
-
// return res.data;
|
|
45
|
-
// },
|
|
46
|
-
getNps: async (weeks = 12) => {
|
|
47
|
-
const res = await axios.get<{
|
|
48
|
-
success: boolean;
|
|
49
|
-
data: NpsSummary;
|
|
50
|
-
}>('/JSON/surveys/GetNpsDataQuery.json', {
|
|
51
|
-
params: { weeks },
|
|
52
|
-
headers: getHeaders(),
|
|
53
|
-
});
|
|
54
|
-
return res.data.data;
|
|
55
|
-
},
|
|
56
|
-
// Single survey for the details page.
|
|
57
|
-
// Mock mode: reads the list JSON and picks the row. Real API: GET `${BASE}/surveys/${id}`.
|
|
58
|
-
getById: async (id: string) => {
|
|
59
|
-
const page = await surveysApi.list({ pageSize: 1000 });
|
|
60
|
-
return page.items.find((s) => s.id === id) ?? null;
|
|
61
|
-
},
|
|
62
|
-
|
|
63
|
-
create: async (body: CreateSurveyDto) => {
|
|
64
|
-
const res = await axios.post<SurveyListItem>(`${BASE}/surveys`, body, {
|
|
65
|
-
headers: getHeaders(),
|
|
66
|
-
});
|
|
67
|
-
return res.data;
|
|
68
|
-
},
|
|
69
|
-
|
|
70
|
-
delete: async (id: string) => {
|
|
71
|
-
await axios.delete<void>(`${BASE}/surveys/${id}`, {
|
|
72
|
-
headers: getHeaders(),
|
|
73
|
-
});
|
|
74
|
-
},
|
|
75
|
-
|
|
76
|
-
// getResponses: async (params?: Record<string, unknown>) => {
|
|
77
|
-
// const res = await axios.get<PagedResponse<SurveyResponseItem>>(
|
|
78
|
-
// `${BASE}/surveys/responses`,
|
|
79
|
-
// { params, headers: getHeaders() }
|
|
80
|
-
// );
|
|
81
|
-
// return res.data;
|
|
82
|
-
// },
|
|
83
|
-
getResponses: async (params?: Record<string, unknown>) => {
|
|
84
|
-
const res = await axios.get<{
|
|
85
|
-
success: boolean;
|
|
86
|
-
data: PagedResponse<SurveyResponseItem>;
|
|
87
|
-
}>('/JSON/surveys/GetSurveyResponsesQuery.json', {
|
|
88
|
-
params,
|
|
89
|
-
headers: getHeaders(),
|
|
90
|
-
});
|
|
91
|
-
return res.data.data;
|
|
92
|
-
},
|
|
93
|
-
// getAnalytics: async () => {
|
|
94
|
-
// const res = await axios.get<SurveyAnalyticsItem[]>(
|
|
95
|
-
// `${BASE}/surveys/analytics`,
|
|
96
|
-
// { headers: getHeaders() }
|
|
97
|
-
// );
|
|
98
|
-
// return res.data;
|
|
99
|
-
// },
|
|
100
|
-
getAnalytics: async () => {
|
|
101
|
-
const res = await axios.get<{
|
|
102
|
-
success: boolean;
|
|
103
|
-
data: SurveyAnalyticsItem[];
|
|
104
|
-
}>('/JSON/surveys/GetSurveyAnalyticsQuery.json', {
|
|
105
|
-
headers: getHeaders(),
|
|
106
|
-
});
|
|
107
|
-
return res.data.data;
|
|
108
|
-
},
|
|
109
|
-
// getTemplates: async () => {
|
|
110
|
-
// const res = await axios.get<SurveyTemplateItem[]>(
|
|
111
|
-
// `${BASE}/surveys/templates`,
|
|
112
|
-
// { headers: getHeaders() }
|
|
113
|
-
// );
|
|
114
|
-
// return res.data;
|
|
115
|
-
// },
|
|
116
|
-
getTemplates: async () => {
|
|
117
|
-
const res = await axios.get<{
|
|
118
|
-
success: boolean;
|
|
119
|
-
data: SurveyTemplateItem[];
|
|
120
|
-
}>('/JSON/surveys/GetSurveyTemplatesQuery.json', {
|
|
121
|
-
headers: getHeaders(),
|
|
122
|
-
});
|
|
123
|
-
return res.data.data;
|
|
124
|
-
},
|
|
125
|
-
|
|
126
|
-
useTemplate: async (
|
|
127
|
-
templateId: string,
|
|
128
|
-
body: { name: string; targetResponses: number }
|
|
129
|
-
) => {
|
|
130
|
-
const res = await axios.post<SurveyListItem>(
|
|
131
|
-
`${BASE}/surveys/templates/${templateId}/use`,
|
|
132
|
-
body,
|
|
133
|
-
{ headers: getHeaders() }
|
|
134
|
-
);
|
|
135
|
-
return res.data;
|
|
136
|
-
},
|
|
137
|
-
|
|
138
|
-
getNpsTrend: async () => {
|
|
139
|
-
const res = await axios.get<
|
|
140
|
-
Array<{ period: string; score: number; responses: number }>
|
|
141
|
-
>(`${BASE}/surveys/nps-trend`, { headers: getHeaders() });
|
|
142
|
-
return res.data;
|
|
143
|
-
},
|
|
144
|
-
};
|
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
// src/features/surveys/types/survey.types.ts
|
|
2
|
-
|
|
3
|
-
// ── Survey list item (canonical, merged from both duplicates) ────────────────
|
|
4
|
-
/** Describes the survey list item. */
|
|
5
|
-
export interface SurveyListItem {
|
|
6
|
-
id: string;
|
|
7
|
-
name: string;
|
|
8
|
-
description: string | null;
|
|
9
|
-
status: 'draft' | 'active' | 'paused' | 'closed';
|
|
10
|
-
responses: number;
|
|
11
|
-
target: number;
|
|
12
|
-
createdAt: string;
|
|
13
|
-
endsAt: string | null;
|
|
14
|
-
npsScore: number | null;
|
|
15
|
-
questionCount: number;
|
|
16
|
-
createdByName: string;
|
|
17
|
-
updatedAt: string;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
// ── NPS ──────────────────────────────────────────────────────────────────────
|
|
21
|
-
/** Describes the nps summary. */
|
|
22
|
-
export interface NpsSummary {
|
|
23
|
-
currentScore: number;
|
|
24
|
-
scoreDelta: number;
|
|
25
|
-
promotersPercent: number;
|
|
26
|
-
passivesPercent: number;
|
|
27
|
-
detractorsPercent: number;
|
|
28
|
-
totalResponses: number;
|
|
29
|
-
trend: NpsTrendPoint[];
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/** Describes the nps trend point. */
|
|
33
|
-
export interface NpsTrendPoint {
|
|
34
|
-
period: string;
|
|
35
|
-
score: number;
|
|
36
|
-
responses: number;
|
|
37
|
-
promoters: number;
|
|
38
|
-
passives: number;
|
|
39
|
-
detractors: number;
|
|
40
|
-
trend: 'up' | 'down';
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
// ── Create survey payload (used by POST /surveys) ────────────────────────────
|
|
44
|
-
/** Data transfer object for create survey. */
|
|
45
|
-
export interface CreateSurveyDto {
|
|
46
|
-
name: string;
|
|
47
|
-
description?: string;
|
|
48
|
-
targetResponses: number;
|
|
49
|
-
endsAt?: string;
|
|
50
|
-
questions: SurveyQuestionDto[];
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
/** Data transfer object for survey question. */
|
|
54
|
-
export interface SurveyQuestionDto {
|
|
55
|
-
question: string;
|
|
56
|
-
type: 'nps' | 'rating' | 'multiple_choice' | 'open_text';
|
|
57
|
-
required: boolean;
|
|
58
|
-
options?: string[];
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
// Alias for backward compatibility (some pages import CreateSurveyPayload)
|
|
62
|
-
/** Type definition for create survey payload. */
|
|
63
|
-
export type CreateSurveyPayload = CreateSurveyDto;
|
|
64
|
-
|
|
65
|
-
// ── Survey responses ─────────────────────────────────────────────────────────
|
|
66
|
-
/** Describes the survey response item. */
|
|
67
|
-
export interface SurveyResponseItem {
|
|
68
|
-
id: string;
|
|
69
|
-
surveyId: string;
|
|
70
|
-
surveyName: string;
|
|
71
|
-
userId: string;
|
|
72
|
-
npsScore?: number;
|
|
73
|
-
rating?: number;
|
|
74
|
-
responseText?: string;
|
|
75
|
-
createdAt: string;
|
|
76
|
-
npsCategory: 'promoter' | 'passive' | 'detractor';
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
// ── Analytics ────────────────────────────────────────────────────────────────
|
|
80
|
-
/** Describes the survey analytics item. */
|
|
81
|
-
export interface SurveyAnalyticsItem {
|
|
82
|
-
surveyId: string;
|
|
83
|
-
surveyName: string;
|
|
84
|
-
totalResponses: number;
|
|
85
|
-
completionRate: number;
|
|
86
|
-
avgCompletionTime: string;
|
|
87
|
-
npsScore?: number;
|
|
88
|
-
averageRating: number;
|
|
89
|
-
topTheme: string;
|
|
90
|
-
bottomTheme: string;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
// ── Templates ────────────────────────────────────────────────────────────────
|
|
94
|
-
/** Describes the survey template item. */
|
|
95
|
-
export interface SurveyTemplateItem {
|
|
96
|
-
id: string;
|
|
97
|
-
name: string;
|
|
98
|
-
description: string;
|
|
99
|
-
category: string;
|
|
100
|
-
questionCount: number;
|
|
101
|
-
isSystem: boolean;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
// ── Pagination wrapper ───────────────────────────────────────────────────────
|
|
105
|
-
/** Describes the paged response. */
|
|
106
|
-
export interface PagedResponse<T> {
|
|
107
|
-
items: T[];
|
|
108
|
-
totalCount: number;
|
|
109
|
-
page?: number;
|
|
110
|
-
pageSize: number;
|
|
111
|
-
hasMore: boolean;
|
|
112
|
-
nextCursor: string | null;
|
|
113
|
-
}
|
|
@@ -1,175 +0,0 @@
|
|
|
1
|
-
/* Survey module types — single source of truth (mirrors queue/types/*).
|
|
2
|
-
Moved from services/api/{types,TableConfigDto,TableQueryParams}.ts */
|
|
3
|
-
|
|
4
|
-
/** Describes the api response. */
|
|
5
|
-
export interface ApiResponse<T> {
|
|
6
|
-
data: T;
|
|
7
|
-
success: boolean;
|
|
8
|
-
message?: string;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
// ── Survey list item (canonical, merged from both duplicates) ────────────────
|
|
12
|
-
/** Allowed values for survey status. */
|
|
13
|
-
export type SurveyStatus = 'draft' | 'active' | 'paused' | 'closed';
|
|
14
|
-
|
|
15
|
-
/** Describes the survey list item. */
|
|
16
|
-
export interface SurveyListItem {
|
|
17
|
-
id: string;
|
|
18
|
-
name: string;
|
|
19
|
-
description: string | null;
|
|
20
|
-
status: SurveyStatus;
|
|
21
|
-
responses: number;
|
|
22
|
-
target: number;
|
|
23
|
-
createdAt: string;
|
|
24
|
-
endsAt: string | null;
|
|
25
|
-
npsScore: number | null;
|
|
26
|
-
questionCount: number;
|
|
27
|
-
createdByName: string;
|
|
28
|
-
updatedAt: string;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/** One row of the All-Surveys table. */
|
|
32
|
-
export type SurveyRow = SurveyListItem;
|
|
33
|
-
|
|
34
|
-
// ── NPS ──────────────────────────────────────────────────────────────────────
|
|
35
|
-
/** Describes the nps summary. */
|
|
36
|
-
export interface NpsSummary {
|
|
37
|
-
currentScore: number;
|
|
38
|
-
scoreDelta: number;
|
|
39
|
-
promotersPercent: number;
|
|
40
|
-
passivesPercent: number;
|
|
41
|
-
detractorsPercent: number;
|
|
42
|
-
totalResponses: number;
|
|
43
|
-
trend: NpsTrendPoint[];
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
/** Describes the nps trend point. */
|
|
47
|
-
export interface NpsTrendPoint {
|
|
48
|
-
period: string;
|
|
49
|
-
score: number;
|
|
50
|
-
responses: number;
|
|
51
|
-
promoters: number;
|
|
52
|
-
passives: number;
|
|
53
|
-
detractors: number;
|
|
54
|
-
trend: 'up' | 'down';
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
// ── Create survey payload (used by POST /surveys) ────────────────────────────
|
|
58
|
-
/** Data transfer object for create survey. */
|
|
59
|
-
export interface CreateSurveyDto {
|
|
60
|
-
name: string;
|
|
61
|
-
description?: string;
|
|
62
|
-
targetResponses: number;
|
|
63
|
-
endsAt?: string;
|
|
64
|
-
questions: SurveyQuestionDto[];
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
/** Data transfer object for survey question. */
|
|
68
|
-
export interface SurveyQuestionDto {
|
|
69
|
-
question: string;
|
|
70
|
-
type: 'nps' | 'rating' | 'multiple_choice' | 'open_text';
|
|
71
|
-
required: boolean;
|
|
72
|
-
options?: string[];
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
// Alias for backward compatibility (some pages import CreateSurveyPayload)
|
|
76
|
-
/** Type definition for create survey payload. */
|
|
77
|
-
export type CreateSurveyPayload = CreateSurveyDto;
|
|
78
|
-
|
|
79
|
-
// ── Survey responses ─────────────────────────────────────────────────────────
|
|
80
|
-
/** Describes the survey response item. */
|
|
81
|
-
export interface SurveyResponseItem {
|
|
82
|
-
id: string;
|
|
83
|
-
surveyId: string;
|
|
84
|
-
surveyName: string;
|
|
85
|
-
userId: string;
|
|
86
|
-
npsScore?: number;
|
|
87
|
-
rating?: number;
|
|
88
|
-
responseText?: string;
|
|
89
|
-
createdAt: string;
|
|
90
|
-
npsCategory: 'promoter' | 'passive' | 'detractor';
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
// ── Analytics ────────────────────────────────────────────────────────────────
|
|
94
|
-
/** Describes the survey analytics item. */
|
|
95
|
-
export interface SurveyAnalyticsItem {
|
|
96
|
-
surveyId: string;
|
|
97
|
-
surveyName: string;
|
|
98
|
-
totalResponses: number;
|
|
99
|
-
completionRate: number;
|
|
100
|
-
avgCompletionTime: string;
|
|
101
|
-
npsScore?: number;
|
|
102
|
-
averageRating: number;
|
|
103
|
-
topTheme: string;
|
|
104
|
-
bottomTheme: string;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
/** One row of the Survey Analytics table (DataTable rows need an `id`). */
|
|
108
|
-
export type SurveyAnalyticsRow = SurveyAnalyticsItem & { id: string };
|
|
109
|
-
|
|
110
|
-
// ── Templates ────────────────────────────────────────────────────────────────
|
|
111
|
-
/** Describes the survey template item. */
|
|
112
|
-
export interface SurveyTemplateItem {
|
|
113
|
-
id: string;
|
|
114
|
-
name: string;
|
|
115
|
-
description: string;
|
|
116
|
-
category: string;
|
|
117
|
-
questionCount: number;
|
|
118
|
-
isSystem: boolean;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
// ── Pagination wrapper ───────────────────────────────────────────────────────
|
|
122
|
-
/** Describes the paged response. */
|
|
123
|
-
export interface PagedResponse<T> {
|
|
124
|
-
items: T[];
|
|
125
|
-
totalCount: number;
|
|
126
|
-
page?: number;
|
|
127
|
-
pageSize: number;
|
|
128
|
-
hasMore: boolean;
|
|
129
|
-
nextCursor: string | null;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
// ── Server-driven table config (GET /tables/:name/config) ────────────────────
|
|
133
|
-
/** Data transfer object for table config. */
|
|
134
|
-
export interface TableConfigDto {
|
|
135
|
-
tableName: string;
|
|
136
|
-
columns: {
|
|
137
|
-
key: string;
|
|
138
|
-
label: string;
|
|
139
|
-
cellType?: string | null;
|
|
140
|
-
align?: 'left' | 'center' | 'right';
|
|
141
|
-
width?: string;
|
|
142
|
-
minWidth?: string;
|
|
143
|
-
maxWidth?: string;
|
|
144
|
-
sortable: boolean;
|
|
145
|
-
hidden: boolean;
|
|
146
|
-
hideBelow?: 'sm' | 'md' | 'lg' | 'xl';
|
|
147
|
-
className?: string;
|
|
148
|
-
toggleable: boolean;
|
|
149
|
-
}[];
|
|
150
|
-
tabs: { key: string; label: string; count?: number; icon?: string }[];
|
|
151
|
-
controls: {
|
|
152
|
-
action: string;
|
|
153
|
-
label: string;
|
|
154
|
-
icon?: string;
|
|
155
|
-
variant: 'primary' | 'secondary' | 'ghost' | 'danger';
|
|
156
|
-
showOnSelection: boolean;
|
|
157
|
-
disabled: boolean;
|
|
158
|
-
}[];
|
|
159
|
-
defaultSortBy: string;
|
|
160
|
-
defaultSortOrder: 'asc' | 'desc';
|
|
161
|
-
defaultPageSize: number;
|
|
162
|
-
tabFilterKey?: string;
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
// ── Query params sent to list endpoints ──────────────────────────────────────
|
|
166
|
-
/** Parameters for table query. */
|
|
167
|
-
export interface TableQueryParams {
|
|
168
|
-
cursor?: string;
|
|
169
|
-
pageSize?: number;
|
|
170
|
-
search?: string;
|
|
171
|
-
sortBy?: string;
|
|
172
|
-
sortOrder?: 'asc' | 'desc';
|
|
173
|
-
tab?: string;
|
|
174
|
-
[key: string]: unknown;
|
|
175
|
-
}
|