feat: filtros de Estado, Prioridad y proximos a vencer en Proyectos
El backend ya soportaba filtrar por statusId/priorityId; solo faltaba exponerlo en la UI. "Proximos a vencer" es client-side, ventana de 7 dias (misma definicion que el KPI del dashboard). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -137,6 +137,7 @@ export const messages = {
|
||||
project_invite_sent: 'Invitacion enviada por correo',
|
||||
project_created_at: 'Creado',
|
||||
project_deleted_at: 'Eliminado',
|
||||
project_filter_due_soon: 'Solo próximos a vencer (7 días)',
|
||||
project_delete_confirm_msg: '¿Seguro que deseas eliminar este proyecto? Se movera a la papelera y dejara de verse en el listado; un superadministrador puede restaurarlo o borrarlo definitivamente.',
|
||||
project_trash: 'Papelera',
|
||||
project_trash_title: 'Papelera de proyectos',
|
||||
@@ -346,6 +347,7 @@ export const messages = {
|
||||
project_invite_sent: 'Invite sent by email',
|
||||
project_created_at: 'Created',
|
||||
project_deleted_at: 'Deleted',
|
||||
project_filter_due_soon: 'Due soon only (7 days)',
|
||||
project_delete_confirm_msg: 'Are you sure you want to delete this project? It will move to the trash and disappear from the list; a superadmin can restore it or delete it permanently.',
|
||||
project_trash: 'Trash',
|
||||
project_trash_title: 'Project trash',
|
||||
|
||||
@@ -40,7 +40,14 @@ export default function ProyectosPage() {
|
||||
const isSuperadmin = currentUser?.roleCode === 'superadmin';
|
||||
const canDelete = CAN_DELETE_ROLES.includes(currentUser?.roleCode);
|
||||
|
||||
const { data: projects, reload } = useAsync(() => listProjects(showTrash ? { trash: true } : {}), [showTrash]);
|
||||
const [filterStatusId, setFilterStatusId] = useState('');
|
||||
const [filterPriorityId, setFilterPriorityId] = useState('');
|
||||
const [filterDueSoon, setFilterDueSoon] = useState(false);
|
||||
|
||||
const { data: projects, reload } = useAsync(
|
||||
() => listProjects(showTrash ? { trash: true } : { statusId: filterStatusId, priorityId: filterPriorityId }),
|
||||
[showTrash, filterStatusId, filterPriorityId]
|
||||
);
|
||||
const { data: priorities } = useAsync(() => listCatalog('priorities'), []);
|
||||
const { data: statuses } = useAsync(() => listCatalog('project-statuses'), []);
|
||||
const { data: types } = useAsync(() => listCatalog('project-types'), []);
|
||||
@@ -133,6 +140,14 @@ export default function ProyectosPage() {
|
||||
|
||||
if (!projects) return <div className="text-muted">{t('common_loading')}</div>;
|
||||
|
||||
const visibleProjects = filterDueSoon && !showTrash
|
||||
? projects.filter((p) => {
|
||||
if (p.status_is_closed || !p.estimated_end_date) return false;
|
||||
const diffDays = Math.round((new Date(p.estimated_end_date) - new Date()) / 86400000);
|
||||
return diffDays >= 0 && diffDays <= 7;
|
||||
})
|
||||
: projects;
|
||||
|
||||
return (
|
||||
<div>
|
||||
<div className="toolbar">
|
||||
@@ -155,11 +170,25 @@ export default function ProyectosPage() {
|
||||
|
||||
<div className="toolbar">
|
||||
<SearchInput value={search} onChange={setSearch} />
|
||||
{!showTrash && (
|
||||
<>
|
||||
<div style={{ width: 160 }}>
|
||||
<ComboBox options={[{ value: '', label: t('common_all') }, ...statusOptions]} value={filterStatusId} onChange={setFilterStatusId} placeholder={t('common_status')} />
|
||||
</div>
|
||||
<div style={{ width: 160 }}>
|
||||
<ComboBox options={[{ value: '', label: t('common_all') }, ...priorityOptions]} value={filterPriorityId} onChange={setFilterPriorityId} placeholder={t('common_priority')} />
|
||||
</div>
|
||||
<label className="checkbox-row">
|
||||
<input type="checkbox" checked={filterDueSoon} onChange={(e) => setFilterDueSoon(e.target.checked)} />
|
||||
{t('project_filter_due_soon')}
|
||||
</label>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<ListView
|
||||
columns={columns}
|
||||
rows={projects}
|
||||
rows={visibleProjects}
|
||||
searchValue={search}
|
||||
getSearchHaystack={(p) => `${p.code} ${p.name} ${p.owner_name} ${p.status_name}`}
|
||||
getRowKey={(p) => p.id}
|
||||
|
||||
Reference in New Issue
Block a user