File tree Expand file tree Collapse file tree 2 files changed +10
-1
lines changed
src/features/surveys/features/SurveyCreator/managers/createSurveyManager Expand file tree Collapse file tree 2 files changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -8,7 +8,6 @@ import { PropsWithChildren } from 'react';
88jest . mock ( 'next/router' , ( ) => require ( 'next-router-mock' ) ) ;
99
1010const NEW_QUESTION_TITLE = 'new question' ;
11-
1211const NEW_SURVEY_TITLE = 'new survey title' ;
1312
1413const setUp = ( ) => {
@@ -27,6 +26,7 @@ const setUp = () => {
2726 } ) ;
2827
2928 act ( ( ) => {
29+ result . current . removeAllQuestions ( ) ;
3030 result . current . addQuestion ( {
3131 draftId : v4 ( ) ,
3232 type : 'INPUT' ,
Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ import { CreateEditSurveyPayload } from 'pages/api/survey';
1414import { QuestionWithLogicPath } from 'types/QuestionWithLogicPath' ;
1515import { useApplicationContext } from 'features/application/context' ;
1616import { Page } from 'features/application/types/Page' ;
17+ import { USER_FEEDBACK_TEMPLATE } from 'features/surveys/features/SurveyCreator/constants/templatesData/UserFeedbackTemplate' ;
1718
1819export interface DraftQuestion {
1920 draftId : string ;
@@ -100,6 +101,9 @@ export const useCreateSurveyManager = (initialData?: SurveyWithQuestions) => {
100101 if ( title !== undefined ) setTitle ( title ) ;
101102 if ( questions !== undefined ) setQuestions ( questions ) ;
102103 if ( surveyOptions !== undefined ) setSurveyOptions ( surveyOptions ) ;
104+ } else {
105+ setTitle ( USER_FEEDBACK_TEMPLATE . title ) ;
106+ setQuestions ( USER_FEEDBACK_TEMPLATE . questions ) ;
103107 }
104108 setIsLoaded ( true ) ;
105109 } else if ( isEditMode ) {
@@ -124,6 +128,10 @@ export const useCreateSurveyManager = (initialData?: SurveyWithQuestions) => {
124128 setError ( '' ) ;
125129 } ;
126130
131+ const removeAllQuestions = ( ) => {
132+ setQuestions ( [ ] ) ;
133+ } ;
134+
127135 const removeQuestion = ( index : number ) => {
128136 setQuestions ( ( oldQuestions ) => {
129137 oldQuestions . forEach ( ( question ) => {
@@ -524,6 +532,7 @@ export const useCreateSurveyManager = (initialData?: SurveyWithQuestions) => {
524532 updateLogicPath,
525533 expandAdvancedSettings,
526534 selectTemplate,
535+ removeAllQuestions,
527536 } ;
528537} ;
529538
You can’t perform that action at this time.
0 commit comments