AddAccount.vue 922 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <template>
  2. <main>
  3. <h1>Add account</h1>
  4. <hr/>
  5. <br/>
  6. <account-form v-if="account.version" :onSubmit="onSubmit" :initialAccount="account"/>
  7. </main>
  8. </template>
  9. <script>
  10. import AccountForm from '../components/AccountForm.vue';
  11. import io from "../../io.js";
  12. export default {
  13. components: { AccountForm },
  14. data: () => {
  15. return {
  16. account: {}
  17. }
  18. },
  19. methods: {
  20. onSubmit(account) {
  21. this.socket.emit("account.add", account, (res) => {
  22. console.log(res);
  23. if (res.status === "success") {
  24. this.$router.push("/accounts")
  25. }
  26. });
  27. }
  28. },
  29. mounted() {
  30. io.getSocket(socket => {
  31. this.socket = socket;
  32. this.socket.emit("accountSchema.getLatest", res => {
  33. this.socket.emit("account.createEmptyAccount", res.schema.version, res => {
  34. this.account = res.account;
  35. });
  36. });
  37. });
  38. }
  39. };
  40. </script>
  41. <style lang="scss" scoped>
  42. </style>