Skip to content
This repository was archived by the owner on Mar 4, 2025. It is now read-only.

fixed appirio-tech/topcoder-app/issues/1040 refactored details page b… #480

Merged

Conversation

shubhendusaurabh
Copy link
Contributor

fixed topcoder-archive/appirio_tech-topcoder-app/issues/1040 refactored details page btons

@birdofpreyru
Copy link
Collaborator

Hey, so far I've just briefly looked at the code, and I might misunderstood something (don't hesitate to argue and correct me), but here are the changes, I believe you should make:

  1. Get rid of the getButton() function in its current form. I believe, now each time you call this function, it first creates a new buttons object, and then returns the specified button from that object - unefficient. I'd better have all properties of each button specified right inside vm.puttons.push() argument, probably passing them through a newButton() method, to verify the correct use. I.e. smth like:
vm.buttons.push(newButton({
  href: '...',
  text: '...'
}))

where newButton() will (1) document which fields an object button may have, (2) validates that you pass a correct set of params, i.e. it does not make sense to pass both href and onClick, though you should pass in one of them.

  1. Let's get rid of spanText. Instead, in the span we can show just the index of button inside vm.buttons array, shifted by one. So that if your condition say a button should not be included in the array, the remaining buttons will automatically have proper numbers on them, depending on their order inside the array.

  2. Any reason to pass onClick as text? Why don't we pass the handlers by function reference? - I'd prefer this way.

@shubhendusaurabh
Copy link
Contributor Author

@birdofpreyru Updated

good code review 👍

@birdofpreyru
Copy link
Collaborator

Good, but contains some errors in the logic.

  1. Registration button is inactive for challenges with open registration.
    scr-14

  2. If I register for a challenge using production website, and then click Unregister in the local deployment, running your changes, here is what I see (buttons array is not reset at some point):
    scr-15

@shubhendusaurabh
Copy link
Contributor Author

@birdofpreyru fixed

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[$60] - Refactoring of buttons on Challenge Details page
2 participants