Skip to content

Commit a2af250

Browse files
authored
Feature/Template picker
1 parent c95c545 commit a2af250

26 files changed

Lines changed: 519 additions & 151 deletions

File tree

.env.example

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ GOOGLE_SECRET=
1616
NEXT_PUBLIC_PROFILE_SETTINGS=
1717
NEXT_PUBLIC_REMOVE_ACCOUNT=
1818
NEXT_PUBLIC_ALLOW_MULTIPLE_ANSWERS=
19-
NEXT_PUBLIC_INDIVIDUAL_RESULTS=
2019

2120

2221
# Others

cypress/e2e/answerSurvey.cy.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@ describe('Answering survey tests', () => {
1111

1212
cy.get('[data-test-id="create-survey"]').click();
1313
cy.url().should('include', '/survey/create');
14+
cy.get('[data-test-id="start-from-scratch-field"]').click();
15+
cy.get('[data-test-id="start-from-scratch-button"]').click();
16+
cy.get('[data-test-id="add-question-button"]').click();
17+
cy.get('[data-test-id="emoji-question-button"]').click();
18+
cy.get('[data-test-id="add-question-button"]').click();
19+
cy.get('[data-test-id="input-question-button"]').click();
20+
1421
cy.get('input[name="survey-title"]').clear().type(surveyTitle);
1522

1623
cy.get('input[data-test-id="question-input-0"]')

cypress/e2e/createSurvey.cy.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,13 @@ describe('Creating survey tests', () => {
99
cy.get('[data-test-id="create-survey"]').click();
1010
cy.url().should('include', '/survey/create');
1111

12+
cy.get('[data-test-id="start-from-scratch-field"]').click();
13+
cy.get('[data-test-id="start-from-scratch-button"]').click();
14+
cy.get('[data-test-id="add-question-button"]').click();
15+
cy.get('[data-test-id="emoji-question-button"]').click();
16+
cy.get('[data-test-id="add-question-button"]').click();
17+
cy.get('[data-test-id="input-question-button"]').click();
18+
1219
cy.get('input[name="survey-title"]').clear().type(surveyTitle);
1320

1421
cy.get('input[data-test-id="question-input-0"]')

next-env.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
/// <reference types="next/image-types/global" />
33

44
// NOTE: This file should not be edited
5-
// see https://nextjs.org/docs/basic-features/typescript for more information.
5+
// see https://nextjs.org/docs/pages/building-your-application/configuring/typescript for more information.

src/features/surveys/components/ShareSurveryModal/ShareSurveyModal.tsx

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -33,21 +33,17 @@ export default function ShareSurveyModal({
3333
title={t('shareSurveyModal.title')}
3434
content={
3535
<>
36-
<div className="mt-4 flex justify-center">
37-
<div className="w-1/2">
38-
<QRCode
39-
size={256}
40-
style={{ height: 'auto', maxWidth: '100%', width: '100%' }}
41-
value={link}
42-
/>
43-
</div>
36+
<div className="mx-auto my-4 w-1/3">
37+
<QRCode
38+
size={256}
39+
style={{ height: 'auto', maxWidth: '100%', width: '100%' }}
40+
value={link}
41+
/>
4442
</div>
4543

46-
<div className="mt-4">
47-
<span className="scrollbar-hide block w-full select-all overflow-x-auto whitespace-nowrap rounded-md border border-gray-300 px-3 py-2 text-center text-sm focus:outline-none">
48-
{link}
49-
</span>
50-
</div>
44+
<span className="scrollbar-hide block w-full select-all overflow-x-auto whitespace-nowrap rounded-md border border-gray-300 px-3 py-2 text-center text-sm focus:outline-none">
45+
{link}
46+
</span>
5147

5248
<div className="mt-4 flex flex-col-reverse justify-between gap-2 sm:flex-row">
5349
<Button

src/features/surveys/features/SurveyCreator/SurveyCreator.tsx

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,23 @@
11
import React from 'react';
2-
import TitleAndConfigSection from 'features/surveys/features/SurveyCreator/components/TitleAndConfigSection/TitleAndConfigSection';
3-
import QuestionsSection from 'features/surveys/features/SurveyCreator/components/QuestionsSection/QuestionsSection';
4-
import ActionButtons from 'features/surveys/features/SurveyCreator/components/ActionButtons/ActionButtons';
52
import clsx from 'clsx';
63
import { usePreviewPanelContext } from 'features/surveys/features/SurveyCreator/managers/previewPanelManager/context';
74
import PreviewPanel from 'features/surveys/features/SurveyCreator/components/PreviewPanel/PreviewPanel';
5+
import { useSurveyCreatorContext } from 'features/surveys/features/SurveyCreator/managers/createSurveyManager/context';
6+
7+
import dynamic from 'next/dynamic';
8+
import CreatorContent from 'features/surveys/features/SurveyCreator/components/CreatorContent/CreatorContent';
9+
10+
const Templates = dynamic(
11+
() =>
12+
import(
13+
'features/surveys/features/SurveyCreator/components/Templates/Templates'
14+
),
15+
{ ssr: false }
16+
);
817

918
export default function SurveyCreator() {
1019
const { isPanelOpened } = usePreviewPanelContext();
20+
const { isEditMode, isTemplatePicked } = useSurveyCreatorContext();
1121

1222
return (
1323
<>
@@ -18,9 +28,11 @@ export default function SurveyCreator() {
1828
)}
1929
>
2030
<div className="mx-auto max-w-[58rem] px-4 xl:px-10">
21-
<TitleAndConfigSection />
22-
<QuestionsSection />
23-
<ActionButtons />
31+
{!isTemplatePicked && !isEditMode ? (
32+
<Templates />
33+
) : (
34+
<CreatorContent />
35+
)}
2436
</div>
2537
</div>
2638

src/features/surveys/features/SurveyCreator/components/AddQuestionButton/AddQuestionButton.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export const AddQuestionButton = ({ onClick }: AddQuestionButtonProps) => {
1616
onClick={openModal}
1717
sizeType={ButtonSize.FULL}
1818
className="h-[50px]"
19+
data-test-id="add-question-button"
1920
icon={<PlusCircleIcon className="h-5 w-5" />}
2021
>
2122
Add new block
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import React from 'react';
2+
import ActionButtons from 'features/surveys/features/SurveyCreator/components/ActionButtons/ActionButtons';
3+
import QuestionsSection from 'features/surveys/features/SurveyCreator/components/QuestionsSection/QuestionsSection';
4+
import TitleAndConfigSection from 'features/surveys/features/SurveyCreator/components/TitleAndConfigSection/TitleAndConfigSection';
5+
import withAnimation from 'shared/HOC/withAnimation';
6+
7+
function CreatorContent() {
8+
return (
9+
<>
10+
<TitleAndConfigSection />
11+
<QuestionsSection />
12+
<ActionButtons />
13+
</>
14+
);
15+
}
16+
17+
export default withAnimation(CreatorContent);

src/features/surveys/features/SurveyCreator/components/NewQuestionModal/NewQuestionModal.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,21 +86,25 @@ export default function NewQuestionModal({
8686
onClick={addEmojiQuestion}
8787
icon={<EmojiIcon />}
8888
text="Emoji"
89+
testSelector="emoji-question-button"
8990
/>
9091
<NewQuestionModalButton
9192
onClick={addInputQuestion}
9293
icon={<InputIcon />}
9394
text="Text"
95+
testSelector="input-question-button"
9496
/>
9597
<NewQuestionModalButton
9698
onClick={addChoiceQuestion}
9799
icon={<ChoiceIcon />}
98100
text="Choice"
101+
test-selector="choice-question-button"
99102
/>
100103
<NewQuestionModalButton
101104
onClick={addRateQuestion}
102105
icon={<RateIcon />}
103106
text="Rate"
107+
test-selector="rate-question-button"
104108
/>
105109
</div>
106110
}

src/features/surveys/features/SurveyCreator/components/NewQuestionModal/components/NewQuestionModalButton.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,20 @@ interface NewQuestionModalButtonProps {
55
onClick: () => void;
66
icon: React.ReactNode;
77
text: string;
8+
testSelector?: string;
89
}
910

1011
export default function NewQuestionModalButton({
1112
onClick,
1213
icon,
1314
text,
15+
testSelector,
1416
}: NewQuestionModalButtonProps) {
1517
return (
1618
<Button
1719
onClick={onClick}
1820
className="flex flex-col p-4 text-center sm:w-[160px]"
21+
data-test-id={testSelector}
1922
>
2023
<div className="mb-[2px] w-[18px]">{icon}</div>
2124
{text}

0 commit comments

Comments
 (0)