2020-02-02 22:42:18 +00:00
|
|
|
<template>
|
2020-05-02 20:10:33 +00:00
|
|
|
<div class="container is-fullwidth">
|
2020-04-12 14:25:42 +00:00
|
|
|
<div class="loading" v-if="loading">
|
|
|
|
<Loading />
|
|
|
|
</div>
|
2020-03-17 22:16:34 +00:00
|
|
|
<div class v-else>
|
|
|
|
<Modal
|
|
|
|
title="Add A child"
|
|
|
|
:isActive="enableChildModel"
|
|
|
|
acceptText="Add"
|
|
|
|
rejectText="Cancel"
|
|
|
|
@accept="addChild()"
|
|
|
|
@close="enableChildModel=false"
|
|
|
|
>
|
|
|
|
<form class="form register" id="form-register">
|
2020-02-09 15:17:11 +00:00
|
|
|
<div class="field">
|
|
|
|
<label class="label">Name</label>
|
2020-03-17 22:16:34 +00:00
|
|
|
<div class="control has-icons-left">
|
|
|
|
<input
|
|
|
|
:class="['input']"
|
|
|
|
required="true"
|
|
|
|
name="name"
|
|
|
|
type="text"
|
|
|
|
placeholder="John Snow"
|
|
|
|
:disabled="!childValidation.enableInput"
|
|
|
|
v-model="childValidation.name"
|
|
|
|
/>
|
|
|
|
<span class="icon is-small is-left">
|
|
|
|
<i class="fa fa-id-card"></i>
|
|
|
|
</span>
|
2020-02-09 15:17:11 +00:00
|
|
|
</div>
|
2020-04-26 02:33:49 +00:00
|
|
|
<p class="help is-danger">{{ '' }}</p>
|
|
|
|
<!-- TODO: Error messages -->
|
2020-02-09 15:17:11 +00:00
|
|
|
</div>
|
2020-03-17 22:16:34 +00:00
|
|
|
|
2020-02-09 15:17:11 +00:00
|
|
|
<div class="field">
|
2020-03-17 22:16:34 +00:00
|
|
|
<label class="label">Birthday</label>
|
|
|
|
<div class="control has-icons-left">
|
|
|
|
<input
|
|
|
|
:class="['input']"
|
|
|
|
required="true"
|
|
|
|
name="dob"
|
|
|
|
type="date"
|
|
|
|
:disabled="!childValidation.enableInput"
|
|
|
|
v-model="childValidation.dob"
|
|
|
|
/>
|
|
|
|
<span class="icon is-small is-left">
|
|
|
|
<i class="fa fa-gift"></i>
|
|
|
|
</span>
|
2020-02-09 15:17:11 +00:00
|
|
|
</div>
|
2020-04-26 02:33:49 +00:00
|
|
|
<p class="help is-danger">{{ '' }}</p>
|
2020-02-09 15:17:11 +00:00
|
|
|
</div>
|
2020-03-17 22:16:34 +00:00
|
|
|
<file-select v-model="childValidation.avatar" accept="image/*" lable="Upload Avatar:"></file-select>
|
2020-02-09 15:17:11 +00:00
|
|
|
</form>
|
2020-03-17 22:16:34 +00:00
|
|
|
</Modal>
|
|
|
|
<div class="has-text-centered">
|
|
|
|
<h3 class="title">Settings</h3>
|
|
|
|
<h4 class="subtitle">{{user.name}}</h4>
|
|
|
|
</div>
|
|
|
|
<div class="columns">
|
2020-05-02 20:10:33 +00:00
|
|
|
<div class="column is-3">
|
2020-03-17 22:16:34 +00:00
|
|
|
<figure class="image is-128x128 m-auto">
|
|
|
|
<img class="is-rounded is-avatar" :src="user.avatar" />
|
|
|
|
</figure>
|
|
|
|
<div class="card m-t-lg">
|
|
|
|
<header class="card-header">
|
|
|
|
<p class="card-header-title">My Children</p>
|
|
|
|
</header>
|
|
|
|
<div class="card-content">
|
2020-04-12 14:25:42 +00:00
|
|
|
<ChildCard v-for="child in user.connections.children" :key="child.id" :child="child"></ChildCard>
|
2020-03-17 22:16:34 +00:00
|
|
|
</div>
|
|
|
|
<footer class="card-footer">
|
|
|
|
<a
|
|
|
|
:enabled="childValidation.enableInput"
|
|
|
|
class="card-footer-item"
|
|
|
|
@click="enableChildModel=true"
|
|
|
|
>Add a New Child</a>
|
|
|
|
</footer>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="column">
|
|
|
|
<form class="form">
|
|
|
|
<div class="field">
|
|
|
|
<label class="label">Name</label>
|
|
|
|
<div class="control">
|
|
|
|
<input
|
|
|
|
:disabled="!childValidation.enableInput"
|
|
|
|
class="input"
|
|
|
|
type="text"
|
|
|
|
placeholder="Text input"
|
|
|
|
v-model="user.name"
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="field">
|
|
|
|
<label class="label">Email</label>
|
|
|
|
<div class="control">
|
|
|
|
<input class="input" v-model="user.email" type="email" placeholder="Text input" />
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</form>
|
|
|
|
</div>
|
2020-02-09 15:17:11 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
2020-02-02 22:42:18 +00:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
2020-03-17 22:16:34 +00:00
|
|
|
import { mapActions, mapGetters } from "vuex";
|
|
|
|
import Modal from "../../shared/components/Modal/Modal.vue";
|
|
|
|
import ChildCard from "../components/Child_Card.vue";
|
|
|
|
import Services from "../../services";
|
|
|
|
import FileSelect from "../../shared/components/FileSelect/FileSelect.vue";
|
2020-04-12 14:25:42 +00:00
|
|
|
import Loading from "../../shared/components/Loading/Loading.vue";
|
2020-02-02 22:42:18 +00:00
|
|
|
export default {
|
2020-03-17 22:16:34 +00:00
|
|
|
components: {
|
|
|
|
Modal,
|
|
|
|
FileSelect,
|
2020-04-12 14:25:42 +00:00
|
|
|
ChildCard,
|
|
|
|
Loading
|
2020-03-17 22:16:34 +00:00
|
|
|
},
|
2020-02-02 22:42:18 +00:00
|
|
|
name: "Settings",
|
2020-03-17 22:16:34 +00:00
|
|
|
async beforeCreate() {
|
|
|
|
return true;
|
|
|
|
},
|
2020-02-02 22:42:18 +00:00
|
|
|
async created() {
|
2020-03-17 22:16:34 +00:00
|
|
|
if (!this.user) {
|
|
|
|
try {
|
|
|
|
await this.getUser();
|
|
|
|
} catch (e) {
|
|
|
|
console.error("Failed to fetch user");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
this.loading = false;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
async addChild() {
|
|
|
|
this.childValidation.enableInput = false;
|
|
|
|
const childData = {
|
|
|
|
name: this.childValidation.name,
|
|
|
|
dob: this.childValidation.dob,
|
|
|
|
avatar: this.childValidation.avatar
|
|
|
|
};
|
|
|
|
console.log(childData);
|
|
|
|
const child = await Services.ApiService.createChild(
|
|
|
|
childData.name,
|
|
|
|
childData.dob,
|
|
|
|
childData.avatar
|
|
|
|
);
|
|
|
|
if (childData.avatar) console.log(childData.avatar.length);
|
|
|
|
this.childValidation.name = null;
|
|
|
|
this.childValidation.dob = null;
|
|
|
|
this.childValidation.avatar = null;
|
|
|
|
this.childValidation.enableInput = true;
|
|
|
|
|
|
|
|
this.enableChildModel = false;
|
|
|
|
await this.getUser();
|
2020-04-12 14:25:42 +00:00
|
|
|
this.notify({
|
|
|
|
message: `Yay!, ${child.name} was cretated`,
|
|
|
|
level: "success"
|
|
|
|
});
|
2020-03-17 22:16:34 +00:00
|
|
|
// console.log(child);
|
|
|
|
return true;
|
|
|
|
},
|
2020-04-12 14:25:42 +00:00
|
|
|
...mapActions(["getUser", "notify"])
|
2020-03-17 22:16:34 +00:00
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
...mapGetters(["user"])
|
2020-02-02 22:42:18 +00:00
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
2020-03-17 22:16:34 +00:00
|
|
|
loading: true,
|
|
|
|
childValidation: {
|
|
|
|
enableInput: true,
|
|
|
|
name: null,
|
|
|
|
dob: null,
|
|
|
|
avatar: null
|
|
|
|
},
|
|
|
|
enableChildModel: false
|
2020-02-02 22:42:18 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|