worldcubeassociation.org icon indicating copy to clipboard operation
worldcubeassociation.org copied to clipboard

Media table migration to react component

Open MibettyMeanie opened this issue 2 years ago • 3 comments

React component to render media table in multimedia page

MibettyMeanie avatar Aug 09 '23 03:08 MibettyMeanie

Hi @MibettyMeanie! Thanks for the PR on this. The main change I think we need to make is to move to serving the Media data via an API, rather than as a Rails object (@media) in the View.

I've done my best to explain this here - please let me know if any of that doesn't make sense, I'd be happy to help further!

Specifically, I think we'd need to make the following changes:

  • [ ] Have get_mediareturn a JSON of the data it fetches
  • [ ] Create a /media API endpoint (it doesn't look like we have one at the moment) which returns the JSON that get_media creates
    • [ ] This endpoint should accept the parameters that get_media expects (year, region, status). I'd suggest that we pass these parameters as URL parameters
  • [ ] Update your React code to fetch this data via the API call, rather than expecting to receive it immediately from the view (once it has the data, no change should be needed - the JSON format from the API can match pretty closely the one you get from the view at the moment)

Let me know if any of that doesn't make sense, or if there's anything I can do to help! I am literally here to help :P

dunkOnIT avatar Sep 22 '23 14:09 dunkOnIT

Thanks a lot for the review @coder13 and @dunkOnIT. I'll work on the changes you both suggested and will push it soon.

MibettyMeanie avatar Sep 23 '23 11:09 MibettyMeanie

Hi @MibettyMeanie! Thanks for the PR on this. The main change I think we need to make is to move to serving the Media data via an API, rather than as a Rails object (@media) in the View.

I've done my best to explain this here - please let me know if any of that doesn't make sense, I'd be happy to help further!

Specifically, I think we'd need to make the following changes:

  • [ ] Have get_mediareturn a JSON of the data it fetches

  • [ ] Create a /media API endpoint (it doesn't look like we have one at the moment) which returns the JSON that get_media creates

    • [ ] This endpoint should accept the parameters that get_media expects (year, region, status). I'd suggest that we pass these parameters as URL parameters
  • [ ] Update your React code to fetch this data via the API call, rather than expecting to receive it immediately from the view (once it has the data, no change should be needed - the JSON format from the API can match pretty closely the one you get from the view at the moment)

Let me know if any of that doesn't make sense, or if there's anything I can do to help! I am literally here to help :P

Hey @dunkOnIT, I have added API referring to other controllers and it is now only for fetching and updating, the old controller has ruby API's which are used in the edit view (I haven't changed it in this PR). Also @danieljames-dj informed me that WCT leader has asked him not to delete rejected media from table rather than keep it intact with the status as rejected, so I have implemented like that.

MibettyMeanie avatar Feb 03 '24 10:02 MibettyMeanie