feat(settings): final migration of settings and edits added

This commit is contained in:
2025-11-25 14:36:06 -06:00
parent 3193e07e47
commit 7e15e5d7bc
11 changed files with 760 additions and 522 deletions

View File

@@ -0,0 +1,18 @@
import { keepPreviousData, queryOptions } from "@tanstack/react-query";
import axios from "axios";
export function getSettings() {
return queryOptions({
queryKey: ["getSettings"],
queryFn: () => fetchSession(),
staleTime: 5000,
refetchOnWindowFocus: true,
placeholderData: keepPreviousData,
});
}
const fetchSession = async () => {
const { data } = await axios.get("/lst/api/system/settings");
return data.data;
};

View File

@@ -0,0 +1,26 @@
import { createColumnHelper } from "@tanstack/react-table";
import { ArrowDown, ArrowUp } from "lucide-react";
import { Button } from "@/components/ui/button";
export const GenericColumn = ({ columnName }: { columnName: string }) => {
const columnHelper = createColumnHelper();
return columnHelper.accessor(`${columnName}`, {
header: ({ column }) => {
return (
<Button
variant="ghost"
onClick={() => column.toggleSorting(column.getIsSorted() === "asc")}
>
<span className="flex flex-row gap-2">{`${columnName.toUpperCase()}`}</span>
{column.getIsSorted() === "asc" ? (
<ArrowUp className="ml-2 h-4 w-4" />
) : (
<ArrowDown className="ml-2 h-4 w-4" />
)}
</Button>
);
},
cell: (i) => i.getValue(),
});
};

View File

@@ -1,6 +1,7 @@
import {
flexRender,
getCoreRowModel,
getFilteredRowModel,
getPaginationRowModel,
getSortedRowModel,
type SortingState,
@@ -26,6 +27,9 @@ export default function TableNoExpand({
columns: any;
}) {
const [sorting, setSorting] = useState<SortingState>([]);
// const [columnFilters, setColumnFilters] = React.useState<ColumnFiltersState>(
// []
// )
const table = useReactTable({
data,
columns,
@@ -33,11 +37,14 @@ export default function TableNoExpand({
getPaginationRowModel: getPaginationRowModel(),
onSortingChange: setSorting,
getSortedRowModel: getSortedRowModel(),
getFilteredRowModel: getFilteredRowModel(),
//renderSubComponent: ({ row }: { row: any }) => <ExpandedRow row={row} />,
//getRowCanExpand: () => true,
filterFns: {},
state: {
sorting,
//columnFilters
},
});
return (