#29 refactor: replace admin code with role-based auth using Pinia

This commit is contained in:
mono
2026-03-14 22:55:24 -05:00
parent 2c9ea4b871
commit 786d0551bb
12 changed files with 105 additions and 129 deletions

View File

@@ -1,20 +1,19 @@
<template>
<div>
<CodeDialog @code-verified="(verified) => showComponent = verified"/>
</div>
<AdminPurchase v-if="showComponent"/>
<AdminPurchase v-if="authStore.isAdmin"/>
</template>
<script >
import CodeDialog from '../components/CodeDialog.vue'
import { useAuthStore } from '@/stores/auth';
export default {
data() {
return {
showComponent: false,
setup() {
const authStore = useAuthStore();
return { authStore };
},
mounted() {
if (!this.authStore.isAdmin) {
this.$router.push('/');
}
},
components: { CodeDialog },
methods: {},
}
</script>

View File

@@ -1,20 +1,19 @@
<template>
<div>
<CodeDialog @code-verified="(verified) => showComponent = verified"/>
</div>
<ReconciliationJar v-if="showComponent" />
<ReconciliationJar v-if="authStore.isAdmin" />
</template>
<script >
import CodeDialog from '../components/CodeDialog.vue'
import { useAuthStore } from '@/stores/auth';
export default {
data() {
return {
showComponent: false,
setup() {
const authStore = useAuthStore();
return { authStore };
},
mounted() {
if (!this.authStore.isAdmin) {
this.$router.push('/');
}
},
components: { CodeDialog },
methods: {},
}
</script>

View File

@@ -1,20 +1,19 @@
<template>
<div>
<CodeDialog @code-verified="(verified) => showComponent = verified" />
</div>
<ReconciliationJarIndex v-if="showComponent" />
<ReconciliationJarIndex v-if="authStore.isAdmin" />
</template>
<script>
import CodeDialog from '../components/CodeDialog.vue'
import { useAuthStore } from '@/stores/auth';
export default {
data() {
return {
showComponent: false,
setup() {
const authStore = useAuthStore();
return { authStore };
},
mounted() {
if (!this.authStore.isAdmin) {
this.$router.push('/');
}
},
components: { CodeDialog },
methods: {},
}
</script>

View File

@@ -1,8 +1,5 @@
<template>
<div>
<CodeDialog @code-verified="(verified) => showComponent = verified"/>
</div>
<v-container class="fill-height d-flex align-center justify-center">
<v-container v-if="authStore.isAdmin" class="fill-height d-flex align-center justify-center">
<v-card class="pa-6" max-width="600" elevation="4">
<v-card-title class="text-h5 font-weight-bold text-center">
🔄 Sincronización de Clientes
@@ -44,11 +41,15 @@
</template>
<script>
import CodeDialog from '../components/CodeDialog.vue'
import { useAuthStore } from '@/stores/auth';
import { inject } from 'vue';
export default {
name: 'CustomersFromTryton',
setup() {
const authStore = useAuthStore();
return { authStore };
},
data() {
return {
api: inject('api'),
@@ -59,21 +60,24 @@
updated_customers: [],
}
},
mounted() {
if (!this.authStore.isAdmin) {
this.$router.push('/');
}
},
methods: {
startSync() {
this.api.getCustomersFromTryton()
.then(response => {
// Manejar la respuesta exitosa
this.checked_tryton_parties = response.checked_tryton_parties.map(id => ({ id }));
this.created_customers = response.created_customers.map(id => ({ id }));
this.failed_parties = response.failed_parties.map(id => ({ id }));
this.untouched_customers = response.untouched_customers.map(id => ({ id }));
})
.catch(error => {
// Manejar el error
console.error("Error al sincronizar clientes:", error);
});
}
}
}
</script>
</script>

View File

@@ -1,8 +1,5 @@
<template>
<div>
<CodeDialog @code-verified="(verified) => showComponent = verified"/>
</div>
<v-container class="fill-height d-flex align-center justify-center">
<v-container v-if="authStore.isAdmin" class="fill-height d-flex align-center justify-center">
<v-card class="pa-6" max-width="600" elevation="4">
<v-card-title class="text-h5 font-weight-bold text-center">
🔄 Sincronización de Productos
@@ -39,16 +36,24 @@
</template>
<script>
import CodeDialog from '../components/CodeDialog.vue'
import { useAuthStore } from '@/stores/auth';
import { inject } from 'vue';
export default {
name: 'ProductsFromTryton',
setup() {
const authStore = useAuthStore();
return { authStore };
},
data() {
return {
api: inject('api'),
productos_tryton: [{}],
showComponent: false,
}
},
mounted() {
if (!this.authStore.isAdmin) {
this.$router.push('/');
}
},
methods: {
@@ -57,4 +62,4 @@
}
}
}
</script>
</script>

View File

@@ -1,8 +1,5 @@
<template>
<div>
<CodeDialog @code-verified="(verified) => showComponent = verified"/>
</div>
<v-container class="fill-height d-flex align-center justify-center">
<v-container v-if="authStore.isAdmin" class="fill-height d-flex align-center justify-center">
<v-card class="pa-6" max-width="600" elevation="4">
<v-card-title class="text-h5 font-weight-bold text-center">
🔄 Sincronización de Ventas
@@ -35,16 +32,24 @@
</v-container>
</template>
<script>
import CodeDialog from '../components/CodeDialog.vue';
import { useAuthStore } from '@/stores/auth';
import { inject } from 'vue';
export default {
name: 'SalesToTryton',
setup() {
const authStore = useAuthStore();
return { authStore };
},
data() {
return {
api: inject('api'),
ventas_tryton: [],
showComponent: false,
}
},
mounted() {
if (!this.authStore.isAdmin) {
this.$router.push('/');
}
},
methods: {

View File

@@ -1,19 +1,18 @@
<template>
<div>
<CodeDialog @code-verified="(verified) => showComponent = verified"/>
</div>
<ExportPurchasesForTryton v-if="showComponent" />
<ExportPurchasesForTryton v-if="authStore.isAdmin" />
</template>
<script>
import CodeDialog from '../components/CodeDialog.vue'
import { useAuthStore } from '@/stores/auth';
export default {
data() {
return {
showComponent: false,
setup() {
const authStore = useAuthStore();
return { authStore };
},
mounted() {
if (!this.authStore.isAdmin) {
this.$router.push('/');
}
},
components: { CodeDialog },
methods: {},
}
</script>