Reconciliar fontes instaladas 423bd512d8c5 com main
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import SearchState from '@/components/search-state';
|
||||
import { useEffect, useState } from 'react';
|
||||
import InvestmentTerritory from '@/components/investment-territory';
|
||||
import { Management, Field, control } from './shared';
|
||||
@@ -10,8 +11,11 @@ export default function TerritoryAssociations() {
|
||||
const [rows, setRows] = useState<{ id: string; name: string }[]>([]);
|
||||
const [more, setMore] = useState(false);
|
||||
const [error, setError] = useState('');
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [retry, setRetry] = useState(0);
|
||||
useEffect(() => {
|
||||
const controller = new AbortController();
|
||||
setLoading(true); setError(''); setRows([]);
|
||||
const timer = setTimeout(async () => {
|
||||
try {
|
||||
const params = new URLSearchParams({
|
||||
@@ -31,21 +35,22 @@ export default function TerritoryAssociations() {
|
||||
'Não foi possível carregar os investimentos.',
|
||||
);
|
||||
const data = await response.json();
|
||||
if (controller.signal.aborted) return;
|
||||
setRows(data.data);
|
||||
setMore(Boolean(data.next_page_url));
|
||||
setError('');
|
||||
} catch (e) {
|
||||
} catch {
|
||||
if (!controller.signal.aborted)
|
||||
setError(
|
||||
e instanceof Error ? e.message : 'Erro de ligação.',
|
||||
'Não foi possível concluir a pesquisa.',
|
||||
);
|
||||
}
|
||||
} finally { if (!controller.signal.aborted) setLoading(false); }
|
||||
}, 250);
|
||||
return () => {
|
||||
clearTimeout(timer);
|
||||
controller.abort();
|
||||
};
|
||||
}, [kind, q, page]);
|
||||
}, [kind, q, page, retry]);
|
||||
return (
|
||||
<Management title="Localizações dos investimentos">
|
||||
<Field label="Tipo de investimento">
|
||||
@@ -71,6 +76,7 @@ export default function TerritoryAssociations() {
|
||||
<option value="opportunities">Oportunidades</option>
|
||||
</select>
|
||||
</Field>
|
||||
<SearchState loading={loading} error={error} total={rows.length} retry={() => setRetry(value => value + 1)} />
|
||||
<Field label="Pesquisar investimento">
|
||||
<input
|
||||
className={control}
|
||||
|
||||
Reference in New Issue
Block a user