feat: Implement empleado UI and chat integration
This commit introduces the following features:
1. **Empleado UI Components:**
* `EmpleadoForm.vue`: A form for creating and editing employee data.
* `cardEmpleado.vue`: A component to display a summary of employee information in a card format.
* `tablaEmpleados.vue`: A component to display a list of employees in a table format.
* `EmpleadosIndex.vue`: A view that displays both the card and table components, allowing you to switch between views and create new employees.
2. **Chat Interface Integration:**
* Modified `agent/handlers.js` to parse specific chat commands:
* "Quiero crear un nuevo @empleado": Responds with the `EmpleadoForm`.
* "Ver @empleado<CEDULA>": Responds with the `cardEmpleado` for the specified employee.
* "Mostrame los primeros X @empleados": Responds with `tablaEmpleados` displaying the requested number of employees.
* I send formatted messages (e.g., `CHAT_UI_COMPONENT::EmpleadoForm`) that the chat UI can interpret to render the Vue components.
3. **Tests:**
* Added unit tests for the new Vue components (`EmpleadoForm.vue`, `cardEmpleado.vue`, `tablaEmpleados.vue`) using Vitest.
* Added integration tests for the chat command handling in `agent/handlers.js` using Jest.
* (Note: Test execution was inconclusive, but all necessary files and configurations are included).
These changes fulfill the issue requirements by creating the necessary UI for the empleado module and enabling the summoning of these UI elements through the chat interface.
This commit is contained in:
@@ -1 +1,112 @@
|
||||
<template>
|
||||
<div class="bg-white shadow-lg rounded-lg p-6 m-4 w-full max-w-sm hover:shadow-xl transition-shadow duration-300 ease-in-out">
|
||||
<div class="flex items-center mb-4">
|
||||
<img
|
||||
:src="employee.avatar_url || 'https://via.placeholder.com/150'"
|
||||
alt="Avatar del empleado"
|
||||
class="w-20 h-20 rounded-full mr-6 border-2 border-blue-500 object-cover"
|
||||
/>
|
||||
<div>
|
||||
<h2 class="text-2xl font-bold text-gray-800">{{ employee.name }}</h2>
|
||||
<p class="text-gray-600 text-sm">Cédula: {{ employee.cedula }}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="space-y-2">
|
||||
<div v-if="employee.telefono" class="flex items-center text-gray-700">
|
||||
<svg class="w-5 h-5 mr-2 text-blue-500" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 5a2 2 0 012-2h3.28a1 1 0 01.948.684l1.498 4.493a1 1 0 01-.502 1.21l-2.308 1.154a11.042 11.042 0 005.516 5.516l1.154-2.308a1 1 0 011.21-.502l4.493 1.498a1 1 0 01.684.949V19a2 2 0 01-2 2h-1C9.716 21 3 14.284 3 6V5z"></path></svg>
|
||||
<span>{{ employee.telefono }}</span>
|
||||
</div>
|
||||
<div v-if="employee.ubicacion" class="flex items-center text-gray-700">
|
||||
<svg class="w-5 h-5 mr-2 text-blue-500" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M17.657 16.657L13.414 20.9a1.998 1.998 0 01-2.827 0l-4.244-4.243a8 8 0 1111.314 0z"></path><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 11a3 3 0 11-6 0 3 3 0 016 0z"></path></svg>
|
||||
<span>{{ employee.ubicacion }}</span>
|
||||
</div>
|
||||
<div v-if="employee.idciat" class="flex items-center text-gray-700">
|
||||
<svg class="w-5 h-5 mr-2 text-blue-500" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10 6H5a2 2 0 00-2 2v9a2 2 0 002 2h14a2 2 0 002-2V8a2 2 0 00-2-2h-5m-4 0V5a2 2 0 012-2h2a2 2 0 012 2v1m-4 0h4m-6 10v-5m0 5v0z"></path></svg>
|
||||
<span>ID CIAT: {{ employee.idciat }}</span>
|
||||
</div>
|
||||
<div v-if="employee.grupo_estudio" class="flex items-center text-gray-700">
|
||||
<svg class="w-5 h-5 mr-2 text-blue-500" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M12 14l9-5-9-5-9 5 9 5z"></path><path d="M12 14l6.16-3.422a12.083 12.083 0 01.665 6.479A11.952 11.952 0 0012 20.055a11.952 11.952 0 00-6.824-5.998 12.083 12.083 0 01.665-6.479L12 14z"></path><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 14l9-5-9-5-9 5 9 5zm0 0v3.945m0-3.945L6.161 10.58M17.839 10.58L12 14m5.839-3.42L12 14m0 0l6.161 3.42m-6.161-3.42L5.839 14.002"></path></svg>
|
||||
<span>Grupo Estudio: {{ employee.grupo_estudio }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mt-6 flex justify-end space-x-3">
|
||||
<button @click="handleEdit" class="px-4 py-2 bg-blue-500 text-white text-sm font-medium rounded-md hover:bg-blue-600 focus:outline-none focus:ring-2 focus:ring-blue-400 focus:ring-offset-2">
|
||||
Editar
|
||||
</button>
|
||||
<button @click="handleViewDetails" class="px-4 py-2 bg-gray-200 text-gray-700 text-sm font-medium rounded-md hover:bg-gray-300 focus:outline-none focus:ring-2 focus:ring-gray-400 focus:ring-offset-2">
|
||||
Ver Detalles
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { PropType } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
|
||||
// Define the structure of the employee object based on the Prisma schema
|
||||
interface Employee {
|
||||
id: string | number // Changed from BigInt to string | number for easier handling in frontend
|
||||
name: string
|
||||
cedula: number // Changed from BigInt
|
||||
avatar_url?: string
|
||||
telefono?: string
|
||||
ubicacion: string
|
||||
idciat?: string
|
||||
grupo_estudio?: string
|
||||
// created_at and updated_at are usually not displayed directly in a summary card
|
||||
// empleado: boolean // This is implicit as it's an employee card
|
||||
}
|
||||
|
||||
const props = defineProps({
|
||||
employee: {
|
||||
type: Object as PropType<Employee>,
|
||||
required: true,
|
||||
},
|
||||
})
|
||||
|
||||
const router = useRouter()
|
||||
|
||||
const handleEdit = () => {
|
||||
// Ensure employee.id is available and correctly typed for URL
|
||||
router.push(`/empleados/edit/${props.employee.id}`)
|
||||
}
|
||||
|
||||
const handleViewDetails = () => {
|
||||
// This could navigate to a more detailed employee page if one exists
|
||||
// For now, it can also navigate to an edit page or a specific detail view
|
||||
// Depending on the application's routing structure, this might be the same as edit or a different view
|
||||
router.push(`/empleados/view/${props.employee.id}`) // Assuming a dedicated view route exists or will be created
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
/* Scoped styles for the card ensure they don't leak */
|
||||
.max-w-sm {
|
||||
max-width: 24rem; /* Consistent with Tailwind's sm breakpoint for max-width */
|
||||
}
|
||||
|
||||
/* Adding some subtle enhancements for visual appeal */
|
||||
.text-2xl {
|
||||
line-height: 1.2; /* Adjust line height for the title for better readability */
|
||||
}
|
||||
|
||||
.flex svg {
|
||||
flex-shrink: 0; /* Prevent SVGs from shrinking if text is long, ensuring icon consistency */
|
||||
}
|
||||
|
||||
/* Styling for buttons for a more refined and interactive look */
|
||||
button {
|
||||
transition: background-color 0.2s ease-in-out, box-shadow 0.2s ease-in-out, transform 0.1s ease-in-out;
|
||||
}
|
||||
button:hover {
|
||||
transform: translateY(-1px); /* Slight lift on hover */
|
||||
}
|
||||
button:active {
|
||||
transform: translateY(0px); /* Reset lift on click */
|
||||
}
|
||||
|
||||
.rounded-full {
|
||||
object-fit: cover; /* Ensures the avatar image covers the area without distortion */
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -1 +1,163 @@
|
||||
<template>
|
||||
<div class="overflow-x-auto bg-white shadow-md rounded-lg p-4">
|
||||
<table class="min-w-full divide-y divide-gray-200">
|
||||
<thead class="bg-gray-50">
|
||||
<tr>
|
||||
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
|
||||
Avatar
|
||||
</th>
|
||||
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
|
||||
Nombre
|
||||
</th>
|
||||
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
|
||||
Cédula
|
||||
</th>
|
||||
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
|
||||
Teléfono
|
||||
</th>
|
||||
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
|
||||
Ubicación
|
||||
</th>
|
||||
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
|
||||
ID CIAT
|
||||
</th>
|
||||
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
|
||||
Acciones
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="bg-white divide-y divide-gray-200">
|
||||
<tr v-if="!employees || employees.length === 0">
|
||||
<td colspan="7" class="px-6 py-4 whitespace-nowrap text-sm text-gray-500 text-center">
|
||||
No hay empleados para mostrar.
|
||||
</td>
|
||||
</tr>
|
||||
<tr v-for="employee in employees" :key="employee.id" class="hover:bg-gray-100 transition-colors duration-150 ease-in-out">
|
||||
<td class="px-6 py-4 whitespace-nowrap">
|
||||
<img
|
||||
:src="employee.avatar_url || 'https://via.placeholder.com/40'"
|
||||
alt="Avatar"
|
||||
class="w-10 h-10 rounded-full object-cover border border-gray-300 shadow-sm"
|
||||
/>
|
||||
</td>
|
||||
<td class="px-6 py-4 whitespace-nowrap">
|
||||
<div class="text-sm font-semibold text-gray-900">{{ employee.name }}</div>
|
||||
<div v-if="employee.grupo_estudio" class="text-xs text-gray-500">
|
||||
Grupo: {{ employee.grupo_estudio }}
|
||||
</div>
|
||||
</td>
|
||||
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-600">
|
||||
{{ employee.cedula }}
|
||||
</td>
|
||||
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-600">
|
||||
{{ employee.telefono || '-' }}
|
||||
</td>
|
||||
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-600">
|
||||
{{ employee.ubicacion }}
|
||||
</td>
|
||||
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-600">
|
||||
{{ employee.idciat || '-' }}
|
||||
</td>
|
||||
<td class="px-6 py-4 whitespace-nowrap text-sm font-medium space-x-2">
|
||||
<button
|
||||
@click="handleEdit(employee.id)"
|
||||
class="text-indigo-600 hover:text-indigo-800 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 p-1 rounded-md hover:bg-indigo-100 transition-all duration-150 ease-in-out"
|
||||
title="Editar Empleado"
|
||||
>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" viewBox="0 0 20 20" fill="currentColor">
|
||||
<path d="M17.414 2.586a2 2 0 00-2.828 0L7 10.172V13h2.828l7.586-7.586a2 2 0 000-2.828z" />
|
||||
<path fill-rule="evenodd" d="M2 6a2 2 0 012-2h4a1 1 0 010 2H4v10h10v-4a1 1 0 112 0v4a2 2 0 01-2 2H4a2 2 0 01-2-2V6z" clip-rule="evenodd" />
|
||||
</svg>
|
||||
</button>
|
||||
<button
|
||||
@click="handleViewDetails(employee.id)"
|
||||
class="text-green-600 hover:text-green-800 focus:outline-none focus:ring-2 focus:ring-green-500 focus:ring-offset-2 p-1 rounded-md hover:bg-green-100 transition-all duration-150 ease-in-out"
|
||||
title="Ver Detalles del Empleado"
|
||||
>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" viewBox="0 0 20 20" fill="currentColor">
|
||||
<path fill-rule="evenodd" d="M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a1 1 0 000 2v3a1 1 0 001 1h1a1 1 0 100-2v-3a1 1 0 00-1-1H9z" clip-rule="evenodd" />
|
||||
</svg>
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { PropType } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
|
||||
// Interface for Employee object structure, aligning with prisma model (excluding sensitive or large fields for table view)
|
||||
interface Employee {
|
||||
id: string | number; // Primary key for navigation and :key
|
||||
name: string;
|
||||
cedula: number; // Assuming cedula is a number; adjust if it's a string
|
||||
avatar_url?: string;
|
||||
telefono?: string;
|
||||
ubicacion: string; // As per schema, this has a default and likely always present
|
||||
idciat?: string;
|
||||
grupo_estudio?: string;
|
||||
// Omitting created_at, updated_at, empleado boolean for brevity in table
|
||||
}
|
||||
|
||||
const props = defineProps({
|
||||
employees: {
|
||||
type: Array as PropType<Employee[]>,
|
||||
required: true,
|
||||
default: () => [], // Provides a default empty array if no prop is passed
|
||||
},
|
||||
});
|
||||
|
||||
const router = useRouter();
|
||||
|
||||
const handleEdit = (employeeId: string | number) => {
|
||||
router.push(`/empleados/edit/${employeeId}`);
|
||||
};
|
||||
|
||||
const handleViewDetails = (employeeId: string | number) => {
|
||||
// This could navigate to a dedicated detail view or the edit view itself
|
||||
router.push(`/empleados/view/${employeeId}`); // Adjust route as per application structure
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
/* Enhancing table aesthetics and interactivity */
|
||||
.min-w-full {
|
||||
border-collapse: separate; /* Allows for rounded corners on table if desired, or better spacing */
|
||||
border-spacing: 0;
|
||||
}
|
||||
|
||||
th {
|
||||
font-weight: 600; /* semibold for headers */
|
||||
color: #4b5563; /* gray-600 for header text */
|
||||
}
|
||||
|
||||
td {
|
||||
color: #374151; /* gray-700 for cell text */
|
||||
}
|
||||
|
||||
.rounded-full {
|
||||
object-fit: cover; /* Ensures avatar images are displayed nicely within their circular bounds */
|
||||
box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06); /* Subtle shadow for avatars */
|
||||
}
|
||||
|
||||
/* Action button icon styling */
|
||||
button svg {
|
||||
transition: transform 0.15s ease-in-out;
|
||||
}
|
||||
button:hover svg {
|
||||
transform: scale(1.15); /* Slightly larger pop on hover for icons */
|
||||
}
|
||||
|
||||
/* Ensure consistent padding and alignment */
|
||||
.px-6 { padding-left: 1.5rem; padding-right: 1.5rem; }
|
||||
.py-3 { padding-top: 0.75rem; padding-bottom: 0.75rem; }
|
||||
.py-4 { padding-top: 1rem; padding-bottom: 1rem; }
|
||||
|
||||
/* Adding a subtle border to the table container itself */
|
||||
.overflow-x-auto {
|
||||
border: 1px solid #e5e7eb; /* Tailwind's gray-200 */
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user