Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate Create newcomers entry page to react #10732

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

danieljames-dj
Copy link
Member

This PR aims at converting the create-newcomers page to react

Copy link
Member

Choose a reason for hiding this comment

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

You can definitely use SemUI components here.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done, I assume

doesn't have any alternative and hence can be used.

@@ -169,7 +169,7 @@ export default {
},
[PANEL_PAGES.createNewComers]: {
name: 'Create New Comers',
link: createNewComersUrl,
component: CreateNewComersPage,
Copy link
Member

Choose a reason for hiding this comment

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

Not 100% sure but I think the correct capitalization is just "Newcomers".

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh yes, changed. (there are some places where it's still wrong, I'll change that in a separate PR after this is merged, because those are not related to migration)

competition_ids: params[:competition_ids] || nil,
)
private def competition_list_from_string(competition_ids_string)
(competition_ids_string || '').split(',').uniq.compact
Copy link
Member

Choose a reason for hiding this comment

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

You can make sure that there's always a valid string being passed to this method via stuff like params.fetch(:foo, 'my_default')

Copy link
Member Author

Choose a reason for hiding this comment

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

Okay done.

Comment on lines 25 to 29
<Header as="h4">
<HeaderSubheader>
Leave blank to check for all competitions
</HeaderSubheader>
</Header>
Copy link
Member

Choose a reason for hiding this comment

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

Creating a header only for showing a subheader (with no "main" header) smells like bad code to me. What is your goal here, and why is a simple text paragraph not good enough?

Copy link
Member Author

Choose a reason for hiding this comment

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

I wanted to show it as 'hint' like thing, so I followed your suggestion in another PR (LINK). Did I implement this wrongly?

export default function CreateNewComersPage() {
return (
<>
<Header>Create New Comers</Header>
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
<Header>Create New Comers</Header>
<Header>Create newcomers</Header>

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

@danieljames-dj danieljames-dj force-pushed the create-newcomers1 branch 4 times, most recently from 5259a4c to b13e2ce Compare January 28, 2025 16:45
@@ -169,7 +169,7 @@ export default {
},
[PANEL_PAGES.createNewComers]: {
name: 'Create New Comers',
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
name: 'Create New Comers',
name: 'Create newcomers',

This should be changed as well ;-)

Copy link
Member Author

Choose a reason for hiding this comment

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

Okay now since you said it, I've changed it :-)

As mentioned in #10732 (comment), I wanted to change them separately all together in another PR after this is merged. For example, the line above the line you highlighted - for that to be changed, I need to change at many places which will make this PR more confusing and those changes will not be aligned to the PR title.

@@ -49,7 +49,7 @@
All newcomers seem to have been assigned WCA IDs.
Please <%= link_to "delete the inbox rows", competition_admin_delete_inbox_data_path(@competition, model: :inbox_person), class: 'inbox-trigger btn btn-primary', data: { jquery_method: :delete } %>.
<% else %>
Please <%= link_to "assign WCA IDs to newcomers", admin_complete_persons_path(finish_persons_form: { competition_ids: @competition.id }), target: '_blank', class: 'btn btn-primary' %>
Please <%= link_to "assign WCA IDs to newcomers", admin_complete_persons_path(competition_ids: [@competition.id]), target: '_blank', class: 'btn btn-primary' %>
Copy link
Member

Choose a reason for hiding this comment

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

Why do you need to wrap this in an array? Passing it as a string should be just fine

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, it do accept single string as well I guess, but there are cases where multiple competitions are also needed to be given as input. So, to make the type of competition_ids as a single type (array of string) instead of multiple type (array of string or single string), I thought of doing this way. Is it fine?

@@ -1,18 +1,18 @@
<% provide(:title, 'Finish unfinished persons') %>

<div class="container">
<% competition_ids = @finish_persons.competition_ids %>
<% competition_ids = @competition_ids %>
Copy link
Member

Choose a reason for hiding this comment

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

This line is redundant now, if you already have a @competition_ids variable then use it everywhere.

Copy link
Member

Choose a reason for hiding this comment

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

No need to re-assign it to "itself" with another name

Copy link
Member Author

Choose a reason for hiding this comment

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

Okay, instead of changing in many places, I thought of doing this way. Changed all the occurrences.


<h2>
<%= yield(:title) %>
<%= link_to "Go back", admin_finish_unfinished_persons_path(competition_ids: competition_ids), class: "btn btn-default" %>
<%= link_to "Go back", panel_page_path(id: User.panel_pages[:createNewComers], competition_ids: competition_ids), class: "btn btn-default" %>
Copy link
Member

Choose a reason for hiding this comment

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

Does this work as expected when competition_ids is an already-split array?

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for pointing that out, I actually didn't test that portion and realized that it was not even working for single competition ID as it was getting lost during redirection. I've fixed it now.

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

Successfully merging this pull request may close these issues.

3 participants