Skip to content

useRunsStore

This store persists reduced data of all runs to display it on the runs table in Our Runs nav-item

📄 View source on GitHub

Used by

Used Stores

State

NameTypeDescription
rawRunsrefRun data as loaded from the API
loadingrefLoading state
errorrefError state
targetDaterefNext week's run date
itemsPerPagerefDefines the itemes per page in `RunsTable
pagerefCurrent page visible in `RunsTable

Initialization

initializeRunsStore 🚀

Initializes the runs store. Tries to load the state from local storage, and if skipFetch is not set to true, fetches the runs data from the backend and updates the store.

Actions

persist

Persists the store's state to local storage.

fetchRuns

Fetches run data from the /runs endpoint of the backend, including hare images and location details. Updates the rawRuns state with the fetched data and handles loading and error states. Utilizes pagination to efficiently retrieve data from the server. Resets the loading state and persists any changes after completion.

Getters/Setters

runs (computed)

Transforms the rawRuns data into a format to be used in the RunsTable component.

runsWithFinancialReport (computed)

Creates a list of runs which have a financial report (after 2025-04-02). The financial report functionality was only introduced after deployment of the new website and the implementation of the sales functionality in the Sign-In App. Kind of a tricky decision to make we need to decide when the new report is visible in the selection - decided for an empty report from Tuesday onwards

targetIndex (computed)

Computes the index of the target run in the runs array. This is required to determine the table page where the most actual run is located

initialPage (computed)

Computes the initial page number based on the index of the target run. If the target run is not found, returns 1. This is required to determine the table page where the most actual run is located

Released under the MIT License.