<commit_before><template>
  <div>
    <div class="md-layout md-alignment-top-center">
      <div class="md-layout-item">
        <h2>{{ subtitle }}</h2>
      </div>
    </div>
    <form id="codeForm" class="md-layout md-alignment-top-center">
      <div class="md-layout-item md-size-85">
        <md-field>
          <label>Código del Paquete</label>
          <md-input type="text" v-model="code" required></md-input>
        </md-field>
      </div>
      <div class="md-layout-item md-size-85">
        <div class="md-layout md-gutter md-alignment-top-center">
          <div class="md-layout-item">
            <md-button type="button" class="md-raised md-accent" v-on:click="getCainiao()">
              Buscar en AliExpress/Cainiao
            </md-button>
          </div>
          <div class="md-layout-item">
            <md-button type="button" class="md-raised md-primary" v-on:click="getCorreosChile()">
              Buscar en CorreosChile
            </md-button>
          </div>
        </div>
      </div>
    </form>
    <div class="md-layout md-alignment-center-center">
      <div class="md-layout-item md-size-85" v-if="resultStatus === 'cainiao'">
        <h3>Resultado en Cainiao</h3>
        <pre>{{ trackResult }}</pre>
      </div>
      <div class="md-layout-item md-size-85" v-else-if="resultStatus === 'correos-chile'">
        <h3>Resultado en CorreosChile</h3>
        <pre>{{ trackResult }}</pre>
      </div>
      <div class="md-layout-item md-size-85" v-else-if="resultStatus === 'loading'">
        <div class="md-layout md-alignment-center-center">
          <div class="md-layout-item">
            <md-progress-spinner :md-diameter="100" :md-stroke="10" md-mode="indeterminate"></md-progress-spinner>
            <md-snackbar md-position="center" :md-duration="3500" :md-active.sync="showSnackbar">
              <span>Rastreando el paquete {{ code }}</span>
            </md-snackbar>
          </div>
        </div>
      </div>
      <div class="md-layout-item md-size-85" v-else-if="resultStatus === 'error'">
        <p>Es posible que el código del paquete no sea válido o esté mal escrito, o que el servicio de rastreo no esté operativo.</p>
      </div>
      <div class="md-layout-item md-size-85" v-else>
        <p>Ingresa un código de AliExpress Standard Shipping, China Post, Singapore Post o CorreosChile.</p>
        <p>Ejemplo: <i>12891902267000204623069001</i> o <i>RB351146770SG</i></p>
      </div>
    </div>
  </div>
  <!--
  <md-layout md-column id="home">
    <md-layout md-row>
      
    </md-layout>
    <form novalidate>
      <md-layout md-row>
        <md-input-container>
          <label>Código del Paquete</label>
          <md-input type="text" v-model="code" required=""></md-input>
        </md-input-container>
      </md-layout>
      <md-layout md-row>
        <md-layout md-column md-flex="50">
          <md-button type="submit" class="md-raised md-warn" v-on:click="getCainiao()">Buscar en AliExpress/Cainiao</md-button>
        </md-layout>
        <md-layout md-column md-flex="50">
          <md-button type="submit" class="md-raised md-accent" v-on:click="getCorreosChile()">Buscar en CorreosChile</md-button>
        </md-layout>
      </md-layout>
    </form>
    <md-layout md-row>
      <md-layout md-column v-if="resultStatus === 'cainiao'">
        <h3>Buscando en Cainiao</h3>
        <pre>{{ trackResult }}</pre>
      </md-layout>
      <md-layout md-column v-else-if="resultStatus === 'correos-chile'">
        <h3>Buscando en CorreosChile</h3>
        <pre>{{ trackResult }}</pre>
      </md-layout>
      <md-layout md-column v-else-if="resultStatus === 'loading'">
        <md-layout md-align="center">
          <md-progress-spinner :md-diameter="100" :md-stroke="10" md-mode="indeterminate"></md-progress-spinner>
        </md-layout>
        <md-snackbar md-position="center" md-duration="3000" md-persistent>
          <span>Rastreando el paquete {{ code }}</span>
        </md-snackbar>
      </md-layout>
      <md-layout md-column v-else-if="resultStatus === 'loading'">
        <md-layout md-align="center">
          <h3>¡Ha ocurrido un error al buscar el paquete!</h3>
        </md-layout>
        <md-layout md-align="center">
          <p>Es posible que el código del paquete no sea válido o esté mal escrito, o que el servicio de rastreo no esté operativo.</p>
        </md-layout>
      </md-layout>
      <md-layout md-column v-else>
        asdf!
      </md-layout>
    </md-layout>
  </md-layout>
  -->
</template>

<script>
import Tracker from '../services/tracker';

