|
@@ -15,7 +15,7 @@ export default defineComponent({
|
|
|
return {
|
|
|
config,
|
|
|
data: null,
|
|
|
- videos: null,
|
|
|
+ videos: null
|
|
|
}
|
|
|
},
|
|
|
setup() {
|
|
@@ -26,7 +26,7 @@ export default defineComponent({
|
|
|
'$route.params.id'(newId, oldId) {
|
|
|
this.data = null
|
|
|
this.fetchData(newId)
|
|
|
- },
|
|
|
+ }
|
|
|
},
|
|
|
created() {
|
|
|
this.fetchData(this.$route.params.id)
|
|
@@ -36,14 +36,14 @@ export default defineComponent({
|
|
|
// Fetch account data //
|
|
|
axios
|
|
|
.get(`${config.serverURL}/account/${id}/get`, {
|
|
|
- withCredentials: true,
|
|
|
+ withCredentials: true
|
|
|
})
|
|
|
.then((response) => {
|
|
|
if (response.data.error)
|
|
|
return (this.data = {
|
|
|
username: 'profile not found',
|
|
|
followers: 'profile not found',
|
|
|
- following: 'profile not found',
|
|
|
+ following: 'profile not found'
|
|
|
})
|
|
|
this.data = response.data
|
|
|
console.log(this.data)
|
|
@@ -52,7 +52,7 @@ export default defineComponent({
|
|
|
this.data = {
|
|
|
username: 'profile not found',
|
|
|
followers: 'profile not found',
|
|
|
- following: 'profile not found',
|
|
|
+ following: 'profile not found'
|
|
|
}
|
|
|
|
|
|
console.error('Error in getting profile id ' + id + '!')
|
|
@@ -62,7 +62,7 @@ export default defineComponent({
|
|
|
// Fetch video data //
|
|
|
axios
|
|
|
.get(`${config.serverURL}/account/${id}/videos`, {
|
|
|
- withCredentials: true,
|
|
|
+ withCredentials: true
|
|
|
})
|
|
|
.then((response) => {
|
|
|
if (response.data.error) return (this.videos = [])
|
|
@@ -84,7 +84,25 @@ export default defineComponent({
|
|
|
signedIn() {
|
|
|
return Cookies.get('token') && Cookies.get('token').startsWith('HajeebToken')
|
|
|
},
|
|
|
- },
|
|
|
+ async follow() {
|
|
|
+ const response = await axios.post(`${config.serverURL}/account/${this.$route.params.id}/follow`, {}, {
|
|
|
+ withCredentials: true
|
|
|
+ });
|
|
|
+
|
|
|
+ if(response.data.error) {
|
|
|
+ alert(`error ${this.data.error} following ${this.data.username}. try again later`);
|
|
|
+ return console.error(response.data);
|
|
|
+ }
|
|
|
+
|
|
|
+ if(response.data.successful) {
|
|
|
+ alert("successfully followed " + this.data.username + "!!!");
|
|
|
+ return this.router.go();
|
|
|
+ } else {
|
|
|
+ alert(response.data.message);
|
|
|
+ return this.router.go();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
})
|
|
|
</script>
|
|
|
|
|
@@ -109,8 +127,16 @@ export default defineComponent({
|
|
|
|
|
|
<span class="profile-detail">
|
|
|
<span class="profile-row" id="buttons">
|
|
|
- <button class="india-button">follow</button>
|
|
|
- <button class="india-button">message</button>
|
|
|
+ <span v-if="this.data">
|
|
|
+ <button class="india-button" disabled
|
|
|
+ v-if="this.data.followed || this.data.myself">follow</button>
|
|
|
+ <button class="india-button" v-else @click="follow">follow</button>
|
|
|
+ </span>
|
|
|
+ <span v-if="this.data">
|
|
|
+ <button class="india-button" disabled
|
|
|
+ v-if="this.data.myself">message</button>
|
|
|
+ <button class="india-button" v-else>message</button>
|
|
|
+ </span>
|
|
|
<span v-if="this.data">
|
|
|
<button
|
|
|
class="india-button"
|
|
@@ -270,6 +296,11 @@ export default defineComponent({
|
|
|
background-clip: padding-box;
|
|
|
}
|
|
|
|
|
|
+.india-button:disabled {
|
|
|
+ border-image-source: url('/assets/indiaButtonDisabled.png');
|
|
|
+ color: black;
|
|
|
+}
|
|
|
+
|
|
|
.india-button:hover {
|
|
|
animation-name: interaction;
|
|
|
animation-duration: 0.5s;
|