Jules was unable to complete the task in time. Please review the work done so far and provide feedback for Jules to continue.
This commit is contained in:
@@ -1,2 +1,143 @@
|
||||
<template>
|
||||
<div class="asistencias-index-container">
|
||||
<header class="page-header">
|
||||
<h1>Gestión de Asistencias</h1>
|
||||
<button @click="navigateToCreateForm" class="btn-create">
|
||||
Registrar Nueva Asistencia
|
||||
</button>
|
||||
</header>
|
||||
|
||||
<template></template>
|
||||
<div v-if="isLoading" class="loading-message">
|
||||
Cargando asistencias...
|
||||
</div>
|
||||
|
||||
<div v-else-if="errorLoading" class="error-message-full">
|
||||
<p>Ocurrió un error al cargar las asistencias. Por favor, intente de nuevo más tarde.</p>
|
||||
<p v-if="errorMessage">Detalle: {{ errorMessage }}</p>
|
||||
</div>
|
||||
|
||||
<div v-else>
|
||||
<tabla-asistencias
|
||||
:asistencias="asistenciasList"
|
||||
@edit="handleEditAsistencia"
|
||||
/>
|
||||
<div v-if="!asistenciasList || asistenciasList.length === 0 && !isLoading" class="no-data-message">
|
||||
No hay asistencias registradas. Puede registrar una nueva haciendo clic en el botón de arriba.
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, computed, onMounted } from 'vue';
|
||||
import { useAsistenciasStore } from '../../stores/useAsistencias';
|
||||
import { useRouter } from 'vue-router';
|
||||
import TablaAsistencias from '../../components/asistencias/tablaAsistencias.vue';
|
||||
|
||||
const asistenciasStore = useAsistenciasStore();
|
||||
const router = useRouter();
|
||||
|
||||
const isLoading = ref(true);
|
||||
const errorLoading = ref(false);
|
||||
const errorMessage = ref('');
|
||||
|
||||
const asistenciasList = computed(() => asistenciasStore.asistencias);
|
||||
|
||||
onMounted(async () => {
|
||||
try {
|
||||
isLoading.value = true;
|
||||
errorLoading.value = false;
|
||||
errorMessage.value = '';
|
||||
await asistenciasStore.fetchAsistencias();
|
||||
} catch (error) {
|
||||
console.error("Error fetching asistencias on mount:", error);
|
||||
errorLoading.value = true;
|
||||
errorMessage.value = error.message || 'Error desconocido al cargar asistencias.';
|
||||
} finally {
|
||||
isLoading.value = false;
|
||||
}
|
||||
});
|
||||
|
||||
const navigateToCreateForm = () => {
|
||||
// Assuming route for creating a new asistencia is named 'AsistenciaFormNew'
|
||||
router.push({ name: 'AsistenciaFormNew' });
|
||||
};
|
||||
|
||||
const handleEditAsistencia = (asistenciaId) => {
|
||||
// Assuming route for editing is named 'AsistenciaFormEdit'
|
||||
router.push({ name: 'AsistenciaFormEdit', params: { id: asistenciaId } });
|
||||
};
|
||||
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.asistencias-index-container {
|
||||
padding: 20px;
|
||||
max-width: 1200px;
|
||||
margin: 0 auto;
|
||||
font-family: 'Arial', sans-serif;
|
||||
}
|
||||
|
||||
.page-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 25px;
|
||||
padding-bottom: 15px;
|
||||
border-bottom: 1px solid #dee2e6;
|
||||
}
|
||||
|
||||
.page-header h1 {
|
||||
color: #212529;
|
||||
font-size: 1.8em;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.btn-create {
|
||||
background-color: #17a2b8; /* Info Blue */
|
||||
color: white;
|
||||
padding: 10px 18px;
|
||||
border: none;
|
||||
border-radius: 5px;
|
||||
font-size: 1em;
|
||||
font-weight: 500;
|
||||
cursor: pointer;
|
||||
transition: background-color 0.2s ease-in-out, box-shadow 0.2s ease;
|
||||
box-shadow: 0 2px 5px rgba(0,0,0,0.1);
|
||||
}
|
||||
|
||||
.btn-create:hover {
|
||||
background-color: #138496;
|
||||
box-shadow: 0 4px 8px rgba(0,0,0,0.15);
|
||||
}
|
||||
|
||||
.loading-message,
|
||||
.error-message-full,
|
||||
.no-data-message {
|
||||
text-align: center;
|
||||
padding: 25px;
|
||||
margin-top: 25px;
|
||||
border-radius: 8px;
|
||||
font-size: 1.1em;
|
||||
}
|
||||
|
||||
.loading-message {
|
||||
color: #495057;
|
||||
}
|
||||
|
||||
.error-message-full {
|
||||
background-color: #f8d7da;
|
||||
color: #721c24;
|
||||
border: 1px solid #f5c6cb;
|
||||
}
|
||||
.error-message-full p {
|
||||
margin: 5px 0;
|
||||
}
|
||||
|
||||
.no-data-message {
|
||||
background-color: #f8f9fa;
|
||||
color: #343a40;
|
||||
border: 1px solid #e9ecef;
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user