aboutsummaryrefslogtreecommitdiff
path: root/src/views/Start.vue
blob: f32c337f3fdf4ebc673afe2ff614f01ceec7d8c0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<template>
  <div id="start">
    <router-link to="/editor">
      <UIButton>Create new database</UIButton>
    </router-link>
    <FileUpload
      :accept="'application/json'"
      @fileChanged="handleDatabaseChange">Use existing database</FileUpload>
  </div>
</template>

<script lang="ts">
import { defineComponent } from 'vue';
import FileUpload from '@/components/FileUpload.vue';
import { parsePtDatabase } from '@/features/parser';
import UIButton from '@/components/UIButton.vue';

export default defineComponent({
  name: 'Start',
  components: {
    FileUpload,
    UIButton,
  },
  methods: {
    async handleDatabaseChange(files: File[]) {
      const result = await parsePtDatabase(files[0]);
      this.$store.commit('setLabs', result.labs);
      this.$store.commit('setPeerTeachers', result.peerTeachers);
      this.$router.push({ name: 'Editor' });
    },
  },
});
</script>

<style>
#start {
  align-items: center;
  display: flex;
  flex-direction: column;
  font-size: 1.5rem;
  height: 100vh;
  justify-content: center;
}

#start > * {
  margin-top: 1em;
}

#start > *:first-child {
  margin-top: 0;
}
</style>