@@ -343,21 +323,13 @@ const AnnunciList = () => {
consegna,
sort,
map,
- page,
isLoading: ricercaLoading,
- annunciNumber,
} = useRicerca();
- const {
- data,
- status,
- //isPlaceholderData
- } = api.annunci.getWithCursor.useQuery(
+ const { data, status } = api.annunci.annunciRicerca.useQuery(
{
comune: comune || undefined,
consegna: consegna || undefined,
- page,
- pageSize: annunciNumber,
sort: sort || undefined,
tipologia: tipo || undefined,
},
@@ -368,58 +340,6 @@ const AnnunciList = () => {
},
);
- /*
- DISABILITATO FUNZIONALITA PAGING E PAGE SIZE
-
- const utils = api.useUtils();
- useEffect(() => {
- const prefetchData = async () => {
- if (!isPlaceholderData && data?.hasMore) {
- await utils.annunci.getWithCursor.prefetch({
- comune: comune || undefined,
- consegna: consegna || undefined,
- page: page + 1,
- pageSize: annunciNumber,
- sort: sort || undefined,
- tipologia: tipo || undefined,
- });
- }
- };
- prefetchData().catch((err) => {
- console.error("Error prefetching next page:", err);
- });
- }, [data, isPlaceholderData, page, annunciNumber]);
-
- useEffect(() => {
- // Reset to page 0 if current page has no data or less than page size
- const checkPage = async () => {
- if (data) {
- if (data.annunci.length === 0 && page !== 0) {
- await setPage(0);
- }
- }
- };
- checkPage().catch((err) => {
- console.error("Error checking data for page reset:", err);
- });
- }, [data, tipo, comune, consegna, sort, setPage, annunciNumber]);
-
- const [debouncedAnnunciNumber, setDebouncedAnnunciNumber] =
- useState(annunciNumber);
-
- useDebounce(
- async () => {
- console.log("Setting annunciNumber to", debouncedAnnunciNumber);
- console.log("Current annunciNumber is", annunciNumber);
- if (debouncedAnnunciNumber !== annunciNumber) {
- await setAnnunciNumber(debouncedAnnunciNumber);
- await setPage(0);
- }
- },
- 500,
- [debouncedAnnunciNumber],
- );
-*/
if (ricercaLoading) return
;
if (status === "error") return
;
@@ -429,7 +349,7 @@ const AnnunciList = () => {
) : (
- {data.annunci.map((annuncio, idx) => (
+ {data.map((annuncio, idx) => (
{
))}
)}
-
- {/*
-
-
- annunci per pagina:
-
- {
- if (val !== undefined) {
- setDebouncedAnnunciNumber(val);
- }
- }}
- value={debouncedAnnunciNumber}
- />
-
-
- {page >= 2 && (
-
- )}
-
-
-
-
- {page + 1}
-
-
-
-
-
*/}
);
};
diff --git a/apps/infoalloggi/src/providers/RicercaProvider.tsx b/apps/infoalloggi/src/providers/RicercaProvider.tsx
index 655dbaf..58bd038 100644
--- a/apps/infoalloggi/src/providers/RicercaProvider.tsx
+++ b/apps/infoalloggi/src/providers/RicercaProvider.tsx
@@ -41,15 +41,8 @@ type RicercaContextType = {
tipologieOptions: string[];
consegnaOptions: number[];
sortOptions: typeof sortOptions;
- page: number;
- setPage: (
- value: number | ((old: number | null) => number | null) | null,
- ) => Promise