Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2020
320
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. renderStateComponents() {
  2.         let toRender = [];
  3.         console.log("[Customize.js] renderStateComponents()]");
  4.  
  5.         for (let i = 0; i < this.props.comp.length; i++) {
  6.             if (this.props.comp[i].type === "Header") {
  7.                 toRender.push(
  8.                     <div>
  9.                         <Header
  10.                             key={i}
  11.                             uniqueId={this.props.comp[i].id}
  12.                             // FIXME: TypeError: Cannot read property 'webCopy' of undefined
  13.                             // customText={this.props.copy[i].webCopy}
  14.                         ></Header>
  15.                         <input
  16.                             key={this.props.comp.length + i}
  17.                             associate={this.props.comp[i].id}
  18.                             onChange={e =>
  19.                                 this.props.addCopy(
  20.                                     e.target.value,
  21.                                     this.props.comp[i].id
  22.                                 )
  23.                             }
  24.                         ></input>
  25.                     </div>
  26.                 );
  27.                 if (this.props.copy.length === 0) {
  28.                     // assigns a unique ID to each piece of copy entered into database
  29.                     this.props.getNewStateVariable(this.props.comp[i].id);
  30.                 }
  31.             } else if (this.props.comp[i].type === "Headline") {
  32.                 toRender.push(
  33.                     <div>
  34.                         <Headline
  35.                             key={i}
  36.                             uniqueId={this.props.comp[i].id}
  37.                             moveUp={() =>
  38.                                 this.moveUp([
  39.                                     this.props.comp[i].type,
  40.                                     this.props.comp[i].id
  41.                                 ])
  42.                             }
  43.                             moveDown={() =>
  44.                                 this.moveDown([
  45.                                     this.props.comp[i].type,
  46.                                     this.props.comp[i].id
  47.                                 ])
  48.                             }
  49.                             del={() =>
  50.                                 this.deleteComponent([
  51.                                     this.props.comp[i].type,
  52.                                     this.props.comp[i].id
  53.                                 ])
  54.                             }
  55.                         ></Headline>
  56.                         <input
  57.                             key={this.props.comp.length + i}
  58.                             associate={this.props.comp[i].id}
  59.                         ></input>
  60.                     </div>
  61.                 );
  62.                 if (this.props.copy.length === 0) {
  63.                     this.props.getNewStateVariable(this.props.comp[i].id);
  64.                 }
  65.             } else if (this.props.comp[i].type === "Text Area") {
  66.                 toRender.push(
  67.                     <div>
  68.                         <TextArea
  69.                             key={i}
  70.                             uniqueId={this.props.comp[i].id}
  71.                             moveUp={() =>
  72.                                 this.moveUp([
  73.                                     this.props.comp[i].type,
  74.                                     this.props.comp[i].id
  75.                                 ])
  76.                             }
  77.                             moveDown={() =>
  78.                                 this.moveDown([
  79.                                     this.props.comp[i].type,
  80.                                     this.props.comp[i].id
  81.                                 ])
  82.                             }
  83.                             del={() =>
  84.                                 this.deleteComponent([
  85.                                     this.props.comp[i].type,
  86.                                     this.props.comp[i].id
  87.                                 ])
  88.                             }
  89.                         ></TextArea>
  90.                         <input
  91.                             key={this.props.comp.length + i}
  92.                             associate={this.props.comp[i].id}
  93.                         ></input>
  94.                     </div>
  95.                 );
  96.                 if (this.props.copy.length === 0) {
  97.                     this.props.getNewStateVariable(this.props.comp[i].id);
  98.                 }
  99.             } else if (this.props.comp[i].type === "Image") {
  100.                 toRender.push(
  101.                     <div>
  102.                         <Image
  103.                             key={i}
  104.                             uniqueId={this.props.comp[i].id}
  105.                             moveUp={() =>
  106.                                 this.moveUp([
  107.                                     this.props.comp[i].type,
  108.                                     this.props.comp[i].id
  109.                                 ])
  110.                             }
  111.                             moveDown={() =>
  112.                                 this.moveDown([
  113.                                     this.props.comp[i].type,
  114.                                     this.props.comp[i].id
  115.                                 ])
  116.                             }
  117.                             del={() =>
  118.                                 this.deleteComponent([
  119.                                     this.props.comp[i].type,
  120.                                     this.props.comp[i].id
  121.                                 ])
  122.                             }
  123.                         ></Image>
  124.                         <input
  125.                             key={this.props.comp.length + i}
  126.                             associate={this.props.comp[i].id}
  127.                         ></input>
  128.                     </div>
  129.                 );
  130.                 if (this.props.copy.length === 0) {
  131.                     this.props.getNewStateVariable(this.props.comp[i].id);
  132.                 }
  133.             } else if (this.props.comp[i].type === "Email Field") {
  134.                 toRender.push(
  135.                     <div>
  136.                         <EmailField
  137.                             key={i}
  138.                             uniqueId={this.props.comp[i].id}
  139.                             moveUp={() =>
  140.                                 this.moveUp([
  141.                                     this.props.comp[i].type,
  142.                                     this.props.comp[i].id
  143.                                 ])
  144.                             }
  145.                             moveDown={() =>
  146.                                 this.moveDown([
  147.                                     this.props.comp[i].type,
  148.                                     this.props.comp[i].id
  149.                                 ])
  150.                             }
  151.                             del={() =>
  152.                                 this.deleteComponent([
  153.                                     this.props.comp[i].type,
  154.                                     this.props.comp[i].id
  155.                                 ])
  156.                             }
  157.                         ></EmailField>
  158.                         <input
  159.                             key={this.props.comp.length + i}
  160.                             associate={this.props.comp[i].id}
  161.                         ></input>
  162.                     </div>
  163.                 );
  164.                 if (this.props.copy.length === 0) {
  165.                     this.props.getNewStateVariable(this.props.comp[i].id);
  166.                 }
  167.             } else if (this.props.comp[i].type === "Footer") {
  168.                 toRender.push(
  169.                     <div>
  170.                         <Footer
  171.                             key={i}
  172.                             uniqueId={this.props.comp[i].id}
  173.                             moveUp={() =>
  174.                                 this.moveUp([
  175.                                     this.props.comp[i].type,
  176.                                     this.props.comp[i].id
  177.                                 ])
  178.                             }
  179.                             moveDown={() =>
  180.                                 this.moveDown([
  181.                                     this.props.comp[i].type,
  182.                                     this.props.comp[i].id
  183.                                 ])
  184.                             }
  185.                             del={() =>
  186.                                 this.deleteComponent([
  187.                                     this.props.comp[i].type,
  188.                                     this.props.comp[i].id
  189.                                 ])
  190.                             }
  191.                         ></Footer>
  192.                         <input
  193.                             key={this.props.comp.length + i}
  194.                             associate={this.props.comp[i].id}
  195.                         ></input>
  196.                     </div>
  197.                 );
  198.                 if (this.props.copy.length === 0) {
  199.                     this.props.getNewStateVariable(this.props.comp[i].id);
  200.                 }
  201.             }
  202.         }
  203.  
  204.         return toRender;
  205.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement