AlexsLemonade / refinebio-web

Refinebio Web
https://staging.web.refine.bio
BSD 3-Clause "New" or "Revised" License
1 stars 0 forks source link

Implement useCompendia hook for compendia #152

Closed nozomione closed 1 year ago

nozomione commented 1 year ago

Context

As with the existing refine.bio, when users visit the compendia page, we want to be able to display the available downloadable compendia for the normalized and RNA-seq sample.

Problem or idea

We'll implement the hook useCompendia which includes the states and methods required to render the compendia data in UI and handle the file download.

Each exposed method of this manager should correspond to the behavior of the application and indirectly communicates with the API using the refinebio-js helper.

The implementation details and pseudocode is as follows:

❚ State Management

The hook contains the following states.

compendia: (an object) the compendia data fetched from API setCompendia: an async method for setting compendia

loading: (boolean) the loading indicator for the compendia data setLoading: an async method for setting loading

❚ Method

These methods are primarily used in the UI and each one corresponds to a specific application behavior.

(Parameters marked with * are required).

getCompendia(quantSfOnly = boolean, token = null) return void

downloadCompendia(id*, token*) return object

navigateToFileDownload(organism*, url*) return void

Example: We'll make the API request to the compendia endpoint by calling getCompendia from the compendia page component for the RNA-seq Sample tab:

getCompendia(true) 

Solution or next step