-
Notifications
You must be signed in to change notification settings - Fork 66
Talking to APIs
these just do a http request (using ky
) with the right csrf token
use in actions and other hooks
use*Request
seem to be similar to the above, with more error handling?
eg. useGetRequest
returns a function (url, query?)
for use by useSWR
useGet
takes (url, query?, refreshInterval?)
and returns { data, error, refresh, isLoading }
- using useSWR
use in detail screen
use in list screens
import { idKeyFn, useHubView } from '../useHubView';
import { hubAPI } from '../api';
// const toolbarFilters = useApprovalFilters();
// const tableColumns = useApprovalsColumns();
const view = useHubView<Approval>(
hubAPI`/_ui/v1/collection-versions/`,
idKeyFn,
toolbarFilters,
tableColumns
);
// <PageTable {...view} />
import { getIdFromPulpHref, usePulpView } from '../usePulpView';
import { pulpAPI } from '../api';
// const toolbarFilters = useTaskFilters();
// const tableColumns = useTaskColumns();
const view = usePulpView<Task>(
pulpAPI`/tasks/`,
pulpHRefKeyFn,
toolbarFilters,
tableColumns
);
// <PageTable {...view} />
under the hood, these use useSWR (via framework/useView
)
and the view returns:
// from useView
page, setPage, perPage, setPerPage,
sort, setSort, sortDirection, setSortDirection,
filters, setFilters, clearAllFilters,
// from useSelected
selectedItems, selectItem, unselectItem, isSelected,
selectItems, selectAll, unselectAll, allSelected,
keyFn, unselectItems,
// only in useHubView
unselectItemsAndRefresh,
// common
error
itemCount
pageItems
refresh
PageFramework
PageHeader
PageLayout
PageDashboard
PageDashboardCarousel
PageDetails
PageForm
PageTable
PageTabs
PageToolbar
BulkActionDialog
BulkConfirmationDialog
EmptyState
PageCarousel
ReorderItems
useBreakPoint
useFrameworkTranslations
useInMemoryView
useIsMounted
useOpen
usePageNavigate
useSearchParams
useSelectDialog
useTableItems
useView
useWindowLocation
useDeleteRequest
useGet
useGetAllPagesAWX
useGetItem
useGetRequest
useOptions
usePatchRequest
usePostRequest