edit cooperative page and functionality

This commit is contained in:
María
2025-08-20 12:37:20 +02:00
parent 8fedf54470
commit d609660dde
10 changed files with 671 additions and 13 deletions

View File

@@ -0,0 +1,59 @@
<template>
<BContainer class="container">
<BRow align-h="center">
<BCol class="edit-coop">
<h1 class="title">Editar Cooperativa</h1>
<div class="form-container">
<CompanyForm />
</div>
</BCol>
</BRow>
</BContainer>
</template>
<script>
export default {
setup (){
definePageMeta({
layout: 'editar',
middleware: 'auth',
auth: { authority: 'COOP_MANAGER' }
})
},
}
</script>
<style lang="scss" scoped>
.container {
margin-top: 40px;
margin-bottom: 80px;
}
.edit-coop {
display: flex;
flex-direction: column;
align-items: center;
}
.title {
color: $color-navy;
font-size: $xxl;
margin-bottom: 50px;
text-align: left;
@include desktop {
width: 40%;
}
@include tablet {
width: 60%;
}
@include mobile {
width: 90%;
margin-top: 70px;
}
}
.form-container {
width: 100%;
display: flex;
flex-direction: column;
align-items: center;
}
</style>

View File

@@ -6,12 +6,14 @@
<h1 class="title">Editar perfil</h1>
<FormInput
v-model="form.full_name"
:value="form.full_name ? form.full_name : ''"
type="text"
label-text="Nombre de usuario"
@input="form.full_name = $event"
/>
<FormInput
v-model="form.email"
:value="form.email ? form.email : ''"
type="text"
label-text="Email"
@input="form.email = $event"
@@ -55,26 +57,28 @@ export default {
success: false,
}
},
async fetch() {
computed: {
...mapState(useAuthStore, ['id', 'access']),
},
async created() {
const config = useRuntimeConfig()
try {
await $fetch(`/my_user/`, {
const response = await $fetch(`/my_user/`, {
baseURL: config.public.baseURL,
method: 'GET',
body: JSON.stringify(this.form),
headers: {
Authorization: `Bearer ${this.access}`
}
})
//console.log('User data fetched successfully:', response)
this.form.full_name = response.full_name
this.form.email = response.email
this.form.notify = response.notify
} catch (err) {
console.error('Error fetching user data:', err)
this.error = true
return
}
this.form.full_name = response.full_name
this.form.email = response.email
this.form.notify = response.notify
},
computed: {
...mapState(useAuthStore, ['id', 'access']),
},
methods: {
...mapActions( useAuthStore, ['setUser']),