Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Result improvement #99

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
96 changes: 80 additions & 16 deletions client/src/components/Result.jsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,86 @@
import React from 'react';
import { BsFillCheckCircleFill } from 'react-icons/bs';
import { BsFillCheckCircleFill, BsFillExclamationCircleFill, BsFillExclamationTriangleFill } from 'react-icons/bs'; //get logos from here

function Result() {
function Result(status, title, intro) {
let comp;

if ( { status } === "success" ) {
comp = (
<div style={{
width: '100%',
height: '100%',
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
}}
>
<BsFillCheckCircleFill
style={{
fontSize: '72px',
color: '#52c41a',
}}
/>
</div>
)
} else if ( { status } === "error" ) {
comp = (
<div style={{
width: '100%',
height: '100%',
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
}}
>
<BsFillExclamationTriangleFill
style={{
fontSize: '72px',
color: '#52c41a',
}}
/>
</div>
)
} else if ( { status } === "info" ) {
comp = (
<div style={{
width: '100%',
height: '100%',
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
}}
>
<BsFillExclamationCircleFill
style={{
fontSize: '72px',
color: '#52c41a',
}}
/>
</div>
)
} else if ( { status } === "warning" ) {
comp = (
<div style={{
width: '100%',
height: '100%',
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
}}
>
<BsFillExclamationCircleFill
style={{
fontSize: '72px',
color: '#52c41a',
}}
/>
</div>
)
}

return (
<div style={{
width: '100%',
height: '100%',
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
}}
>
<BsFillCheckCircleFill
style={{
fontSize: '72px',
color: '#52c41a',
}}
/>
<div>
{ status, title, intro }
</div>
);
}
Expand Down
107 changes: 1 addition & 106 deletions client/src/pages/Survey.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -112,113 +112,8 @@ class Survey extends Component {
}

render() {
const {
currentPage, isFetching, surveyLength, isStart, surveyDefinition, isComplete,
} = this.state;
if (isFetching) {
return null;
}
if (currentPage === this.getSurvey().activities.length) {
localStorage.clear();
if (!isComplete) {
submitAnswer(this.getSurveyId(), this.state.response)
.then(() => {
console.log('Submitted');
this.setState({
isComplete: true,
});
})
.catch((err) => console.log(err));
}
return (
<Suspense fallback={<Loading />}>
<Result
status="success"
title="Survey Complete"
subTitle="Thank you for participating!"
/>
</Suspense>
);
}

if (!isStart) {
return (
<Suspense fallback={<Loading />}>
<IntroRender
title={surveyDefinition.title}
intro={surveyDefinition.intro}
onFinish={this.start}
/>
</Suspense>
);
}

const currentActivity = this.getActivity();
const currentResponse = this.getResponse(currentActivity.id);

if (currentActivity.type === 'form') {
return (
<Suspense fallback={<Loading />}>
<PageRender
id={currentActivity.id}
current={currentPage + 1}
length={surveyLength}
title={currentActivity.title}
intro={currentActivity.intro}
progress
>
<FormRender
questions={currentActivity.questions}
onChange={this.updateResponse}
values={currentResponse}
onFinish={this.next}
/>
</PageRender>
</Suspense>
);
}
if (currentActivity.type === 'map') {
return (
<Suspense fallback={<Loading />}>
<MapPage
key="MapPage"
activity={currentActivity}
onChange={this.updateResponse}
onFinish={this.next}
values={currentResponse}
current={currentPage + 1}
length={surveyLength}
progress
/>
</Suspense>
);
}
if (currentActivity.type === 'end') {
return (
<Suspense fallback={<Loading />}>
<EndRender
id={currentActivity.id}
current={currentPage + 1}
length={surveyLength}
title={currentActivity.title}
intro={currentActivity.intro}
questions={currentActivity.questions}
onChange={this.updateResponse}
values={currentResponse}
onFinish={this.next}
progress
/>
</Suspense>
);
}
return (
<Suspense fallback={<Loading />}>
<Result
status="warning"
title="Activity type not found"
subTitle="The specified activity type does not exist."
/>
</Suspense>
Result("warning", "test1", "test2")
);
}
}
Expand Down