Skip to content

Conversation

nozomione
Copy link
Member

Issue Number

Closes #1407

Purpose/Implementation Notes

I've bootstrap the useDataset hook.

Changes include:

  • Bootstrap the useDataset hook with following methods:
    • create
    • get
    • process
    • update
    • getErrorMessage : returns a error message that matches the corresponding status code on API request failure

Types of changes

  • New feature (non-breaking change which adds functionality)

Functional tests

N/A

Checklist

  • Lint and unit tests pass locally with my changes
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)
  • Any dependent changes have been merged and published in downstream modules

Screenshots

N/A

@nozomione nozomione self-assigned this Sep 5, 2025
@nozomione nozomione linked an issue Sep 5, 2025 that may be closed by this pull request
Copy link
Contributor

@davidsmejia davidsmejia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One comment for maintainability otherwise LGTM

Comment on lines 20 to 29
switch (statusCode) {
case 400:
case 403:
case 404:
case 405:
case 409:
return exceptions[statusCode]
default:
return defaultMessage
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
switch (statusCode) {
case 400:
case 403:
case 404:
case 405:
case 409:
return exceptions[statusCode]
default:
return defaultMessage
}
if (statusCode in exceptions) {
return exceptions[statusCode]
}
return defaultMessage

I think something like this would be easier to maintain since you already have defined the supported codes.

I don't think we want to be presenting the HTTP errors to the user. For now this is ok but we should have a TODO to handle recoverable errors for now at least.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Much cleaner using the in operator! I've also added a TODO comment for recoverable error handling.

Copy link
Contributor

@avrohomgottlieb avrohomgottlieb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM


const process = async (dataset) => {
if (!token) {
addError('A valid token is required to update the dataset')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
addError('A valid token is required to update the dataset')
addError('A valid token is required to process the dataset')

…set.getErrorMessage and add a TODO comment for recoverable error handling, and fix a typo in useDataset.process
@nozomione nozomione merged commit 3f635d9 into feature/dataset-integration Sep 8, 2025
5 checks passed
@nozomione nozomione deleted the nozomione/1407-add-use-dataset-hook branch September 8, 2025 22:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add useDataset hook
3 participants