ui(admin): cleanup table hooks, more...

This commit is contained in:
Matthew Penner 2021-07-19 14:37:09 -06:00
parent 7524bbe8ee
commit 6879ca4054
11 changed files with 11 additions and 24 deletions

View File

@ -1,7 +1,7 @@
import http, { FractalResponseData, getPaginationSet, PaginatedResult } from '@/api/http';
import { useContext } from 'react';
import useSWR from 'swr';
import { createContext } from '@/api/admin/admin';
import { createContext } from '@/api/admin';
export interface Database {
id: number;

View File

@ -1,7 +1,7 @@
import http, { FractalResponseData, getPaginationSet, PaginatedResult } from '@/api/http';
import { useContext } from 'react';
import useSWR from 'swr';
import { createContext } from '@/api/admin/admin';
import { createContext } from '@/api/admin';
export interface Location {
id: number;

View File

@ -1,7 +1,7 @@
import http, { FractalResponseData, FractalResponseList, getPaginationSet, PaginatedResult } from '@/api/http';
import { useContext } from 'react';
import useSWR from 'swr';
import { createContext } from '@/api/admin/admin';
import { createContext } from '@/api/admin';
import { Egg, rawDataToEgg } from '@/api/admin/eggs/getEgg';
import { Node, rawDataToNode } from '@/api/admin/nodes/getNodes';
import { Server, rawDataToServer } from '@/api/admin/servers/getServers';

View File

@ -1,7 +1,7 @@
import http, { getPaginationSet, PaginatedResult } from '@/api/http';
import { useContext } from 'react';
import useSWR from 'swr';
import { createContext } from '@/api/admin/admin';
import { createContext } from '@/api/admin';
import { Egg, rawDataToEgg } from '@/api/admin/eggs/getEgg';
export interface Filters {

View File

@ -1,7 +1,7 @@
import http, { FractalResponseData, FractalResponseList, getPaginationSet, PaginatedResult } from '@/api/http';
import { useContext } from 'react';
import useSWR from 'swr';
import { createContext } from '@/api/admin/admin';
import { createContext } from '@/api/admin';
import { Egg, rawDataToEgg } from '@/api/admin/eggs/getEgg';
export interface Nest {

View File

@ -1,7 +1,7 @@
import http, { FractalResponseData, getPaginationSet, PaginatedResult } from '@/api/http';
import { useContext } from 'react';
import useSWR from 'swr';
import { createContext } from '@/api/admin/admin';
import { createContext } from '@/api/admin';
import { Database, rawDataToDatabase } from '@/api/admin/databases/getDatabases';
import { Location, rawDataToLocation } from '@/api/admin/locations/getLocations';

View File

@ -1,7 +1,7 @@
import http, { FractalResponseData, getPaginationSet, PaginatedResult } from '@/api/http';
import { useContext } from 'react';
import useSWR from 'swr';
import { createContext } from '@/api/admin/admin';
import { createContext } from '@/api/admin';
export interface Role {
id: number;

View File

@ -2,7 +2,7 @@ import { Egg, rawDataToEgg } from '@/api/admin/eggs/getEgg';
import http, { FractalResponseData, getPaginationSet, PaginatedResult } from '@/api/http';
import { useContext } from 'react';
import useSWR from 'swr';
import { createContext } from '@/api/admin/admin';
import { createContext } from '@/api/admin';
import { Node, rawDataToNode } from '@/api/admin/nodes/getNodes';
import { User, rawDataToUser } from '@/api/admin/users/getUsers';

View File

@ -1,7 +1,7 @@
import http, { FractalResponseData, getPaginationSet, PaginatedResult } from '@/api/http';
import { useContext } from 'react';
import useSWR from 'swr';
import { createContext } from '@/api/admin/admin';
import { createContext } from '@/api/admin';
export interface User {
id: number;

View File

@ -7,22 +7,9 @@ import Spinner from '@/components/elements/Spinner';
import styled from 'styled-components/macro';
import tw from 'twin.macro';
import { PaginatedResult, PaginationDataSet } from '@/api/http';
import { ListContext as TableHooks } from '@/api/admin';
interface Hooks<T> {
page: number;
setPage: (page: ((p: number) => number) | number) => void;
filters: T | null;
setFilters: (filters: ((f: T | null) => T | null) | T | null) => void;
sort: string | null;
setSort: (sort: string | null) => void;
sortDirection: boolean;
setSortDirection: (direction: ((p: boolean) => boolean) | boolean) => void;
}
export function useTableHooks<T> (): Hooks<T> {
export function useTableHooks<T> (): TableHooks<T> {
const [ page, setPage ] = useState<number>(1);
const [ filters, setFilters ] = useState<T | null>(null);
const [ sort, setSortState ] = useState<string | null>(null);