export default {
  name: 'home',
  data() {
    return {
      appName: 'TrackAliChile',
      subtitle: 'Rastreo de paquetes en AliExpress Standard Shipping y CorreosChile',
      showSnackbar: true,
      code: '',
      trackResult: '',
      pingResult: '',
      resultStatus: 'none'
    }
  },
  computed: {
    emptyCode() {
      return this.code === '';
    }
  },
  methods: {
    getCorreosChile() {
      if (!this.emptyCode) {
        console.log(this.code);
        this.resultStatus = 'loading';
        Tracker.queryCorreosChile(this.code)
        .then((res) => {
          this.trackResult = res.data;
          this.resultStatus = 'correos-chile';
        })
        .catch((err) => {
          this.resultStatus = 'error';
        });
      }
    },
    // 12891902267000204623045001
    getCainiao() {
      if (!this.emptyCode) {
        console.log(this.code);
        this.resultStatus = 'loading';
        Tracker.queryCainiao(this.code)
        .then((res) => {
          this.trackResult = res.data;
          this.resultStatus = 'cainiao';
        })
        .catch((err) => {
          this.resultStatus = 'error';
        });
      }
    }
  }
};
</script>

<style scoped>
</style><commit_msg>Frontend code cleaning<commit_after><template>
  <div>
    <div class="md-layout md-alignment-top-center">
      <div class="md-layout-item">
        <h2>{{ subtitle }}</h2>
      </div>
    </div>
    <form id="codeForm" class="md-layout md-alignment-top-center">
      <div class="md-layout-item md-size-85">
        <md-field>
          <label>Código del Paquete</label>
          <md-input type="text" v-model="code" required></md-input>
        </md-field>
      </div>
      <div class="md-layout-item md-size-85">
        <div class="md-layout md-gutter md-alignment-top-center">
          <div class="md-layout-item">
            <md-button type="button" class="md-raised md-accent" v-on:click="getCainiao()">
              Buscar en AliExpress/Cainiao
            </md-button>
          </div>
          <div class="md-layout-item">
            <md-button type="button" class="md-raised md-primary" v-on:click="getCorreosChile()">
              Buscar en CorreosChile
            </md-button>
          </div>
        </div>
      </div>
    </form>
    <div class="md-layout md-alignment-center-center">
      <div class="md-layout-item md-size-85" v-if="resultStatus === 'cainiao'">
        <h3>Resultado en AliExpress/Cainiao</h3>
        <pre>{{ trackResult }}</pre>
      </div>
      <div class="md-layout-item md-size-85" v-else-if="resultStatus === 'correos-chile'">
        <h3>Resultado en CorreosChile</h3>
        <pre>{{ trackResult }}</pre>
      </div>
      <div class="md-layout-item md-size-85" v-else-if="resultStatus === 'loading'">
        <div class="md-layout md-alignment-center-center">
          <div class="md-layout-item">
            <md-progress-spinner :md-diameter="100" :md-stroke="10" md-mode="indeterminate"></md-progress-spinner>
            <md-snackbar md-position="center" :md-duration="3500" :md-active.sync="showSnackbar">
              <span>Rastreando el paquete {{ code }}</span>
            </md-snackbar>
          </div>
        </div>
      </div>
      <div class="md-layout-item md-size-85" v-else-if="resultStatus === 'error'">
        <p>Es posible que el código del paquete no sea válido o esté mal escrito, o que el servicio de rastreo no esté operativo.</p>
      </div>
      <div class="md-layout-item md-size-85" v-else>
        <p>Ingresa un código de AliExpress Standard Shipping, China Post, Singapore Post o CorreosChile.</p>
        <p>Ejemplo: <i>12891902267000204623069001</i> o <i>RB351146770SG</i></p>
      </div>
    </div>
  </div>
</template>

<script>
import Tracker from '../services/tracker';

export default {
  name: 'home',
  data() {
    return {
      appName: 'TrackAliChile',
      subtitle: 'Rastreo de paquetes en AliExpress Standard Shipping y CorreosChile',
      showSnackbar: true,
      code: '',
      trackResult: '',
      pingResult: '',
      resultStatus: 'none'
    }
  },
  computed: {
    emptyCode() {
      return this.code === '';
    }
  },
  methods: {
    getCorreosChile() {
      if (!this.emptyCode) {
        console.log(this.code);
        this.resultStatus = 'loading';
        Tracker.queryCorreosChile(this.code)
        .then((res) => {
          this.trackResult = res.data;
          this.resultStatus = 'correos-chile';
        })
        .catch((err) => {
          this.resultStatus = 'error';
        });
      }
    },
    getCainiao() {
      if (!this.emptyCode) {
        console.log(this.code);
        this.resultStatus = 'loading';
        Tracker.queryCainiao(this.code)
        .then((res) => {
          this.trackResult = res.data;
          this.resultStatus = 'cainiao';
        })
        .catch((err) => {
          this.resultStatus = 'error';
        });
      }
    }
  }
};
</script>

<style scoped>
</style>
{'fraction_non_alphanumeric': 0.16868855887889564, 'fraction_numerical': 0.01809244927839364, 'mean_word_length': 2.1728599867286, 'pattern_counts': {'":': 0, '<': 216, '<?xml version=': 0, '>': 224, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6405185', 'n_tokens_mistral': 3406, 'n_tokens_neox': 3257, 'n_words': 623}