Skip to content

Commit

Permalink
Fixing typescript issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Simo-42 committed Dec 23, 2024
1 parent 1e14ea5 commit 42bb45f
Show file tree
Hide file tree
Showing 22 changed files with 1,109 additions and 1,252 deletions.
85 changes: 40 additions & 45 deletions components/Header.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,38 +11,34 @@
<div v-if="completed_profil === true" class="flex flex-wrap space-x-4">
<button
@click="userProfiles"
class="btn btn-warning text-gray-900 hover:bg-yellow-600 transition-all duration-300"
>
class="btn btn-warning text-gray-900 hover:bg-yellow-600 transition-all duration-300">
{{ $t("boutton.UserProfiles") }}
</button>

<button
@click="Dashboard"
class="btn btn-warning text-gray-900 hover:bg-yellow-600 transition-all duration-300"
>
class="btn btn-warning text-gray-900 hover:bg-yellow-600 transition-all duration-300">
Dashboard
</button>

<button
@click="modifyProfile"
class="btn btn-info text-gray-900 hover:bg-blue-600 transition-all duration-300"
>
class="btn btn-info text-gray-900 hover:bg-blue-600 transition-all duration-300">
{{ $t("boutton.ModifyProfiles") }}
</button>
</div>
<button
@click="handleSignOut"
class="btn btn-error text-gray-200 hover:bg-red-600 transition-all duration-300"
>
class="btn btn-error text-gray-200 hover:bg-red-600 transition-all duration-300">
{{ $t("boutton.SignOut") }}
</button>
<userLanguage />
</div>
</div>
<!-- <p>data: {{ data }}</p>
<p>token: {{ token }}</p>
<p>cacfewfwefwefwfwa</p> -->
</template>
<!-- <p>data: {{ data }}</p>
<p>token: {{ token }}</p>
<p>cacfewfwefwefwfwa</p> -->

<script setup lang="ts">
const headers = useRequestHeaders(["cookie"]) as HeadersInit;
Expand All @@ -51,62 +47,61 @@ const { status, signOut } = useAuth();
const data = useAuth();
const loggedIn = computed(() => status.value === "authenticated");
const completed_profil = ref(false);
import LottieAnimation from "~/components/lotie/lotieAnimation.vue";
import animationData from "~/assets/lottie/movie.json";
const { $eventBus } = useNuxtApp();
import LottieAnimation from "~/components/lotie/lotieAnimation.vue";
const { $eventBus } = useNuxtApp() as any;
const showAnimation = ref(true);
const { t, locale } = useI18n();
async function handleSignOut() {
await signOut();
navigateTo("/");
await signOut();
navigateTo("/");
}
function userProfiles() {
navigateTo("/user_profiles");
navigateTo("/user_profiles");
}

function modifyProfile() {
navigateTo("/modify_profile");
navigateTo("/modify_profile");
}
function Dashboard() {
navigateTo("/Dashboard");
navigateTo("/Dashboard");
}

onMounted(() => {
console.log("completed_profil:", completed_profil.value);
//Show the nav bar only if the profile is completed
const { $emitter } = useNuxtApp();
console.log("completed_profil:", completed_profil.value);
//Show the nav bar only if the profile is completed
const { $emitter } = useNuxtApp();

$eventBus.on("CompleteProfil", (payload) => {
checkCompletedProfile();
});
$eventBus.on("CompleteProfil", (payload: any) => {
checkCompletedProfile();
});
});

onBeforeUnmount(() => {
$eventBus.off("CompleteProfil", CompleteProfile);
$eventBus.off("CompleteProfil", completed_profil);
});

async function checkCompletedProfile() {
try {
const response = await $fetch("/api/users/completed", {
method: "POST",
body: {
email: token.value.email,
},
headers: {
Authorization: `Bearer ${token.value}`,
},
});
console.log("completed_profil ===== :", response.complete_profile);
completed_profil.value = response.complete_profile;
console.log("api completed", response.complete_profile);
console.log(typeof response.complete_profile);
try {
if (token.value === null) throw new Error("Token is null");
const response = await $fetch<{ complete_profile: boolean }>("/api/users/completed", {
method: "POST",
body: {
email: token.value.email,
},
headers: {
Authorization: `Bearer ${token.value}`,
},
});

completed_profil.value = response.complete_profile;
// console.log("completed_profil ===== :", response.complete_profile);
// console.log(typeof response.complete_profile);
// console.log("api completed", response.complete_profile);

console.log("completed_profil:", completed_profil.value); // Verifier la mise a jour de la valeur
} catch (error) {
console.error(error);
}
// console.log("completed_profil:", completed_profil.value); // Verifier la mise a jour de la valeur
} catch (error) {
console.error(error);
}
}
</script>
Loading

0 comments on commit 42bb45f

Please sign in to comment.