commit21
This commit is contained in:
@@ -8,7 +8,9 @@ type Props = {
|
||||
modules: Record<string, string>;
|
||||
counts: Record<string, number>;
|
||||
checkedAt: string;
|
||||
filters: { module: string; search: string };
|
||||
asOf: string;
|
||||
deadlineCounts: Record<string, number>;
|
||||
filters: { module: string; search: string; due: string };
|
||||
tasks: {
|
||||
total: number;
|
||||
data: {
|
||||
@@ -19,6 +21,7 @@ type Props = {
|
||||
blocked: boolean;
|
||||
created_at: string | null;
|
||||
due_on: string | null;
|
||||
due_status: string;
|
||||
href: string;
|
||||
}[];
|
||||
prev_page_url: string | null;
|
||||
@@ -31,11 +34,20 @@ export default function Tasks({
|
||||
modules,
|
||||
counts,
|
||||
checkedAt,
|
||||
asOf,
|
||||
deadlineCounts,
|
||||
filters,
|
||||
tasks,
|
||||
}: Props) {
|
||||
const [search, setSearch] = useState(filters.search);
|
||||
const [module, setModule] = useState(filters.module);
|
||||
const [due, setDue] = useState(filters.due);
|
||||
const deadlines: Record<string, string> = {
|
||||
overdue: 'Prazo ultrapassado',
|
||||
today: 'Vence hoje',
|
||||
upcoming: 'Prazo futuro',
|
||||
undated: 'Sem prazo registado',
|
||||
};
|
||||
const path =
|
||||
area === 'people' ? '/pessoas/tarefas' : '/requisicoes/tarefas';
|
||||
return (
|
||||
@@ -81,7 +93,7 @@ export default function Tasks({
|
||||
event.preventDefault();
|
||||
router.get(
|
||||
path,
|
||||
{ module, search },
|
||||
{ module, search, due },
|
||||
{ preserveState: true },
|
||||
);
|
||||
}}
|
||||
@@ -114,6 +126,23 @@ export default function Tasks({
|
||||
}
|
||||
/>
|
||||
</label>
|
||||
<label>
|
||||
Prazo
|
||||
<select
|
||||
className={controlClass}
|
||||
value={due}
|
||||
onChange={(event) => setDue(event.target.value)}
|
||||
>
|
||||
<option value="all">Todos</option>
|
||||
{Object.entries(deadlines).map(
|
||||
([value, label]) => (
|
||||
<option key={value} value={value}>
|
||||
{label}
|
||||
</option>
|
||||
),
|
||||
)}
|
||||
</select>
|
||||
</label>
|
||||
<Button type="submit" variant="outline">
|
||||
Filtrar
|
||||
</Button>
|
||||
@@ -121,6 +150,16 @@ export default function Tasks({
|
||||
Limpar filtros
|
||||
</Link>
|
||||
</form>
|
||||
<p className="mb-4 text-sm text-muted-foreground">
|
||||
No módulo e pesquisa escolhidos, em {asOf}:{' '}
|
||||
{Object.entries(deadlines)
|
||||
.map(
|
||||
([value, label]) =>
|
||||
`${label}: ${deadlineCounts[value] ?? 0}`,
|
||||
)
|
||||
.join(' · ')}
|
||||
.
|
||||
</p>
|
||||
<p className="mb-4 text-sm text-muted-foreground">
|
||||
{tasks.total} tarefa(s) no filtro. Documentos mais
|
||||
antigos aparecem primeiro; esta ordem não define
|
||||
@@ -162,6 +201,8 @@ export default function Tasks({
|
||||
<p className="mt-2 text-sm">
|
||||
Prazo registado no processo:{' '}
|
||||
{task.due_on}
|
||||
{' · '}
|
||||
{deadlines[task.due_status]}
|
||||
</p>
|
||||
)}
|
||||
</article>
|
||||
|
||||
Reference in New Issue
Block a user