Skip to content

Commit f80a94a

Browse files
committed
refactor
1 parent a17c8c4 commit f80a94a

File tree

8 files changed

+23
-25
lines changed

8 files changed

+23
-25
lines changed

public/index.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ function createElement(options = {}) {
242242
}
243243

244244
function createGenericAssessment() {
245-
Traitify.http.authKey = "admin-secret";
245+
Traitify.http.authKey = "ca7bae5a3e0840dc8e148ab22eac6e01";
246246
const query = Traitify.GraphQL.generic.create;
247247
const variables = {
248248
surveyID: cache.get("surveyID"),
@@ -389,9 +389,9 @@ function setupDom() {
389389
options: [
390390
{text: "Benchmark", value: "benchmark"},
391391
{text: "Cognitive", value: "cognitive"},
392+
{text: "Generic", value: "generic"},
392393
{text: "Order", value: "order"},
393-
{text: "Personality", value: "personality"},
394-
{text: "Generic", value: "generic"}
394+
{text: "Personality", value: "personality"}
395395
],
396396
text: "Survey Type:"
397397
}));
@@ -452,7 +452,7 @@ function setupCognitive() {
452452
}
453453

454454
function setupGeneric() {
455-
Traitify.http.authKey = "admin-secret";
455+
Traitify.http.authKey = "ca7bae5a3e0840dc8e148ab22eac6e01";
456456
const query = Traitify.GraphQL.generic.surveys;
457457
const variables = {localeKey: cache.get("locale")};
458458

@@ -479,8 +479,8 @@ function setupTraitify() {
479479
const environment = cache.get("environment");
480480

481481
if(environment === "staging") {
482-
// Traitify.http.host = "https://api.stag.awse.traitify.com";
483-
Traitify.http.host = "http://localhost:4000/";
482+
Traitify.http.host = "https://api.stag.awse.traitify.com";
483+
// Traitify.http.host = "http://localhost:4000/";
484484
} else {
485485
Traitify.http.host = "https://api.traitify.com";
486486
}
@@ -516,6 +516,6 @@ function onSurveyTypeChange(e) {
516516

517517
setupTraitify();
518518
setupDom();
519-
// setupCognitive();
519+
setupCognitive();
520520
setupGeneric();
521521
createWidget();

src/components/common/modal/index.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ import Icon from "components/common/icon";
44
import useTranslate from "lib/hooks/use-translate";
55
import style from "./style.scss";
66

7-
export default function Modal({children, onClose, title, containerClass = ""}) {
7+
export default function Modal({children, containerClass = null, onClose, title}) {
88
const translate = useTranslate();
9-
const sectionClass = [style.modalContainer, containerClass].join(" ");
9+
const sectionClass = [style.modalContainer, containerClass].filter(Boolean).join(" ");
1010
return (
1111
<div className={`${style.modal} ${style.container}`}>
1212
<section className={sectionClass}>
@@ -35,7 +35,7 @@ export default function Modal({children, onClose, title, containerClass = ""}) {
3535

3636
Modal.propTypes = {
3737
children: PropTypes.node.isRequired,
38+
containerClass: PropTypes.string,
3839
onClose: PropTypes.func.isRequired,
39-
title: PropTypes.string.isRequired,
40-
containerClass: PropTypes.string
40+
title: PropTypes.string.isRequired
4141
};

src/components/survey/generic/container.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,12 @@ import style from "./style.scss";
33

44
export default function Container({children, progress}) {
55
return (
6-
<div className={`${style.container}`}>
7-
{progress < 100
8-
&& (
6+
<div className={style.container}>
7+
{progress < 100 && (
98
<div className={style.progressBar}>
109
<div className={style.progress} style={{width: `${progress}%`}} />
1110
</div>
12-
)}
11+
)}
1312
{children}
1413
</div>
1514
);

src/components/survey/generic/index.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,15 +78,14 @@ export default function Generic() {
7878

7979
return (
8080
<Container {...props}>
81-
{currentQuestionSet
82-
&& (
81+
{currentQuestionSet && (
8382
<QuestionSet
8483
key={questionSetIndex}
8584
questionSet={currentQuestionSet}
8685
updateAnswer={updateAnswer}
8786
next={next}
8887
/>
89-
)}
88+
)}
9089

9190
{questionSetIndex > 0 && (
9291
<button onClick={back} type="button" className={style.back}>

src/components/survey/generic/question-set.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import {useEffect, useState} from "react";
33
import Responses from "./responses";
44
import style from "./style.scss";
55

6-
export default function QuestionSet({questionSet, updateAnswer = null, next = null}) {
6+
export default function QuestionSet({questionSet, next, updateAnswer}) {
77
const questionSetClass = [style.questionSet].join(" ");
88
const [selectedOptions, setSelectedOptions] = useState([]);
99
const setFinished = questionSet.questions.length === selectedOptions.length;
@@ -43,6 +43,6 @@ QuestionSet.propTypes = {
4343
})).isRequired,
4444
setImage: PropTypes.string.isRequired
4545
}).isRequired,
46-
updateAnswer: PropTypes.func,
47-
next: PropTypes.func
46+
next: PropTypes.func.isRequired,
47+
updateAnswer: PropTypes.func.isRequired
4848
};

src/components/survey/generic/responses.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import PropTypes from "prop-types";
22
import {useState} from "react";
33
import style from "./style.scss";
44

5-
export default function Responses({responseOptions = [], updateAnswer = null}) {
5+
export default function Responses({responseOptions = [], updateAnswer}) {
66
const buttonClass = ["traitify--response-button", style.response].join(" ");
77
const buttonWidth = (text) => (text.length > 20 ? "100%" : "auto");
88
const [activeButton, setActiveButton] = useState(null);
@@ -35,5 +35,5 @@ Responses.propTypes = {
3535
text: PropTypes.string.isRequired
3636
})
3737
).isRequired,
38-
updateAnswer: PropTypes.func
38+
updateAnswer: PropTypes.func.isRequired
3939
};

src/components/survey/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ export default function Survey() {
1010
if(!active) { return <Status />; }
1111
if(active.surveyType === "cognitive") { return <Cognitive />; }
1212
if(active.surveyType === "external") { return <Status />; }
13-
if(active.surveyType === "personality") { return <Personality />; }
1413
if(active.surveyType === "generic") { return <Generic />; }
14+
if(active.surveyType === "personality") { return <Personality />; }
1515

1616
return null;
1717
}

src/lib/recoil/assessment.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,8 @@ export const assessmentQuery = selectorFamily({
138138
get: ({id, surveyType}) => async({get}) => {
139139
if(surveyType === "cognitive") { return get(cognitiveAssessmentQuery(id)); }
140140
if(surveyType === "external") { return get(externalAssessmentQuery(id)); }
141-
if(surveyType === "personality") { return get(personalityAssessmentQuery(id)); }
142141
if(surveyType === "generic") { return get(genericAssessmentQuery(id)); }
142+
if(surveyType === "personality") { return get(personalityAssessmentQuery(id)); }
143143

144144
return null;
145145
},

0 commit comments

Comments
 (0)