2020-02-02 22:42:18 +00:00
|
|
|
<template>
|
|
|
|
<div class="wrapper">
|
2020-04-12 14:25:42 +00:00
|
|
|
<div class="loading" v-if="loading">
|
|
|
|
<Loading />
|
|
|
|
</div>
|
|
|
|
<div class v-else>
|
|
|
|
<!-- Profile Cover Modal -->
|
|
|
|
<Modal
|
|
|
|
title="Change Cover"
|
|
|
|
:isActive="showCoverModal"
|
|
|
|
acceptText="Change"
|
|
|
|
rejectText="Cancel"
|
|
|
|
@accept="changeCover()"
|
|
|
|
@close="showCoverModal=false"
|
|
|
|
>
|
|
|
|
<ProfileHeader
|
|
|
|
:title="user.name"
|
|
|
|
:background="childCoverModalImage ? childCoverModalImage : user.profile_cover"
|
|
|
|
/>
|
|
|
|
<file-select v-model="childCoverModalImage" accept="image/*" lable="Select Cover:"></file-select>
|
|
|
|
</Modal>
|
|
|
|
|
|
|
|
<!-- Create Call Modal -->
|
|
|
|
<ConfigureNewCallModal
|
|
|
|
@newCall="makeCall($event)"
|
|
|
|
@dismiss="showCreateCallModal=false"
|
|
|
|
:isActive="showCreateCallModal"
|
|
|
|
/>
|
|
|
|
<!-- Profile -->
|
|
|
|
<ProfileHeader :title="user.name" :background="user.profile_cover" />
|
|
|
|
<div class="columns is-fullheight m-t-md">
|
|
|
|
<div class="column is-3">
|
|
|
|
<div class="card">
|
|
|
|
<div class="card-image">
|
|
|
|
<figure class="image is-4by4 p-md">
|
|
|
|
<img :src="user.avatar" class="is-rounded is-avatar" />
|
2020-03-17 22:16:34 +00:00
|
|
|
</figure>
|
|
|
|
</div>
|
2020-04-12 14:25:42 +00:00
|
|
|
<div class="card-content">
|
|
|
|
<div v-if="!![...user.connections.children, ...user.connections.connections].length">
|
|
|
|
<p class="card-header-title">Connections</p>
|
|
|
|
<ChildCard
|
|
|
|
v-for="child in [...user.connections.children, ...user.connections.connections]"
|
|
|
|
:key="child.id"
|
|
|
|
:child="child"
|
|
|
|
></ChildCard>
|
|
|
|
<br />
|
|
|
|
</div>
|
2020-03-17 22:16:34 +00:00
|
|
|
</div>
|
2020-02-09 15:17:11 +00:00
|
|
|
</div>
|
2020-03-17 22:16:34 +00:00
|
|
|
</div>
|
2020-04-12 14:25:42 +00:00
|
|
|
<div class="column">
|
|
|
|
<div class="card">
|
|
|
|
<div class="card-content">
|
|
|
|
<nav class="level">
|
|
|
|
<!-- Left side -->
|
|
|
|
<div class="level-left">
|
|
|
|
<div class="level-item">
|
|
|
|
<h1 class="title">My Room</h1>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<!-- Right side -->
|
|
|
|
<div class="level-right">
|
|
|
|
<div class="level-item">
|
|
|
|
<button class="button">
|
|
|
|
<i class="fa fa-fw fa-plus"></i> Add
|
|
|
|
</button>
|
|
|
|
<button class="button is-success m-l-md" @click="showCreateCallModal=true">
|
|
|
|
<i class="fa fa-fw fa-phone"></i> Call
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</nav>
|
|
|
|
<div class="Games">
|
|
|
|
<h2 class="subtitle">
|
|
|
|
<i class="fa fa-fw fa-puzzle-piece"></i> My Games
|
|
|
|
</h2>
|
|
|
|
<div class="is-flex m-b-md">
|
|
|
|
<div class="game m-l-md" v-for="i of [1, 2, 3, 4]" :key="i">
|
|
|
|
<div class="game-cover">
|
|
|
|
<figure class="image is-2by3 m-a">
|
|
|
|
<img
|
|
|
|
src="https://external-content.duckduckgo.com/iu/?u=http%3A%2F%2Fblog.springshare.com%2Fwp-content%2Fuploads%2F2010%2F02%2Fnc-md.gif&f=1&nofb=1"
|
|
|
|
/>
|
|
|
|
</figure>
|
|
|
|
</div>
|
|
|
|
<div class="game-text">
|
|
|
|
<div>Name</div>
|
|
|
|
<div>Type</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="Books">
|
|
|
|
<h2 class="subtitle">
|
|
|
|
<i class="fa fa-fw fa-book"></i> My Books
|
|
|
|
</h2>
|
|
|
|
<div class="is-flex m-b-md">
|
|
|
|
<div class="book m-l-md" v-for="i of [1, 2, 3, 4]" :key="i">
|
|
|
|
<div class="book-cover">
|
|
|
|
<figure class="image is-2by3 m-a">
|
|
|
|
<img
|
|
|
|
src="https://external-content.duckduckgo.com/iu/?u=http%3A%2F%2Fwww.sylviaday.com%2FWP%2Fwp-content%2Fthemes%2Fsylviaday%2Fimages%2Fcovers%2Ftemp-covers%2Fplaceholder-cover.jpg&f=1&nofb=1"
|
|
|
|
/>
|
|
|
|
</figure>
|
|
|
|
</div>
|
|
|
|
<div class="book-text">
|
|
|
|
<div>book_name</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
2020-03-17 22:16:34 +00:00
|
|
|
</div>
|
2020-02-09 15:17:11 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
2020-02-02 22:42:18 +00:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
2020-04-12 14:25:42 +00:00
|
|
|
import { mapActions, mapGetters } from "vuex";
|
|
|
|
import ChildCard from "../components/Child_Card.vue";
|
2020-03-17 22:16:34 +00:00
|
|
|
import Services from "../../services/index";
|
2020-04-12 14:25:42 +00:00
|
|
|
import Loading from "../../shared/components/Loading/Loading.vue";
|
|
|
|
import ProfileHeader from "../components/ProfileHeader.vue";
|
|
|
|
import AddConnectionModal from "../components/AddConnectionModal.vue";
|
|
|
|
import ConfigureNewCallModal from "../components/ConfigureNewCallModal.vue";
|
|
|
|
import FileSelect from "../../shared/components/FileSelect/FileSelect.vue";
|
|
|
|
import AvatarBadge from "../components/AvatarBadge.vue";
|
|
|
|
import Moment from "moment";
|
|
|
|
import Modal from "../../shared/components/Modal/Modal.vue";
|
2020-02-02 22:42:18 +00:00
|
|
|
export default {
|
|
|
|
name: "Home",
|
2020-02-09 15:17:11 +00:00
|
|
|
components: {
|
2020-04-12 14:25:42 +00:00
|
|
|
Loading,
|
|
|
|
ProfileHeader,
|
|
|
|
Modal,
|
|
|
|
FileSelect,
|
|
|
|
AvatarBadge,
|
|
|
|
AddConnectionModal,
|
|
|
|
ConfigureNewCallModal,
|
|
|
|
ChildCard
|
2020-02-09 15:17:11 +00:00
|
|
|
},
|
|
|
|
beforeCreate() {},
|
2020-03-17 22:16:34 +00:00
|
|
|
async created() {
|
2020-04-12 14:25:42 +00:00
|
|
|
this.loading = false;
|
|
|
|
return true;
|
2020-03-17 22:16:34 +00:00
|
|
|
},
|
2020-02-09 15:17:11 +00:00
|
|
|
data() {
|
|
|
|
return {
|
2020-04-12 14:25:42 +00:00
|
|
|
loading: true,
|
|
|
|
child: null,
|
|
|
|
isParent: false,
|
|
|
|
inEditMode: false,
|
|
|
|
showCoverModal: false,
|
|
|
|
showCreateCallModal: false,
|
|
|
|
showAddConnectionModal: false,
|
|
|
|
childCoverModalImage: null
|
2020-02-09 15:17:11 +00:00
|
|
|
};
|
2020-04-12 14:25:42 +00:00
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
onDeleteClicked() {
|
|
|
|
this.notify({ message: "Test" });
|
|
|
|
},
|
|
|
|
goChildProfile(connection) {
|
|
|
|
this.$router.push({ path: `/child/${connection.id}` });
|
|
|
|
},
|
|
|
|
async makeCall(event) {
|
|
|
|
try {
|
|
|
|
const response = await Services.ApiService.createCall(event);
|
|
|
|
this.notify({ message: `Connectiong...` });
|
|
|
|
this.$router.push({ path: `/call/${response.data.id}` });
|
|
|
|
} catch (e) {
|
|
|
|
console.error(e);
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
},
|
|
|
|
async changeCover() {
|
|
|
|
if (this.childCoverModalImage) {
|
|
|
|
this.loading = true;
|
|
|
|
try {
|
|
|
|
this.child.profile_cover = await Services.ApiService.updateChildCover(
|
|
|
|
this.child.id,
|
|
|
|
this.childCoverModalImage
|
|
|
|
);
|
|
|
|
} catch (error) {
|
|
|
|
console.error(error);
|
|
|
|
}
|
|
|
|
this.loading = false;
|
|
|
|
}
|
|
|
|
this.showCoverModal = false;
|
|
|
|
this.this.childCoverModalImage = null;
|
|
|
|
},
|
|
|
|
togleEditMode() {
|
|
|
|
this.inEditMode = !this.inEditMode;
|
|
|
|
if (this.inEditMode) {
|
|
|
|
this.showCoverModal = true;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
...mapActions(["getUser", "notify"])
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
age() {
|
|
|
|
const years = Moment().diff(this.child.dob, "years");
|
|
|
|
const months = Moment().diff(this.child.dob, "months") % 12;
|
|
|
|
const isNewBorn = !years && !months;
|
|
|
|
let text = "a new boarn!";
|
|
|
|
if (!isNewBorn) {
|
|
|
|
text = "";
|
|
|
|
if (years) text += `${years} years`;
|
|
|
|
if (years && months) text += ` and`;
|
|
|
|
if (months) text += ` ${months} months`;
|
|
|
|
text += " old";
|
|
|
|
}
|
|
|
|
return `${text}`;
|
|
|
|
},
|
|
|
|
...mapGetters(["user"])
|
2020-02-02 22:42:18 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|