Skip to content
This repository has been archived by the owner on May 14, 2021. It is now read-only.

Victor/eco 1248/new branding ui #22

Open
wants to merge 12 commits into
base: master
Choose a base branch
from

Conversation

Doc999tor
Copy link
Contributor

No description provided.

@Doc999tor Doc999tor requested a review from a team May 6, 2019 08:43
Copy link
Contributor

@doodyparizada doodyparizada left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some comments

// },
// {
// type: PageType.SuccessBasedThankYou,
// },
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hope these are tests

@@ -0,0 +1,38 @@
var offer_contents = (await OfferContent.find())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why plain js?

@@ -77,6 +87,6 @@
.diamond-r-1
left: 84vw;
bottom: 13.3vw;
width: 8.2vw
width: 8.2vw */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

delete commented out code

Copy link
Contributor

@doodyparizada doodyparizada left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did this pass a linter

for (var i = 0; i < offer_contents.length; i++) {
var oc = offer_contents[i];
var pageTypeNum = 0;
for (const i = 0; i < offer_contents.length; i++) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't it be let i = 0?

for (var i = 0; i < offer_contents.length; i++) {
var oc = offer_contents[i];
var pageTypeNum = 3;
for (const i = 0; i < offer_contents.length; i++) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

const allData: any = Object.assign({}, this.state.data, answerData); // todo pollyfill Object.assign
const newPageIndex = this.state.currentPage + 1;
this.setState(Object.assign(this.state, {
data: Object.assign(this.state.data, answerData),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. break this into two lines, nested Assign statements are hard to read.
  2. you need to assign to an empty literal and not to this.state, like so:
    this.setState(Object.assign({}, this.state, {...

bridge.submitResult(allData);
if (Object.keys(this.state.data)) {
console.log("submit " + JSON.stringify(this.state.data));
bridge.submitResult(this.state.data);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't make sense that this is here. This method should only navigate not submit. Move it back into onPageCompleteHandler where it belongs.

const isComplete = this.state.currentPage === (this.state.pages.length - 1);
const isShouldExit = newPageIndex < 0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Doc999tor How does it get to this state?

bridge.close();
}
return;
}

this.setState({
if (isShouldExit) {
console.log("exit " + JSON.stringify(this.state.data));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need this in production?

<div className="header-controls">
<button className="back-nav" onClick={this.props.navigateBack}><img src={ getImageUrl('ic-back') } /></button>
<span></span>
<div className={"pageProgress"}>{currentPage}/{totalQuestionPages}</div>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

className="pageProgress"

}

await updatePolls();
await updateQuizzes();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

newline

@@ -0,0 +1,38 @@
const offer_contents = (await OfferContent.find())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a comment explaining what this file does and how to use it.

const offer_contents = (await OfferContent.find())

async function updatePolls () {
for (let i = 0; i < offer_contents.length; i++) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use for...of

if (page.type !== pageTypeNum) { return false; }
page.rewardText = page.title.replace(/ \${amount}.*/, '');
page.rewardValue = '${amount}';
page.title = '';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is title still used anywhere?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Every poll/quiz in test has title. In some of them it's empty string. So I put here an empty string as well

const content = JSON.parse(oc.content);
content.pages.forEach(page => {
if (page.type !== pageTypeNum) { return false; }
page.rewardText = page.title.replace(/ \${amount}.*/, '');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is the only difference between quiz and poll I would just do an if statement here instead of code duplication.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ran the code separately for more caution reasons, polls and after them quizzes.
I can execute the function with parameters: pageTypeNum and contentType, but it seemed to much ifs

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants