@wix/ditto-codegen-public 1.0.274 → 1.0.276
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/out.js +5 -5
- package/package.json +2 -2
- package/dist/examples-apps/ai-chatbot/.nvmrc +0 -1
- package/dist/examples-apps/ai-chatbot/README.md +0 -21
- package/dist/examples-apps/ai-chatbot/package-lock.json +0 -7266
- package/dist/examples-apps/ai-chatbot/package.json +0 -35
- package/dist/examples-apps/ai-chatbot/src/dashboard/pages/product/ProductChat.module.css +0 -3
- package/dist/examples-apps/ai-chatbot/src/dashboard/pages/product/ProductChat.tsx +0 -108
- package/dist/examples-apps/ai-chatbot/src/dashboard/pages/product/page.tsx +0 -100
- package/dist/examples-apps/ai-chatbot/src/dashboard/withProviders.tsx +0 -15
- package/dist/examples-apps/ai-chatbot/src/env.d.ts +0 -4
- package/dist/examples-apps/ai-chatbot/src/types.ts +0 -4
- package/dist/examples-apps/ai-chatbot/tsconfig.json +0 -8
- package/dist/examples-apps/ai-chatbot/wix.config.json +0 -5
- package/dist/examples-apps/contact-created-logger/package-lock.json +0 -15102
- package/dist/examples-apps/contact-created-logger/package.json +0 -37
- package/dist/examples-apps/contact-created-logger/src/backend/events/contact-created-logger/event.ts +0 -56
- package/dist/examples-apps/contact-created-logger/tsconfig.json +0 -5
- package/dist/examples-apps/contact-created-logger/wix.config.json +0 -4
- package/dist/examples-apps/coupon-popup/README.md +0 -13
- package/dist/examples-apps/coupon-popup/package.json +0 -43
- package/dist/examples-apps/coupon-popup/src/extensions.ts +0 -12
- package/dist/examples-apps/coupon-popup/src/index.ts +0 -2
- package/dist/examples-apps/coupon-popup/src/site/embedded-scripts/cart-coupon-popup/embedded.html +0 -562
- package/dist/examples-apps/coupon-popup/src/site/embedded-scripts/cart-coupon-popup/extensions.ts +0 -8
- package/dist/examples-apps/coupon-popup/tsconfig.json +0 -10
- package/dist/examples-apps/coupon-popup/wix.config.json +0 -4
- package/dist/examples-apps/custom-element/countdown-widget/components/ColorPickerField.tsx +0 -27
- package/dist/examples-apps/custom-element/countdown-widget/components/FontPickerField.tsx +0 -34
- package/dist/examples-apps/custom-element/countdown-widget/components/Separator.tsx +0 -10
- package/dist/examples-apps/custom-element/countdown-widget/components/TimeBlock.tsx +0 -23
- package/dist/examples-apps/custom-element/countdown-widget/extensions.ts +0 -18
- package/dist/examples-apps/custom-element/countdown-widget/panel.tsx +0 -146
- package/dist/examples-apps/custom-element/countdown-widget/styles.ts +0 -73
- package/dist/examples-apps/custom-element/countdown-widget/utils.ts +0 -46
- package/dist/examples-apps/custom-element/countdown-widget/widget.tsx +0 -97
- package/dist/examples-apps/product-created-logger/package-lock.json +0 -15102
- package/dist/examples-apps/product-created-logger/package.json +0 -37
- package/dist/examples-apps/product-created-logger/src/backend/events/product-created-logger/event.ts +0 -66
- package/dist/examples-apps/product-created-logger/tsconfig.json +0 -5
- package/dist/examples-apps/product-created-logger/wix.config.json +0 -4
- package/dist/examples-apps/react-builder/component.tsx +0 -123
- package/dist/examples-apps/react-builder/components/Badge.tsx +0 -14
- package/dist/examples-apps/react-builder/components/Button.tsx +0 -31
- package/dist/examples-apps/react-builder/components/Counter.tsx +0 -14
- package/dist/examples-apps/react-builder/components/FeaturedImage.tsx +0 -31
- package/dist/examples-apps/react-builder/components/SocialLinks.tsx +0 -61
- package/dist/examples-apps/react-builder/components/Subtitle.tsx +0 -11
- package/dist/examples-apps/react-builder/components/Tags.tsx +0 -25
- package/dist/examples-apps/react-builder/components/Title.tsx +0 -11
- package/dist/examples-apps/react-builder/components/index.ts +0 -8
- package/dist/examples-apps/react-builder/manifest.json +0 -345
- package/dist/examples-apps/react-builder/style.css +0 -197
- package/dist/examples-apps/react-builder/types.ts +0 -70
- package/dist/examples-apps/spis-examples/.nvmrc +0 -1
- package/dist/examples-apps/spis-examples/README.md +0 -21
- package/dist/examples-apps/spis-examples/package-lock.json +0 -6903
- package/dist/examples-apps/spis-examples/package.json +0 -32
- package/dist/examples-apps/spis-examples/src/backend/service-plugins/ecom-additional-fees/additional-fees/plugin.ts +0 -66
- package/dist/examples-apps/spis-examples/src/backend/service-plugins/ecom-discount-triggers/discount-triggers/plugin.ts +0 -42
- package/dist/examples-apps/spis-examples/src/backend/service-plugins/ecom-gift-cards/gift-cards/plugin.ts +0 -38
- package/dist/examples-apps/spis-examples/src/backend/service-plugins/ecom-shipping-rates/shipping-rates/plugin.ts +0 -34
- package/dist/examples-apps/spis-examples/src/backend/service-plugins/ecom-validations/validations/plugin.ts +0 -24
- package/dist/examples-apps/spis-examples/src/env.d.ts +0 -4
- package/dist/examples-apps/spis-examples/tsconfig.json +0 -8
- package/dist/examples-apps/spis-examples/wix.config.json +0 -5
- package/dist/examples-apps/survey-manager/README.md +0 -21
- package/dist/examples-apps/survey-manager/package-lock.json +0 -14252
- package/dist/examples-apps/survey-manager/package.json +0 -36
- package/dist/examples-apps/survey-manager/src/dashboard/pages/apis.ts +0 -116
- package/dist/examples-apps/survey-manager/src/dashboard/pages/components/PageLoader.tsx +0 -23
- package/dist/examples-apps/survey-manager/src/dashboard/pages/components/QuestionModal.tsx +0 -84
- package/dist/examples-apps/survey-manager/src/dashboard/pages/components/QuestionsTable.tsx +0 -139
- package/dist/examples-apps/survey-manager/src/dashboard/pages/components/SurveyPageLayout.tsx +0 -99
- package/dist/examples-apps/survey-manager/src/dashboard/pages/components/SurveyStats.tsx +0 -50
- package/dist/examples-apps/survey-manager/src/dashboard/pages/page.tsx +0 -171
- package/dist/examples-apps/survey-manager/src/dashboard/pages/types.ts +0 -28
- package/dist/examples-apps/survey-manager/tsconfig.json +0 -8
- package/dist/examples-apps/survey-manager/wix.config.json +0 -4
- package/dist/opencode-tools/wds-lookup.ts +0 -134
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "wix-astro-blank",
|
|
3
|
-
"type": "module",
|
|
4
|
-
"version": "0.0.1",
|
|
5
|
-
"scripts": {
|
|
6
|
-
"astro": "astro",
|
|
7
|
-
"dev": "wix dev",
|
|
8
|
-
"build": "wix build",
|
|
9
|
-
"wix": "wix",
|
|
10
|
-
"preview": "wix preview",
|
|
11
|
-
"release": "wix release",
|
|
12
|
-
"generate": "wix generate",
|
|
13
|
-
"env": "wix env"
|
|
14
|
-
},
|
|
15
|
-
"dependencies": {
|
|
16
|
-
"@wix/astro": "^2.12.0",
|
|
17
|
-
"@wix/ecom": "^1.0.1392",
|
|
18
|
-
"@wix/data": "^1.0.291",
|
|
19
|
-
"@wix/design-system": "^1.219.0",
|
|
20
|
-
"@wix/wix-ui-icons-common": "^3.92.0",
|
|
21
|
-
"@wix/dashboard": "^1.3.36",
|
|
22
|
-
"@wix/essentials": "^0.1.23",
|
|
23
|
-
"@wix/sdk": "^1.15.23",
|
|
24
|
-
"astro": "^5.8.0",
|
|
25
|
-
"typescript": "^5.8.3"
|
|
26
|
-
},
|
|
27
|
-
"devDependencies": {
|
|
28
|
-
"@astrojs/cloudflare": "^12.5.3",
|
|
29
|
-
"@astrojs/react": "^4.3.0",
|
|
30
|
-
"@types/react": "^18.3.1",
|
|
31
|
-
"@types/react-dom": "^18.3.1",
|
|
32
|
-
"@wix/cli": "^1.1.92",
|
|
33
|
-
"react": "18.3.1",
|
|
34
|
-
"react-dom": "18.3.1"
|
|
35
|
-
}
|
|
36
|
-
}
|
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
import { items } from '@wix/data';
|
|
2
|
-
import type { SurveyQuestion, SurveyResponse, QuestionStats } from './types';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Creates a new survey question
|
|
6
|
-
*/
|
|
7
|
-
export async function createQuestion(
|
|
8
|
-
questionData: Omit<SurveyQuestion, '_id' | '_createdDate' | '_updatedDate' | '_owner'>
|
|
9
|
-
): Promise<SurveyQuestion> {
|
|
10
|
-
try {
|
|
11
|
-
const result = await items.insert('survey-questions', questionData);
|
|
12
|
-
return result as SurveyQuestion;
|
|
13
|
-
} catch (error) {
|
|
14
|
-
console.error('Error creating survey question:', error);
|
|
15
|
-
throw new Error(
|
|
16
|
-
error instanceof Error ? error.message : 'Failed to create survey question'
|
|
17
|
-
);
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Retrieves all survey questions
|
|
23
|
-
*/
|
|
24
|
-
export async function getAllQuestions(): Promise<items.WixDataResult<SurveyQuestion>> {
|
|
25
|
-
try {
|
|
26
|
-
const result = await items.query('survey-questions')
|
|
27
|
-
.descending('_createdDate')
|
|
28
|
-
.find();
|
|
29
|
-
return result as items.WixDataResult<SurveyQuestion>;
|
|
30
|
-
} catch (error) {
|
|
31
|
-
console.error('Error fetching survey questions:', error);
|
|
32
|
-
throw new Error(
|
|
33
|
-
error instanceof Error ? error.message : 'Failed to fetch survey questions'
|
|
34
|
-
);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Updates an existing survey question
|
|
40
|
-
*/
|
|
41
|
-
export async function updateQuestion(questionData: SurveyQuestion): Promise<SurveyQuestion> {
|
|
42
|
-
try {
|
|
43
|
-
if (!questionData._id) {
|
|
44
|
-
throw new Error('Question ID is required for update');
|
|
45
|
-
}
|
|
46
|
-
const result = await items.update('survey-questions', questionData);
|
|
47
|
-
return result as SurveyQuestion;
|
|
48
|
-
} catch (error) {
|
|
49
|
-
console.error('Error updating survey question:', error);
|
|
50
|
-
throw new Error(
|
|
51
|
-
error instanceof Error ? error.message : 'Failed to update survey question'
|
|
52
|
-
);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* Deletes a survey question by ID
|
|
58
|
-
*/
|
|
59
|
-
export async function deleteQuestion(questionId: string): Promise<SurveyQuestion> {
|
|
60
|
-
try {
|
|
61
|
-
if (!questionId) {
|
|
62
|
-
throw new Error('Question ID is required for deletion');
|
|
63
|
-
}
|
|
64
|
-
const result = await items.remove('survey-questions', questionId);
|
|
65
|
-
return result as SurveyQuestion;
|
|
66
|
-
} catch (error) {
|
|
67
|
-
console.error('Error deleting survey question:', error);
|
|
68
|
-
throw new Error(
|
|
69
|
-
error instanceof Error ? error.message : 'Failed to delete survey question'
|
|
70
|
-
);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* Gets statistics for a specific question
|
|
76
|
-
*/
|
|
77
|
-
export async function getQuestionStats(questionId: string): Promise<QuestionStats> {
|
|
78
|
-
try {
|
|
79
|
-
const responses = await items.query('survey-responses')
|
|
80
|
-
.eq('questionId', questionId)
|
|
81
|
-
.find();
|
|
82
|
-
|
|
83
|
-
const responseItems = responses.items as SurveyResponse[];
|
|
84
|
-
const totalResponses = responseItems.length;
|
|
85
|
-
|
|
86
|
-
if (totalResponses === 0) {
|
|
87
|
-
return {
|
|
88
|
-
totalResponses: 0,
|
|
89
|
-
averageRating: 0,
|
|
90
|
-
ratingDistribution: {}
|
|
91
|
-
};
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
const ratings = responseItems.map(r => r.rating);
|
|
95
|
-
const averageRating = ratings.reduce((sum, rating) => sum + rating, 0) / totalResponses;
|
|
96
|
-
|
|
97
|
-
const ratingDistribution: { [rating: number]: number } = {};
|
|
98
|
-
ratings.forEach(rating => {
|
|
99
|
-
ratingDistribution[rating] = (ratingDistribution[rating] || 0) + 1;
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
return {
|
|
103
|
-
totalResponses,
|
|
104
|
-
averageRating: Math.round(averageRating * 100) / 100,
|
|
105
|
-
ratingDistribution
|
|
106
|
-
};
|
|
107
|
-
} catch (error) {
|
|
108
|
-
console.error('Error fetching question stats:', error);
|
|
109
|
-
return {
|
|
110
|
-
totalResponses: 0,
|
|
111
|
-
averageRating: 0,
|
|
112
|
-
ratingDistribution: {}
|
|
113
|
-
};
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import React, { type FC } from 'react';
|
|
2
|
-
import { Page, WixDesignSystemProvider, Box, Loader } from '@wix/design-system';
|
|
3
|
-
|
|
4
|
-
interface PageLoaderProps {
|
|
5
|
-
title: string;
|
|
6
|
-
message?: string;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export const PageLoader: FC<PageLoaderProps> = ({ title, message = 'Loading...' }) => {
|
|
10
|
-
return (
|
|
11
|
-
<WixDesignSystemProvider features={{ newColorsBranding: true }}>
|
|
12
|
-
<Page height="100vh">
|
|
13
|
-
<Page.Header title={title} />
|
|
14
|
-
<Page.Content>
|
|
15
|
-
<Box align="center" verticalAlign="middle" height="50vh">
|
|
16
|
-
<Loader text={message} />
|
|
17
|
-
</Box>
|
|
18
|
-
</Page.Content>
|
|
19
|
-
</Page>
|
|
20
|
-
</WixDesignSystemProvider>
|
|
21
|
-
);
|
|
22
|
-
};
|
|
23
|
-
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import React, { type FC } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
Modal,
|
|
4
|
-
CustomModalLayout,
|
|
5
|
-
FormField,
|
|
6
|
-
Input,
|
|
7
|
-
ToggleSwitch,
|
|
8
|
-
Layout,
|
|
9
|
-
Cell,
|
|
10
|
-
} from '@wix/design-system';
|
|
11
|
-
import type { SurveyQuestion, QuestionFormData } from '../types';
|
|
12
|
-
|
|
13
|
-
interface QuestionModalProps {
|
|
14
|
-
isOpen: boolean;
|
|
15
|
-
editingQuestion: SurveyQuestion | null;
|
|
16
|
-
formData: QuestionFormData;
|
|
17
|
-
onFormChange: (data: QuestionFormData) => void;
|
|
18
|
-
onSave: () => void;
|
|
19
|
-
onClose: () => void;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export const QuestionModal: FC<QuestionModalProps> = ({
|
|
23
|
-
isOpen,
|
|
24
|
-
editingQuestion,
|
|
25
|
-
formData,
|
|
26
|
-
onFormChange,
|
|
27
|
-
onSave,
|
|
28
|
-
onClose,
|
|
29
|
-
}) => {
|
|
30
|
-
return (
|
|
31
|
-
<Modal isOpen={isOpen} onRequestClose={onClose}>
|
|
32
|
-
<CustomModalLayout
|
|
33
|
-
primaryButtonText="Save"
|
|
34
|
-
secondaryButtonText="Cancel"
|
|
35
|
-
onCloseButtonClick={onClose}
|
|
36
|
-
primaryButtonOnClick={onSave}
|
|
37
|
-
secondaryButtonOnClick={onClose}
|
|
38
|
-
title={`${editingQuestion ? 'Edit' : 'Add'} Survey Question`}
|
|
39
|
-
content={
|
|
40
|
-
<Layout gap="24px">
|
|
41
|
-
<Cell span={12}>
|
|
42
|
-
<FormField label="Question Text" required>
|
|
43
|
-
<Input
|
|
44
|
-
value={formData.questionText}
|
|
45
|
-
onChange={(e) =>
|
|
46
|
-
onFormChange({ ...formData, questionText: e.target.value })
|
|
47
|
-
}
|
|
48
|
-
placeholder="How would you rate our service?"
|
|
49
|
-
/>
|
|
50
|
-
</FormField>
|
|
51
|
-
</Cell>
|
|
52
|
-
<Cell span={6}>
|
|
53
|
-
<FormField label="Maximum Rating">
|
|
54
|
-
<Input
|
|
55
|
-
type="number"
|
|
56
|
-
value={formData.maxRating.toString()}
|
|
57
|
-
onChange={(e) =>
|
|
58
|
-
onFormChange({
|
|
59
|
-
...formData,
|
|
60
|
-
maxRating: Math.max(1, Math.min(10, Number(e.target.value))),
|
|
61
|
-
})
|
|
62
|
-
}
|
|
63
|
-
min={1}
|
|
64
|
-
max={10}
|
|
65
|
-
/>
|
|
66
|
-
</FormField>
|
|
67
|
-
</Cell>
|
|
68
|
-
<Cell span={6}>
|
|
69
|
-
<FormField label="Active" labelPlacement="right" stretchContent={false}>
|
|
70
|
-
<ToggleSwitch
|
|
71
|
-
checked={formData.isActive}
|
|
72
|
-
onChange={() =>
|
|
73
|
-
onFormChange({ ...formData, isActive: !formData.isActive })
|
|
74
|
-
}
|
|
75
|
-
/>
|
|
76
|
-
</FormField>
|
|
77
|
-
</Cell>
|
|
78
|
-
</Layout>
|
|
79
|
-
}
|
|
80
|
-
/>
|
|
81
|
-
</Modal>
|
|
82
|
-
);
|
|
83
|
-
};
|
|
84
|
-
|
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
import React, { type FC } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
Table,
|
|
4
|
-
TableActionCell,
|
|
5
|
-
TableToolbar,
|
|
6
|
-
Badge,
|
|
7
|
-
Box,
|
|
8
|
-
Text,
|
|
9
|
-
} from '@wix/design-system';
|
|
10
|
-
import * as Icons from '@wix/wix-ui-icons-common';
|
|
11
|
-
import type { SurveyQuestion, QuestionStats } from '../types';
|
|
12
|
-
|
|
13
|
-
interface QuestionsTableProps {
|
|
14
|
-
questions: SurveyQuestion[];
|
|
15
|
-
questionStats: Record<string, QuestionStats>;
|
|
16
|
-
onEdit: (question: SurveyQuestion) => void;
|
|
17
|
-
onDelete: (questionId: string, questionText: string) => void;
|
|
18
|
-
onToggleStatus: (question: SurveyQuestion) => void;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export const QuestionsTable: FC<QuestionsTableProps> = ({
|
|
22
|
-
questions,
|
|
23
|
-
questionStats,
|
|
24
|
-
onEdit,
|
|
25
|
-
onDelete,
|
|
26
|
-
onToggleStatus,
|
|
27
|
-
}) => {
|
|
28
|
-
const columns = [
|
|
29
|
-
{
|
|
30
|
-
title: 'Question',
|
|
31
|
-
render: (question: SurveyQuestion) => (
|
|
32
|
-
<Box direction="vertical" gap="3px">
|
|
33
|
-
<Text size="medium" weight="normal">
|
|
34
|
-
{question.questionText}
|
|
35
|
-
</Text>
|
|
36
|
-
<Box gap="6px">
|
|
37
|
-
<Badge
|
|
38
|
-
skin={question.isActive ? 'success' : 'neutral'}
|
|
39
|
-
size="small"
|
|
40
|
-
>
|
|
41
|
-
{question.isActive ? 'Active' : 'Inactive'}
|
|
42
|
-
</Badge>
|
|
43
|
-
<Text size="tiny" secondary>
|
|
44
|
-
Max Rating: {question.maxRating}
|
|
45
|
-
</Text>
|
|
46
|
-
</Box>
|
|
47
|
-
</Box>
|
|
48
|
-
),
|
|
49
|
-
width: 'auto',
|
|
50
|
-
},
|
|
51
|
-
{
|
|
52
|
-
title: 'Responses',
|
|
53
|
-
render: (question: SurveyQuestion) => {
|
|
54
|
-
const stats = question._id ? questionStats[question._id] : null;
|
|
55
|
-
return (
|
|
56
|
-
<Box direction="vertical" gap="3px">
|
|
57
|
-
<Text size="medium" weight="bold">
|
|
58
|
-
{stats?.totalResponses || 0}
|
|
59
|
-
</Text>
|
|
60
|
-
<Text size="tiny" secondary>
|
|
61
|
-
Total responses
|
|
62
|
-
</Text>
|
|
63
|
-
</Box>
|
|
64
|
-
);
|
|
65
|
-
},
|
|
66
|
-
width: '120px',
|
|
67
|
-
},
|
|
68
|
-
{
|
|
69
|
-
title: 'Average Rating',
|
|
70
|
-
render: (question: SurveyQuestion) => {
|
|
71
|
-
const stats = question._id ? questionStats[question._id] : null;
|
|
72
|
-
return (
|
|
73
|
-
<Box direction="vertical" gap="3px">
|
|
74
|
-
<Text size="medium" weight="bold">
|
|
75
|
-
{stats?.averageRating || 0}
|
|
76
|
-
</Text>
|
|
77
|
-
<Text size="tiny" secondary>
|
|
78
|
-
out of {question.maxRating}
|
|
79
|
-
</Text>
|
|
80
|
-
</Box>
|
|
81
|
-
);
|
|
82
|
-
},
|
|
83
|
-
width: '120px',
|
|
84
|
-
},
|
|
85
|
-
{
|
|
86
|
-
title: 'Created',
|
|
87
|
-
render: (question: SurveyQuestion) => (
|
|
88
|
-
<Text size="small">
|
|
89
|
-
{question._createdDate
|
|
90
|
-
? new Date(question._createdDate).toLocaleDateString()
|
|
91
|
-
: ''}
|
|
92
|
-
</Text>
|
|
93
|
-
),
|
|
94
|
-
width: '100px',
|
|
95
|
-
},
|
|
96
|
-
{
|
|
97
|
-
title: 'Actions',
|
|
98
|
-
render: (question: SurveyQuestion) => (
|
|
99
|
-
<TableActionCell
|
|
100
|
-
primaryAction={{
|
|
101
|
-
text: 'Edit',
|
|
102
|
-
onClick: () => onEdit(question),
|
|
103
|
-
}}
|
|
104
|
-
secondaryActions={[
|
|
105
|
-
{
|
|
106
|
-
text: question.isActive ? 'Deactivate' : 'Activate',
|
|
107
|
-
icon: question.isActive ? <Icons.Hidden /> : <Icons.Visible />,
|
|
108
|
-
onClick: () => onToggleStatus(question),
|
|
109
|
-
},
|
|
110
|
-
{
|
|
111
|
-
text: 'Delete',
|
|
112
|
-
icon: <Icons.Delete />,
|
|
113
|
-
onClick: () => {
|
|
114
|
-
if (question._id) {
|
|
115
|
-
onDelete(question._id, question.questionText);
|
|
116
|
-
}
|
|
117
|
-
},
|
|
118
|
-
},
|
|
119
|
-
]}
|
|
120
|
-
/>
|
|
121
|
-
),
|
|
122
|
-
width: '120px',
|
|
123
|
-
},
|
|
124
|
-
];
|
|
125
|
-
|
|
126
|
-
return (
|
|
127
|
-
<Table data={questions} columns={columns}>
|
|
128
|
-
<TableToolbar>
|
|
129
|
-
<TableToolbar.ItemGroup position="start">
|
|
130
|
-
<TableToolbar.Item>
|
|
131
|
-
<TableToolbar.Title>Survey Questions</TableToolbar.Title>
|
|
132
|
-
</TableToolbar.Item>
|
|
133
|
-
</TableToolbar.ItemGroup>
|
|
134
|
-
</TableToolbar>
|
|
135
|
-
<Table.Content />
|
|
136
|
-
</Table>
|
|
137
|
-
);
|
|
138
|
-
};
|
|
139
|
-
|
package/dist/examples-apps/survey-manager/src/dashboard/pages/components/SurveyPageLayout.tsx
DELETED
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
import React, { type FC } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
Button,
|
|
4
|
-
Page,
|
|
5
|
-
WixDesignSystemProvider,
|
|
6
|
-
EmptyState,
|
|
7
|
-
} from '@wix/design-system';
|
|
8
|
-
import * as Icons from '@wix/wix-ui-icons-common';
|
|
9
|
-
|
|
10
|
-
import type { SurveyQuestion, QuestionStats, QuestionFormData } from '../types';
|
|
11
|
-
import { SurveyStats } from './SurveyStats';
|
|
12
|
-
import { QuestionModal } from './QuestionModal';
|
|
13
|
-
import { QuestionsTable } from './QuestionsTable';
|
|
14
|
-
|
|
15
|
-
interface SurveyPageLayoutProps {
|
|
16
|
-
questions: SurveyQuestion[];
|
|
17
|
-
questionStats: Record<string, QuestionStats>;
|
|
18
|
-
activeQuestions: number;
|
|
19
|
-
totalResponses: number;
|
|
20
|
-
isModalOpen: boolean;
|
|
21
|
-
editingQuestion: SurveyQuestion | null;
|
|
22
|
-
formData: QuestionFormData;
|
|
23
|
-
onOpenModal: (question?: SurveyQuestion) => void;
|
|
24
|
-
onCloseModal: () => void;
|
|
25
|
-
onFormChange: (data: QuestionFormData) => void;
|
|
26
|
-
onSave: () => void;
|
|
27
|
-
onDelete: (questionId: string, questionText: string) => void;
|
|
28
|
-
onToggleStatus: (question: SurveyQuestion) => void;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export const SurveyPageLayout: FC<SurveyPageLayoutProps> = ({
|
|
32
|
-
questions,
|
|
33
|
-
questionStats,
|
|
34
|
-
activeQuestions,
|
|
35
|
-
totalResponses,
|
|
36
|
-
isModalOpen,
|
|
37
|
-
editingQuestion,
|
|
38
|
-
formData,
|
|
39
|
-
onOpenModal,
|
|
40
|
-
onCloseModal,
|
|
41
|
-
onFormChange,
|
|
42
|
-
onSave,
|
|
43
|
-
onDelete,
|
|
44
|
-
onToggleStatus,
|
|
45
|
-
}) => {
|
|
46
|
-
return (
|
|
47
|
-
<WixDesignSystemProvider features={{ newColorsBranding: true }}>
|
|
48
|
-
<Page height="100vh">
|
|
49
|
-
<Page.Header
|
|
50
|
-
title="Survey Manager"
|
|
51
|
-
subtitle="Create and manage rating survey questions, view aggregated results"
|
|
52
|
-
actionsBar={
|
|
53
|
-
<Button onClick={() => onOpenModal()} prefixIcon={<Icons.Add />}>
|
|
54
|
-
Add Question
|
|
55
|
-
</Button>
|
|
56
|
-
}
|
|
57
|
-
/>
|
|
58
|
-
<Page.Content>
|
|
59
|
-
{questions.length === 0 ? (
|
|
60
|
-
<EmptyState
|
|
61
|
-
title="No survey questions yet"
|
|
62
|
-
subtitle="Create your first rating question to start collecting feedback from visitors"
|
|
63
|
-
skin="page"
|
|
64
|
-
>
|
|
65
|
-
<Button onClick={() => onOpenModal()} prefixIcon={<Icons.Add />}>
|
|
66
|
-
Create First Question
|
|
67
|
-
</Button>
|
|
68
|
-
</EmptyState>
|
|
69
|
-
) : (
|
|
70
|
-
<>
|
|
71
|
-
<SurveyStats
|
|
72
|
-
totalQuestions={questions.length}
|
|
73
|
-
activeQuestions={activeQuestions}
|
|
74
|
-
totalResponses={totalResponses}
|
|
75
|
-
/>
|
|
76
|
-
<QuestionsTable
|
|
77
|
-
questions={questions}
|
|
78
|
-
questionStats={questionStats}
|
|
79
|
-
onEdit={onOpenModal}
|
|
80
|
-
onDelete={onDelete}
|
|
81
|
-
onToggleStatus={onToggleStatus}
|
|
82
|
-
/>
|
|
83
|
-
</>
|
|
84
|
-
)}
|
|
85
|
-
</Page.Content>
|
|
86
|
-
</Page>
|
|
87
|
-
|
|
88
|
-
<QuestionModal
|
|
89
|
-
isOpen={isModalOpen}
|
|
90
|
-
editingQuestion={editingQuestion}
|
|
91
|
-
formData={formData}
|
|
92
|
-
onFormChange={onFormChange}
|
|
93
|
-
onSave={onSave}
|
|
94
|
-
onClose={onCloseModal}
|
|
95
|
-
/>
|
|
96
|
-
</WixDesignSystemProvider>
|
|
97
|
-
);
|
|
98
|
-
};
|
|
99
|
-
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import React, { type FC } from 'react';
|
|
2
|
-
import { Box, Card, Heading, Text } from '@wix/design-system';
|
|
3
|
-
|
|
4
|
-
interface SurveyStatsProps {
|
|
5
|
-
totalQuestions: number;
|
|
6
|
-
activeQuestions: number;
|
|
7
|
-
totalResponses: number;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export const SurveyStats: FC<SurveyStatsProps> = ({
|
|
11
|
-
totalQuestions,
|
|
12
|
-
activeQuestions,
|
|
13
|
-
totalResponses,
|
|
14
|
-
}) => {
|
|
15
|
-
return (
|
|
16
|
-
<Box gap="24px" marginBottom="24px">
|
|
17
|
-
<Card>
|
|
18
|
-
<Card.Content>
|
|
19
|
-
<Box direction="vertical" gap="6px">
|
|
20
|
-
<Heading size="small">Total Questions</Heading>
|
|
21
|
-
<Text size="medium" weight="bold">
|
|
22
|
-
{totalQuestions}
|
|
23
|
-
</Text>
|
|
24
|
-
</Box>
|
|
25
|
-
</Card.Content>
|
|
26
|
-
</Card>
|
|
27
|
-
<Card>
|
|
28
|
-
<Card.Content>
|
|
29
|
-
<Box direction="vertical" gap="6px">
|
|
30
|
-
<Heading size="small">Active Questions</Heading>
|
|
31
|
-
<Text size="medium" weight="bold">
|
|
32
|
-
{activeQuestions}
|
|
33
|
-
</Text>
|
|
34
|
-
</Box>
|
|
35
|
-
</Card.Content>
|
|
36
|
-
</Card>
|
|
37
|
-
<Card>
|
|
38
|
-
<Card.Content>
|
|
39
|
-
<Box direction="vertical" gap="6px">
|
|
40
|
-
<Heading size="small">Total Responses</Heading>
|
|
41
|
-
<Text size="medium" weight="bold">
|
|
42
|
-
{totalResponses}
|
|
43
|
-
</Text>
|
|
44
|
-
</Box>
|
|
45
|
-
</Card.Content>
|
|
46
|
-
</Card>
|
|
47
|
-
</Box>
|
|
48
|
-
);
|
|
49
|
-
};
|
|
50
|
-
|