mirror of
https://github.com/marcogll/TaxHacker_s23.git
synced 2026-01-13 21:35:19 +00:00
fix: restore from backup, restart button for tools, loader for fields
This commit is contained in:
@@ -11,16 +11,16 @@ import {
|
||||
DropdownMenuTrigger,
|
||||
} from "@/components/ui/dropdown-menu"
|
||||
import { Field } from "@/prisma/client"
|
||||
import { ColumnsIcon } from "lucide-react"
|
||||
import { ColumnsIcon, Loader2 } from "lucide-react"
|
||||
import { useRouter } from "next/navigation"
|
||||
import { useState } from "react"
|
||||
|
||||
export function ColumnSelector({ fields, onChange }: { fields: Field[]; onChange?: () => void }) {
|
||||
const router = useRouter()
|
||||
const [isLoading, setIsLoading] = useState<{ [key: string]: boolean }>({})
|
||||
const [isLoading, setIsLoading] = useState(false)
|
||||
|
||||
const handleToggle = async (fieldCode: string, isCurrentlyVisible: boolean) => {
|
||||
setIsLoading((prev) => ({ ...prev, [fieldCode]: true }))
|
||||
setIsLoading(true)
|
||||
|
||||
try {
|
||||
await updateFieldVisibilityAction(fieldCode, !isCurrentlyVisible)
|
||||
@@ -34,7 +34,7 @@ export function ColumnSelector({ fields, onChange }: { fields: Field[]; onChange
|
||||
} catch (error) {
|
||||
console.error("Failed to toggle column visibility:", error)
|
||||
} finally {
|
||||
setIsLoading((prev) => ({ ...prev, [fieldCode]: false }))
|
||||
setIsLoading(false)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ export function ColumnSelector({ fields, onChange }: { fields: Field[]; onChange
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger asChild>
|
||||
<Button variant="outline" size="icon" title="Select table columns">
|
||||
<ColumnsIcon className="h-4 w-4" />
|
||||
{isLoading ? <Loader2 className="h-4 w-4 animate-spin" /> : <ColumnsIcon className="h-4 w-4" />}
|
||||
</Button>
|
||||
</DropdownMenuTrigger>
|
||||
<DropdownMenuContent align="end" className="w-56">
|
||||
@@ -53,10 +53,9 @@ export function ColumnSelector({ fields, onChange }: { fields: Field[]; onChange
|
||||
key={field.code}
|
||||
checked={field.isVisibleInList}
|
||||
onCheckedChange={() => handleToggle(field.code, field.isVisibleInList)}
|
||||
disabled={isLoading[field.code]}
|
||||
disabled={isLoading}
|
||||
>
|
||||
{field.name}
|
||||
{isLoading[field.code] && <span className="ml-2 text-xs opacity-50">Saving...</span>}
|
||||
</DropdownMenuCheckboxItem>
|
||||
))}
|
||||
</DropdownMenuContent>
|
||||
|
||||
Reference in New Issue
Block a user