Skip to content
Snippets Groups Projects
Commit db04d27a authored by Yusuf Akgül's avatar Yusuf Akgül :hatching_chick:
Browse files

fix filter after update

parent 12dd19e6
No related branches found
No related tags found
1 merge request!13Feat.next auth
Pipeline #35303 passed
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
import { Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectTrigger, SelectValue } from "@/components/ui/select"; import { Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectTrigger, SelectValue } from "@/components/ui/select";
import { usePathname, useRouter, useSearchParams } from "next/navigation"; import { usePathname, useRouter, useSearchParams } from "next/navigation";
import { useState } from "react"; import { useLayoutEffect, useState } from "react";
import { Icons } from "./icons"; import { Icons } from "./icons";
import { Button } from "./ui/button"; import { Button } from "./ui/button";
import { Card } from "./ui/card"; import { Card } from "./ui/card";
...@@ -36,7 +36,11 @@ export default function Sort() { ...@@ -36,7 +36,11 @@ export default function Sort() {
const url = `${pathname}${queryParamString ? `${queryParamString}` : ''}`; const url = `${pathname}${queryParamString ? `${queryParamString}` : ''}`;
router.replace(url); useLayoutEffect(() => {
if (queryParamString) {
router.replace(url);
}
}, [queryParamString, router, url]);
function toggleSortOrder() { function toggleSortOrder() {
const newSortOrder = selectedSortOrder === 'desc' ? 'asc' : 'desc'; const newSortOrder = selectedSortOrder === 'desc' ? 'asc' : 'desc';
...@@ -133,7 +137,7 @@ export default function Sort() { ...@@ -133,7 +137,7 @@ export default function Sort() {
</SelectGroup> </SelectGroup>
</SelectContent> </SelectContent>
</Select> </Select>
<Button variant="ghost" onClick={toggleSortOrder}> <Button variant="ghost" onClick={() => toggleSortOrder}>
<Icons.arrowdown className={`h-4 w-4 transition-all transform ${selectedSortOrder === 'asc' ? 'rotate-180' : ''}`} /> <Icons.arrowdown className={`h-4 w-4 transition-all transform ${selectedSortOrder === 'asc' ? 'rotate-180' : ''}`} />
</Button> </Button>
</div> </div>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment