TheDreWen
TheDreWen
NNuxt
Created by TheDreWen on 11/23/2024 in #❓・help
Global import of css files, but no.
@kapa.ai C'est a cause du NuxtLink qui ne retire pas les lien css des pages précédente.
15 replies
NNuxt
Created by TheDreWen on 11/23/2024 in #❓・help
Global import of css files, but no.
@kapa.ai même avec <script> import '~/assets/css/your-style.css' </script>
15 replies
NNuxt
Created by TheDreWen on 11/6/2024 in #❓・help
How do I pass a variable from the middleware to my page?
@kapa.ai J'ai build mon app avec npm run build si je veux utiliser un Dockerfile pour l'heberger comment dois je le structurer
44 replies
NNuxt
Created by TheDreWen on 11/6/2024 in #❓・help
How do I pass a variable from the middleware to my page?
@kapa.ai ici
async function onSubmit() {
formSubmited.value = true;
loading.value = true;
const token = useCookie<string>("X-auth").value;
const {data, error} = await useFetch<{message: string}>(api_url+"users",{
headers: {
"X-auth" : token
},
method: "POST",
body: JSON.stringify({
user: {
email : user_email.value,
username : user_username.value,
password : user_password.value
},
club: {
name : club_name.value,
legal_nature : club_legal_nature.value,
sol_adm : club_sol_adm.value,
polysport : club_polysport.value,
tax_code : club_tax_code.value,
tva: club_tva.value,
sports_group : club_sports_group.value,
com_prov : club_com_prov.value,
group : club_group.value,
affiliation_code : club_affiliation_code.value,
address : club_address.value,
email : club_email.value,
telephone : club_telephone.value,
pec : club_pec.value,
login_email : club_login_email.value,
login_password : club_login_password.value
}
})
});
await navigateTo("/dashboard");
await refreshNuxtData("clubs");
}
async function onSubmit() {
formSubmited.value = true;
loading.value = true;
const token = useCookie<string>("X-auth").value;
const {data, error} = await useFetch<{message: string}>(api_url+"users",{
headers: {
"X-auth" : token
},
method: "POST",
body: JSON.stringify({
user: {
email : user_email.value,
username : user_username.value,
password : user_password.value
},
club: {
name : club_name.value,
legal_nature : club_legal_nature.value,
sol_adm : club_sol_adm.value,
polysport : club_polysport.value,
tax_code : club_tax_code.value,
tva: club_tva.value,
sports_group : club_sports_group.value,
com_prov : club_com_prov.value,
group : club_group.value,
affiliation_code : club_affiliation_code.value,
address : club_address.value,
email : club_email.value,
telephone : club_telephone.value,
pec : club_pec.value,
login_email : club_login_email.value,
login_password : club_login_password.value
}
})
});
await navigateTo("/dashboard");
await refreshNuxtData("clubs");
}
RefreshData ne fonctionne pas dans /dashboard il y a useStats("clubs")
44 replies
NNuxt
Created by TheDreWen on 11/6/2024 in #❓・help
How do I pass a variable from the middleware to my page?
@kapa.ai Quand j'utilise navigateTo entre une page qui ajoute une données en db via mon api une fois arriver sur la page suivant la nouvelle données n'apparait pas comment puis-js faire pour que la page recuperer a nouveua les données sachant que la page utilise un middleware pour recuperer les donnees
44 replies
NNuxt
Created by TheDreWen on 11/6/2024 in #❓・help
How do I pass a variable from the middleware to my page?
@kapa.ai Ici j'ai défini 2 middleware pourquoi la variable user dans useState n'est plus disponible lorsque je ajoute dashboard au middleware ?
<template>
Dash {{ user.username }}

<hr>

{{ clubs }}
</template>
<script setup lang="ts">
import type { Club } from '~/src/interfaces';
import { api_url } from '~/src/variables';

// Page meta et middleware
definePageMeta({
middleware: ["auth", "dashboard"]
});

