MustBeLogged component + fix sideBar auto open
This commit is contained in:
42
src/views/MustBeLogged.vue
Normal file
42
src/views/MustBeLogged.vue
Normal file
@@ -0,0 +1,42 @@
|
||||
<script setup>
|
||||
import LoginForm from "@/views/main/LoginForm.vue";
|
||||
|
||||
const isOpen = defineModel();
|
||||
|
||||
const props = defineProps({
|
||||
message: {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
});
|
||||
|
||||
const handleSuccess = () => {
|
||||
console.log('handleSuccess triggered');
|
||||
isOpen.value = false;
|
||||
}
|
||||
|
||||
const handleFailure = () => {
|
||||
console.error('Login failed');
|
||||
}
|
||||
|
||||
const closeModal = async () => {
|
||||
console.log('closeModal triggered');
|
||||
isOpen.value = false;
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<v-dialog v-model="isOpen" max-width="400">
|
||||
<v-card>
|
||||
<div class="flex flex-col items-center">
|
||||
<v-img src="/images/usersmedia/HutopyProfile/profilepictures/profileHutopyProfile01.png" class="w-50"></v-img>
|
||||
<LoginForm :onSuccess="handleSuccess" :onFailure="handleFailure"></LoginForm>
|
||||
<v-card-text>{{ message }}</v-card-text>
|
||||
</div>
|
||||
<v-card-actions>
|
||||
<v-btn color="primary" text @click="closeModal">Fermer</v-btn>
|
||||
</v-card-actions>
|
||||
</v-card>
|
||||
</v-dialog>
|
||||
</template>
|
||||
@@ -3,8 +3,11 @@ import { useUserStore } from "@/stores/userStore.js";
|
||||
import { REACTIONS } from "@/Constants/Reactions.js";
|
||||
import { computed, ref } from "vue";
|
||||
import { useClient } from "@/plugins/api.js";
|
||||
import {useAuthStore} from "@/stores/authStore.js"
|
||||
import MustBeLogged from "@/views/MustBeLogged.vue";
|
||||
|
||||
const userStore = useUserStore();
|
||||
const authStore = useAuthStore()
|
||||
|
||||
const props = defineProps({
|
||||
content: {
|
||||
@@ -30,9 +33,16 @@ const holdTimeout = ref(null);
|
||||
const hideTimeout = ref(null);
|
||||
const touchTimeout = ref(null);
|
||||
|
||||
const loginModal = ref(false);
|
||||
|
||||
initializeReactions();
|
||||
|
||||
async function reactToContent(reaction) {
|
||||
if (!authStore.isAuthenticated) {
|
||||
loginModal.value = true;
|
||||
return;
|
||||
}
|
||||
|
||||
const client = useClient();
|
||||
|
||||
if (!hasReacted.value) {
|
||||
@@ -308,6 +318,7 @@ function isMobileDevice() {
|
||||
</v-btn>
|
||||
</v-card>
|
||||
</v-menu>
|
||||
<must-be-logged v-model="loginModal" message="Vous devez être connecté pour réagir."></must-be-logged>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
||||
@@ -40,6 +40,7 @@ const password = ref("");
|
||||
const errorSnackBar = ref(false);
|
||||
const showEmailForm = ref(false);
|
||||
const showPassword = ref(false);
|
||||
const googleCallback = ref('');
|
||||
|
||||
const props = defineProps({
|
||||
onSuccess: {
|
||||
|
||||
@@ -36,19 +36,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<v-dialog v-model="loginModal" max-width="400">
|
||||
<v-card>
|
||||
<div class="flex flex-col items-center">
|
||||
<v-img src="/images/usersmedia/HutopyProfile/profilepictures/profileHutopyProfile01.png" class="w-50"></v-img>
|
||||
<LoginForm :onSuccess="handleSuccess" :onFailure="handleFailure"></LoginForm>
|
||||
<v-card-text>Vous devez être connecté pour poster un commentaire.</v-card-text>
|
||||
</div>
|
||||
<v-card-actions>
|
||||
<v-btn color="primary" text @click="closeModal">Fermer</v-btn>
|
||||
</v-card-actions>
|
||||
</v-card>
|
||||
</v-dialog>
|
||||
<must-be-logged v-model="loginModal" message="Vous devez être connecté pour ajouter un commentaire."></must-be-logged>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
@@ -57,11 +45,7 @@ import {v7} from 'uuid'
|
||||
import {useClient} from '@/plugins/api.js'
|
||||
import {useUserStore} from "@/stores/userStore.js"
|
||||
import {useAuthStore} from "@/stores/authStore.js"
|
||||
import LoginForm from "@/views/main/LoginForm.vue"
|
||||
|
||||
const closeModal = () => {
|
||||
loginModal.value = false;
|
||||
}
|
||||
import MustBeLogged from "@/views/MustBeLogged.vue";
|
||||
|
||||
const props = defineProps({
|
||||
subjectId: {
|
||||
@@ -72,7 +56,6 @@ const props = defineProps({
|
||||
|
||||
const emits = defineEmits(['message-posted'])
|
||||
|
||||
|
||||
const loginModal = ref(false);
|
||||
const client = useClient()
|
||||
const value = ref("")
|
||||
@@ -106,14 +89,6 @@ const publish = async () => {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const handleSuccess = () => {
|
||||
loginModal.value = false;
|
||||
}
|
||||
|
||||
const handleFailure = () => {
|
||||
console.error('Login failed');
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
Reference in New Issue
Block a user