Skip to content

Commit

Permalink
fix filter
Browse files Browse the repository at this point in the history
  • Loading branch information
xtian7489 committed Oct 25, 2024
1 parent 1e65c79 commit ad0c473
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
6 changes: 5 additions & 1 deletion src/app/page.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,15 @@ import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
import AssetListHome from "@/components/home/asset-list-home";
import BannerHome from "@/components/home/banner";
import DownloadButton from "@/components/admin/asset/download-button";
import { assetDestination } from "@/lib/utils/constants";

export const dynamic = "force-dynamic";

export default function Home({ searchParams: { estado, search, page } }) {
const destination = estado;
const destination = estado
? assetDestination.find((destination) => destination.slug === estado).value
: null;

return (
<div>
<BannerHome />
Expand Down
4 changes: 2 additions & 2 deletions src/components/admin/asset/asset-serch.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const AssetSerch = () => {
const router = useRouter();
const pathname = usePathname();
const searchParams = useSearchParams();
const [filter, setFilter] = useState("todos");
const [filter, setFilter] = useState(searchParams.get("estado") || "todos");
const [searchValue, setSearchValue] = useState(
searchParams.get("search") || ""
);
Expand Down Expand Up @@ -54,6 +54,7 @@ const AssetSerch = () => {
};

const handleFilter = (value) => {
setFilter(value);
const params = new URLSearchParams(searchParams.entries());

if (!value) {
Expand All @@ -66,7 +67,6 @@ const AssetSerch = () => {
const query = estado ? `?${estado}` : "";

router.push(`${pathname}${query}`);
setFilter(value);
};

return (
Expand Down
6 changes: 3 additions & 3 deletions src/lib/utils/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ export const fieldsInputTypes = [
];

export const assetDestination = [
{ value: 'auction', name: 'Subasta' },
{ value: 'reuse', name: 'Reutilización' },
{ value: 'Testing', name: 'Objeto de prueba' }
{ value: 'auction', name: 'Subasta', slug: 'subasta' },
{ value: 'reuse', name: 'Reutilización', slug: 'reutilizacion' },
{ value: 'Testing', name: 'Objeto de prueba', slug: 'objeto-de-prueba' }
]

export const actorType = [
Expand Down

0 comments on commit ad0c473

Please sign in to comment.