// Variables
const user = useState<{email: string, root: boolean, username: string, user_id: number}>('user');
const clubs = useState<Array<Club>>('clubs');

</script>
<template>
Dash {{ user.username }}

<hr>

{{ clubs }}
</template>
<script setup lang="ts">
import type { Club } from '~/src/interfaces';
import { api_url } from '~/src/variables';

// Page meta et middleware
definePageMeta({
middleware: ["auth", "dashboard"]
});

// Variables
const user = useState<{email: string, root: boolean, username: string, user_id: number}>('user');
const clubs = useState<Array<Club>>('clubs');

</script>
44 replies
NNuxt
Created by TheDreWen on 11/6/2024 in #❓・help
How do I pass a variable from the middleware to my page?
@kapa.ai Pourquoi ici
definePageMeta({
middleware: ["auth", async (to, from) => {
console.log(0)
const token = useCookie<string>("X-auth").value;

const {data, error} = await useFetch<{message: string, clubs: Array<Club> | null, user_club: number | null}>(api_url+"clubs", {
method: "GET",
headers: {
"X-auth" : token
}
});

console.log(1)

if(data.value?.message == "OK"){
useState("clubs", () => data.value?.clubs);
}else{
return navigateTo("/dashboard/clubs/"+data.value?.user_club+"/");
}
}]
});
definePageMeta({
middleware: ["auth", async (to, from) => {
console.log(0)
const token = useCookie<string>("X-auth").value;

const {data, error} = await useFetch<{message: string, clubs: Array<Club> | null, user_club: number | null}>(api_url+"clubs", {
method: "GET",
headers: {
"X-auth" : token
}
});

console.log(1)

if(data.value?.message == "OK"){
useState("clubs", () => data.value?.clubs);
}else{
return navigateTo("/dashboard/clubs/"+data.value?.user_club+"/");
}
}]
});
Le useStats pose problème ?
44 replies
NNuxt
Created by TheDreWen on 11/6/2024 in #❓・help
How do I pass a variable from the middleware to my page?
@kapa.ai Comment setCookie ici ?
<script setup lang="ts">
import { api_url } from '~/src/variables';

// Page meta et middleware
definePageMeta({
middleware: "not-auth"
});
useHead({
title: "Pagina di accesso." // Page de connexion
});

// Variables
const email_input = ref<string>("");
const password_input = ref<string>("");
const login_error = ref<string>("");

// Fonctions
async function onSubmit() {
login_error.value = "";
const {data, error} = await useFetch<{message: string, token: null|string}>(api_url+"login", {
headers: {
"Content-type" : "application/json"
},
body: JSON.stringify({
email: email_input.value,
password: password_input.value
}),
method: "POST"
});

if(data.value?.message == "OK"){
// ICI SET COOKIE
navigateTo("/dashboard");
}else{
login_error.value = "L'indirizzo e-mail o la password non sono corretti."; // L'adresse e-mail ou le mot de passe est incorrect.7
}
}

</script>
<script setup lang="ts">
import { api_url } from '~/src/variables';

// Page meta et middleware
definePageMeta({
middleware: "not-auth"
});
useHead({
title: "Pagina di accesso." // Page de connexion
});

// Variables
const email_input = ref<string>("");
const password_input = ref<string>("");
const login_error = ref<string>("");

// Fonctions
async function onSubmit() {
login_error.value = "";
const {data, error} = await useFetch<{message: string, token: null|string}>(api_url+"login", {
headers: {
"Content-type" : "application/json"
},
body: JSON.stringify({
email: email_input.value,
password: password_input.value
}),
method: "POST"
});

if(data.value?.message == "OK"){
// ICI SET COOKIE
navigateTo("/dashboard");
}else{
login_error.value = "L'indirizzo e-mail o la password non sono corretti."; // L'adresse e-mail ou le mot de passe est incorrect.7
}
}

</script>
44 replies
NNuxt
Created by TheDreWen on 11/6/2024 in #❓・help
How do I pass a variable from the middleware to my page?
@kapa.ai how get sessionStorage with middleware ?
44 replies