text: import React, { useState } from "react"
  import { graphql } from "gatsby"
  import { Helmet } from "react-helmet"
  
  import Layout from "../../../components/layout"
  import Header from "../../../components/header"
  import SEO from "../../../components/seo"
  
  import * as Fixer from "../../../functions/advent/2020/bootCodeFixer"
  
  /**
   * ---
   * title: "Advent of Code 2020, Day Eight"
   * date: "2020-12-08"
   * ---
   */
  export default function DayOne(data) {
    const [part1, setPart1] = useState(0)
    const [part2, setPart2] = useState(0)
  
    const solvePartOne = () => {
      const text = data.data.file.childPlainText.content.split("\n")
      setPart1(Fixer.getAccumulatorOnRepeat(text))
    }
  
    const solvePartTwo = () => {
      const text = data.data.file.childPlainText.content.split("\n")
      setPart2(Fixer.fixCorruptedBootcode(text))
    }
  
    return (
      <Layout>
        <Helmet>
          <body class="advent2020" />
        </Helmet>
        <SEO title="Advent of Code 2020, Day Eight" />
        <Header headerText="Advent of Code 2020, Day Eight" />
  
        <p>This is the fixing a game consoles bootcode one</p>
  
        <button type="button" onClick={solvePartOne}>
          Do Part One
        </button>
        <p>Answer is: {part1}</p>
  
        <button type="button" onClick={solvePartTwo}>
          Do Part Two
        </button>
        <p>Answer is: {part2}</p>
      </Layout>
    )
  }
  
  export const query = graphql`
    query {
      file(relativePath: { eq: "pages/advent/2020/inputs/8.txt" }) {
        id
        childPlainText {
          content
        }
      }
    }
  `
  