Skip to content

Commit 59fb879

Browse files
committed
after rebase, delete radio type, add get session when completing survey
1 parent 368fe41 commit 59fb879

File tree

6 files changed

+27
-29
lines changed

6 files changed

+27
-29
lines changed

src/main/java/com/pwr/students/domain/AnswerType.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,4 @@
33
public enum AnswerType {
44
SLIDER,
55
TEXT,
6-
RADIO,
76
}
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
id;category;answer_type;question_content;is_required;jhi_order;survey_id
22
1;attitude;TEXT;including Networked;true;44743;1
3-
2;Integration Berkshire up;RADIO;whatever question content;true;48233;2
3+
2;Integration Berkshire up;TEXT;whatever question content;true;48233;2
44
3;Jazz;SLIDER;whatever question content;true;75409;3
55
4;sensor Phased;TEXT;orchestration Palladium;true;33686;4
66
5;Account provided;TEXT;VanXXXXXXXXXXXXX;true;91402;5
77
6;strategic lame;TEXT;lens Principal CSS;true;73489;6
88
7;cyan Denver ferociously;SLIDER;to SouthXXXXXXXX;true;11450;7
99
8;Thorium Bowie;SLIDER;Soap RubberXXXXX;true;17469;8
10-
9;Forward;RADIO;Southeast Bacon Copernicium;false;26648;9
11-
10;Czech New;RADIO;but Brakus South;true;60643;10
10+
9;Forward;SLIDER;Southeast Bacon Copernicium;false;26648;9
11+
10;Czech New;SLIDER;but Brakus South;true;60643;10

src/main/webapp/app/modules/surveyCompletion/survey-page.tsx

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@ import axios from 'axios';
44
import './survey-page.scss';
55
import { BiCommentDetail } from 'react-icons/bi';
66
import Slider from 'react-input-slider';
7-
import { useAppDispatch } from 'app/config/store';
7+
import { useAppDispatch, useAppSelector } from 'app/config/store';
88
import { createEntity, getEntities } from 'app/entities/answer/answer.reducer';
99
import { IAnswer } from 'app/shared/model/answer.model';
10-
import { partialUpdateEntity, updateEntity } from 'app/entities/survey-assigment/survey-assigment.reducer';
10+
import { partialUpdateEntity } from 'app/entities/survey-assigment/survey-assigment.reducer';
1111
import { ISurveyAssigment } from 'app/shared/model/survey-assigment.model';
12+
import { getSession } from 'app/shared/reducers/authentication';
13+
import { reset } from 'app/modules/account/settings/settings.reducer';
1214

1315
const SurveyPage = () => {
1416
const navigate = useNavigate();
@@ -21,6 +23,15 @@ const SurveyPage = () => {
2123
const [surveyAssignmentId, setSurveyAssignmentId] = useState(null);
2224

2325
const dispatch = useAppDispatch();
26+
const user = useAppSelector(state => state.authentication.account);
27+
28+
// Fetch the user information during component initialization
29+
useEffect(() => {
30+
dispatch(getSession());
31+
return () => {
32+
dispatch(reset());
33+
};
34+
}, []);
2435

2536
useEffect(() => {
2637
axios
@@ -89,19 +100,6 @@ const SurveyPage = () => {
89100
);
90101
}
91102

92-
if (currentQuestion.answerType === 'RADIO') {
93-
return (
94-
<div>
95-
{currentQuestion.radioOptions.map((option, index) => (
96-
<label key={index}>
97-
<input type="radio" value={option} checked={answers[currentQuestionIndex] === option} onChange={handleAnswerChange} />
98-
{option}
99-
</label>
100-
))}
101-
</div>
102-
);
103-
}
104-
105103
if (currentQuestion.answerType === 'TEXT') {
106104
return (
107105
<div>
@@ -129,6 +127,7 @@ const SurveyPage = () => {
129127
answer,
130128
comment: comments[index] || '',
131129
question: survey.questions[index],
130+
user: user,
132131
}));
133132

134133
try {
@@ -186,10 +185,10 @@ const SurveyPage = () => {
186185
setIsCommentBoxVisible(prevState => !prevState);
187186
};
188187

189-
const handleCommentSubmit = () => {
190-
setIsCommentBoxVisible(prevState => !prevState);
191-
// TODO i guess we need to save the comment somewhere to save while submitting the answers
192-
};
188+
// const handleCommentSubmit = () => {
189+
// setIsCommentBoxVisible(prevState => !prevState);
190+
// // TODO i guess we need to save the comment somewhere to save while submitting the answers
191+
// };
193192

194193
if (!survey) {
195194
return <div>Loading survey...</div>;
@@ -229,9 +228,9 @@ const SurveyPage = () => {
229228
value={comments[currentQuestionIndex] || ''}
230229
onChange={handleCommentChange}
231230
/>
232-
<button className="comment-submit" onClick={handleCommentSubmit}>
233-
Submit
234-
</button>
231+
{/*<button className="comment-submit" onClick={handleCommentSubmit}>*/}
232+
{/* Submit*/}
233+
{/*</button>*/}
235234
</div>
236235
)}
237236
<div className="buttons">

src/main/webapp/app/modules/userSurveysDashboard/userSurveysDashboard.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ const UserSurveysDashboard = () => {
9797
const navigate = useNavigate();
9898

9999
const handleSurvey = () => {
100-
navigate(`/survey/${survey.id}`);
100+
navigate(`/complete-survey/${survey.id}`);
101101
};
102102

103103
const openModal = () => {

src/main/webapp/app/routes.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ const AppRoutes = () => {
5656
}
5757
/>
5858
<Route
59-
path="/survey/:surveyId"
59+
path="/complete-survey/:surveyId"
6060
element={
6161
<PrivateRoute hasAnyAuthorities={[AUTHORITIES.ADMIN, AUTHORITIES.USER]}>
6262
<SurveyPage />

src/test/java/com/pwr/students/web/rest/QuestionResourceIT.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class QuestionResourceIT {
4444
private static final String UPDATED_CATEGORY = "BBBBBBBBBB";
4545

4646
private static final AnswerType DEFAULT_ANSWER_TYPE = AnswerType.TEXT;
47-
private static final AnswerType UPDATED_ANSWER_TYPE = AnswerType.RADIO;
47+
private static final AnswerType UPDATED_ANSWER_TYPE = AnswerType.SLIDER;
4848

4949
private static final String DEFAULT_QUESTION_CONTENT = "AAAAAAAAAAAAAAAA";
5050
private static final String UPDATED_QUESTION_CONTENT = "BBBBBBBBBBBBBBBB";

0 commit comments

Comments
 (0)