style: clean up code with prettier and eslint
This commit is contained in:
1 parent
60278b9e71
commit
fb8e77bb68
378 files changed
+22407
-20689
No files matched your search
@@ -1,38 +1,38 @@
|
||||
'use client'
|
||||
"use client";
|
||||
|
||||
import { FolderTree, HardHat, List, Package } from 'lucide-react'
|
||||
import { useRouter, useSearchParams } from 'next/navigation'
|
||||
import { Button } from '@/components/ui/button'
|
||||
import { cn } from '@/lib/utils'
|
||||
import { FolderTree, HardHat, List, Package } from "lucide-react";
|
||||
import { useRouter, useSearchParams } from "next/navigation";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
interface CatalogViewToggleProps {
|
||||
currentView: string
|
||||
catalogType?: string
|
||||
currentView: string;
|
||||
catalogType?: string;
|
||||
}
|
||||
|
||||
export function CatalogViewToggle({ currentView, catalogType = 'normal' }: CatalogViewToggleProps) {
|
||||
const router = useRouter()
|
||||
const searchParams = useSearchParams()
|
||||
export function CatalogViewToggle({ currentView, catalogType = "normal" }: CatalogViewToggleProps) {
|
||||
const router = useRouter();
|
||||
const searchParams = useSearchParams();
|
||||
|
||||
function setView(view: string) {
|
||||
const params = new URLSearchParams(searchParams.toString())
|
||||
if (view === 'tree') {
|
||||
params.delete('view')
|
||||
const params = new URLSearchParams(searchParams.toString());
|
||||
if (view === "tree") {
|
||||
params.delete("view");
|
||||
} else {
|
||||
params.set('view', view)
|
||||
params.set("view", view);
|
||||
}
|
||||
router.push(`?${params.toString()}`)
|
||||
router.push(`?${params.toString()}`);
|
||||
}
|
||||
|
||||
function setCatalog(type: string) {
|
||||
const params = new URLSearchParams(searchParams.toString())
|
||||
if (type === 'normal') {
|
||||
params.delete('catalog')
|
||||
const params = new URLSearchParams(searchParams.toString());
|
||||
if (type === "normal") {
|
||||
params.delete("catalog");
|
||||
} else {
|
||||
params.set('catalog', type)
|
||||
params.set("catalog", type);
|
||||
}
|
||||
params.delete('view') // reset to tree when switching
|
||||
router.push(`?${params.toString()}`)
|
||||
params.delete("view"); // reset to tree when switching
|
||||
router.push(`?${params.toString()}`);
|
||||
}
|
||||
|
||||
return (
|
||||
@@ -42,8 +42,8 @@ export function CatalogViewToggle({ currentView, catalogType = 'normal' }: Catal
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
className={cn('h-8 rounded-r-none', catalogType === 'normal' && 'bg-accent')}
|
||||
onClick={() => setCatalog('normal')}
|
||||
className={cn("h-8 rounded-r-none", catalogType === "normal" && "bg-accent")}
|
||||
onClick={() => setCatalog("normal")}
|
||||
>
|
||||
<Package className="mr-1.5 h-4 w-4" />
|
||||
Catalog
|
||||
@@ -51,8 +51,8 @@ export function CatalogViewToggle({ currentView, catalogType = 'normal' }: Catal
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
className={cn('h-8 rounded-l-none', catalogType === 'bc' && 'bg-accent')}
|
||||
onClick={() => setCatalog('bc')}
|
||||
className={cn("h-8 rounded-l-none", catalogType === "bc" && "bg-accent")}
|
||||
onClick={() => setCatalog("bc")}
|
||||
>
|
||||
<HardHat className="mr-1.5 h-4 w-4" />
|
||||
Builder Club
|
||||
@@ -64,8 +64,8 @@ export function CatalogViewToggle({ currentView, catalogType = 'normal' }: Catal
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
className={cn('h-8 rounded-r-none', currentView === 'tree' && 'bg-accent')}
|
||||
onClick={() => setView('tree')}
|
||||
className={cn("h-8 rounded-r-none", currentView === "tree" && "bg-accent")}
|
||||
onClick={() => setView("tree")}
|
||||
>
|
||||
<FolderTree className="mr-1.5 h-4 w-4" />
|
||||
Tree
|
||||
@@ -73,13 +73,13 @@ export function CatalogViewToggle({ currentView, catalogType = 'normal' }: Catal
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
className={cn('h-8 rounded-l-none', currentView === 'table' && 'bg-accent')}
|
||||
onClick={() => setView('table')}
|
||||
className={cn("h-8 rounded-l-none", currentView === "table" && "bg-accent")}
|
||||
onClick={() => setView("table")}
|
||||
>
|
||||
<List className="mr-1.5 h-4 w-4" />
|
||||
Table
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user