Subscribe to activity level changes of a location. Usage of this hook will
re-render your component whenever activity data is received from the server
Your component will be automatically unsubscribed from a location whenever
your component is unmounted or the locationId
changes.
The id of the location to subscribe to
The activity level that will be set on initial render
The current activity level of the location
Log in a user based on email and password.
Logout a user.
Retrieve a handle to the currently logged in user and all the data associated with the user.
If no user is logged in, null
will be returned. Internally, the user is
stored in a state variable and will therefore re-render your component
whenever it changes.
The currently logged in user (if any)
Fetches and caches all categories.
Fetches and caches the contact information for a nation.
Fetches and caches a single Event.
See all available query parameters here: EventQueryParams.
The id of the Event to fetch
Event filtering params
Fetches and caches a single Event long description. This should be used when you want to show the full (long) description of an event. It is not needed in the timeline, only when the user wants to read more of an event.
The id of the Event to fetch
Fetches and caches Events.
If oid
is set, e.g. not undefined
or null
, only the events for that
specific Nation will be fetched.
See all available query parameters here: EventQueryParams. Note that you do not need to specify any query data.
This hook supports infinite loading. To fetch more data, e.g. while scrolling, do the following:
const { data, error, pagination, size, setSize } = useEvents(null, { amount: 9 })
You can then load more events by increasing the size
using setSize(size + 1)
.
Of course, you can also decrease the size by doing setSize(size - 1)
.
To use regular pagination, i.e. to render only the data for the page and not the previous pages, you can do the following:
const [page, setPage] = useState(1)
const { data, error, pagination } = useEvents(null, { page, amount: 9 })
As you can see, the only difference between the two is which state variable you use to decide which page to load.
The oid of the Nation to fetch events for.
Event filtering params
Fetches and caches a single individual.
Fetches and caches all individuals for a nation.
Fetches and caches a single Location.
The id of the Location to fetch
Fetches and caches all Locations for a Nation.
The oid of the Nation to fetch locations of
Fetches and caches a single Menu.
The id of the Menu to fetch the menus of
Fetches and caches a single MenuItem.
The id of the MenuItem to fetch
Fetches and caches all MenuItems for a Menu.
See all available query parameters here: PaginationQueryParams.
The id of the Menu to fetch the items of
Fetches and caches all Menus for a Location.
The id of the Location to fetch the menus of
Fetches and caches a single Nation.
Note that the oid
MUST be a number, otherwise, the request will fail.
The oid of the Nation to fetch
Fetches and caches all Nations.
Fetches and caches all notifications for a token.
See all available query parameters here: NotificationQueryParams.
Fetches and caches a single OpeningHour.
The id of the Location to fetch opening hour of
The id of the OpeningHour to fetch
Fetches and caches all OpeningHours for a location.
The id of the Location to fetch opening hours of
Fetches and caches a single subscription.
Fetches and caches a single subscription topic.
Fetches and caches all subscription topics.
Fetches and caches all subscriptions for a token.
Retrieve a handle to the API client for making authenticated POST
, PUT
and
DELETE
requests. This should only be used if you want to implement
functionality for student nation staff. Fetching data should be done using
one of the available fetcher hooks since they will cache your data using SWR.
Hook used to get all the available data from the SDK context. The returned data in this hook is subject to change and it is recommended to instead use the shorthand hooks for extracting your data:
Hook to upload images to resources, e.g. student nation or menu items. Only supports a single upload, i.e. you can not upload both an icon and a cover image for a nation with a single call to this hook. If you want to allow multiple uploads, you need to call this hook once for each upload.
This hook will automatically add the file blob to the upload function that you select. This means that you can omit the last argument of the upload function. You can see an example of this below.
For each upload you must specify the form field (i.e. the upload that you want to make). The available upload fields can be seen in the respective service, e.g.:
The resource that will be returned in the result after uploading, i.e. a Nation
The upload function to use when execute()
is called.
Upload function arguments with the file blob (last argument) omitted
Generated using TypeDoc
React hooks
Contains all the available React hooks in the SDK.
Fetcher functions are cached by default using SWR. This includes data revalidation, automatic rehydration and more. Every fetcher hooks exposes all of the returned values from the
useSWR
hook. This means that you can refer to the SWR documentation for information about how the fetcher hooks can be used.For the other CRUD functions, i.e.
POST
,PUT
andDELETE
operations, we useuseAsync
anduseAsyncCallback
from the react-async-hook package.SWR
react-async-hook