Skip to content

formsSubstore

Manages the paginated list of available forms from the API, along with all filtering (category, search) and pagination state. Any change to a filter automatically resets the page to 1.

Table of contents

Properties

Methods


Properties

paginatedFormsData

paginatedFormsData: ApiResource<TApiFormsPaginated>

Paginated list of forms from the API, including loading and error state.

TApiFormsPaginated contains a content array of form summaries plus pagination metadata (totalPages, totalElements, etc.). Re-fetched automatically whenever any filter or pagination state changes. See ApiResource for the loading/error shape.

Related


masterCategoryId

masterCategoryId?: number

Currently active master-category filter.

When set, only forms belonging to the given master category are returned. Cleared by unsetCategoryIdByType. Mutually exclusive with superCategoryId and categoryId — setting one resets the others.

Related


superCategoryId

superCategoryId?: number

Currently active super-category filter.

When set, only forms belonging to the given super category are returned. See masterCategoryId for mutual-exclusivity behaviour.

Related


categoryId

categoryId?: number

Currently active category filter.

When set, only forms belonging to the given category are returned. See masterCategoryId for mutual-exclusivity behaviour.

Related


noCategory

noCategory: boolean

When true, only forms with no category are shown.

Toggled by setNoCategory. Resets page to 1 on change.

Related


search: string

Current free-text search string used to filter the forms list.

An empty string means no search filter is active. Updated by setSearch, which also resets page to 1.

Related


size

size: number

Number of forms to fetch per page.

Default value is set during store initialisation. Changing this triggers a re-fetch.

Related


page

page: number

Current page number (1-based).

Changed by setNextPage, setPreviousPage, and setPage. Automatically reset to 1 by any filter change.

Related


totalPages

totalPages: number

Total number of pages based on the last API response.

Synced from the TApiFormsPaginated response payload. Used as the upper bound in setNextPage.

Related


Methods

setNextPage

setNextPage: () => void

Advances to the next page, capped at totalPages.

Does nothing when page is already equal to totalPages.

Related


setPreviousPage

setPreviousPage: () => void

Goes back one page, capped at 1.

Does nothing when page is already 1.

Related


setPage

setPage: (page: number) => void

Sets the current page to an arbitrary number.

Parameters

NameTypeDescription
pagenumberTarget page number (1-based)

Related


setCategoryIdByType

setCategoryIdByType: (
args:
| { masterCategoryId: number }
| { superCategoryId: number }
| { categoryId: number },
) => void

Sets a master-, super-, or category-level filter and resets pagination to page 1.

Pass exactly one of the three keys. The other two category filters are cleared automatically.

Parameters

NameTypeDescription
args{ masterCategoryId: number } | { superCategoryId: number } | { categoryId: number }The filter to apply

Related


unsetCategoryIdByType

unsetCategoryIdByType: () => void

Clears the active category filter and resets pagination to page 1.

Clears whichever of masterCategoryId, superCategoryId, or categoryId is currently set.

Related


setNoCategory

setNoCategory: (noCategory: boolean) => void

Toggles the “no-category” filter and resets pagination to page 1.

Parameters

NameTypeDescription
noCategorybooleantrue to show only forms without a category

Related


setSearch

setSearch: (search: string) => void

Updates the free-text search string used to filter forms.

Resets page to 1 on change.

Parameters

NameTypeDescription
searchstringSearch string (empty string clears the filter)

Related


prefetchForms

prefetchForms: (args: {
masterCategoryId?: number;
superCategoryId?: number;
categoryId?: number;
}) => void

Prefetches forms for a given category combination without affecting the current displayed state.

Use this to warm the cache before the user navigates to a category (e.g., on hover). The prefetched data is stored in the query cache and used automatically when the user activates the matching filter.

Parameters

NameTypeDescription
args.masterCategoryIdnumber (optional)Master category to prefetch
args.superCategoryIdnumber (optional)Super category to prefetch
args.categoryIdnumber (optional)Category to prefetch

Related