feat: update sorting options and default values in RicercaProvider; refine filter logic in RicercaFilters
This commit is contained in:
parent
d116ebd3d5
commit
4ca16be4a4
3 changed files with 11 additions and 10 deletions
|
|
@ -1,6 +1,5 @@
|
|||
TODOS:
|
||||
|
||||
- Modale admin conferma mostrare scorciatoia a doc lavoro o simile per facilitare la verifica e sezione per override pack in base a doc presentati
|
||||
- Modale Admin conferma, selettore per fast modifica di permanenza
|
||||
- Post modale conferma, mostrare se transitorio , modale con informativa tipo:" il saldo del servizio e il periodo di permanenza veranno adeguati alle condizioni stabilite insieme al locatore nel momento della trattativa e alla documentazione presentata come giustificazione di transitorietà" (modificato)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -238,7 +238,7 @@ const RicercaFilters = () => {
|
|||
<SelectFilter
|
||||
defaultValue={sort}
|
||||
handleReset={async () => {
|
||||
await setSort("");
|
||||
await setSort("Recenti");
|
||||
}}
|
||||
label={t.ordina_per}
|
||||
onValueChange={async (value: SortTypes) => {
|
||||
|
|
@ -451,12 +451,12 @@ export const SelectFilter = <T extends string>({
|
|||
<Label
|
||||
className={cn(
|
||||
"font-semibold text-muted-foreground",
|
||||
value !== "" && "text-primary",
|
||||
value !== defaultValue && "text-primary",
|
||||
)}
|
||||
>
|
||||
{label}
|
||||
</Label>
|
||||
{value !== "" && (
|
||||
{value !== defaultValue && (
|
||||
<button onClick={handleReset} type="button">
|
||||
<RotateCcwIcon className="size-4" />
|
||||
</button>
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ type RicercaContextType = {
|
|||
isLoading: boolean;
|
||||
};
|
||||
|
||||
const sortOptions = ["Recenti", "Prezzo", "Consegna", "Mq", ""] as const;
|
||||
const sortOptions = ["Recenti", "Prezzo", "Consegna", "Mq"] as const;
|
||||
|
||||
//sort as string union
|
||||
export type SortTypes = (typeof sortOptions)[number];
|
||||
|
|
@ -96,7 +96,7 @@ export const RicercaProvider: FC<{
|
|||
const [sort, setSort] = useQueryState(
|
||||
"sort",
|
||||
parseAsStringLiteral(sortOptions)
|
||||
.withDefault("")
|
||||
.withDefault("Recenti")
|
||||
.withOptions({ startTransition }),
|
||||
);
|
||||
|
||||
|
|
@ -152,15 +152,17 @@ export const RicercaProvider: FC<{
|
|||
await setTipo("");
|
||||
await setComune("");
|
||||
await setConsegna(null);
|
||||
await setSort("");
|
||||
await setSort("Recenti");
|
||||
await setPage(0);
|
||||
};
|
||||
|
||||
const nFiltri =
|
||||
[tipo, comune, sort].reduce(
|
||||
[tipo, comune].reduce(
|
||||
(count, item) => (item !== "" ? count + 1 : count),
|
||||
0,
|
||||
) + (consegna !== null ? 1 : 0);
|
||||
) +
|
||||
(consegna !== null ? 1 : 0) +
|
||||
(sort !== "Recenti" ? 1 : 0);
|
||||
|
||||
return (
|
||||
<RicercaContext.Provider
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue