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

feat: challenges page #462

Merged
merged 13 commits into from
Jan 28, 2025
Merged

feat: challenges page #462

merged 13 commits into from
Jan 28, 2025

Conversation

ruioliveira02
Copy link
Member

No description provided.

@ruioliveira02 ruioliveira02 self-assigned this Jan 11, 2025
@ruioliveira02 ruioliveira02 marked this pull request as ready for review January 12, 2025 19:50
Copy link
Member

@joaodiaslobo joaodiaslobo left a comment

Choose a reason for hiding this comment

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

Challenge shouldn't be in the Minigames context, maybe create a challenge context for it? Make sure to also put ChallengePrize stuff inside it.

Copy link
Member

@joaodiaslobo joaodiaslobo left a comment

Choose a reason for hiding this comment

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

Not working on mobile

Copy link
Member

@joaodiaslobo joaodiaslobo left a comment

Choose a reason for hiding this comment

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

Only one thing remaining for this to be merged.
Instead of making the display position be an input, try to use the sortable hook so that the challenges are sorted via dragging on the table.
Something like what is being done with the company tiers here:

image

I recommend the following:
First, add the possibility of the table component having the Sorting hook by adding the following to the file:
A new attribute to define a sortable table:

  attr :sortable, :boolean, default: false

And if it is true, add the hook (to the table body element):

          <tbody
            id={@id <> "-tbody"}
            phx-update={match?(%Phoenix.LiveView.LiveStream{}, @items) && "stream"}
            phx-hook={if @sortable do "Sorting" end}
          >

Then, after adding this, create a new column for the draggable bars on the challenges table, and add the sortable attribute to it:

    <.table
      id="challenges-table"
      items={@streams.challenges}
      meta={@meta}
      params={@params}
      row_click={&JS.navigate(~p"/dashboard/minigames/challenges/#{elem(&1, 1).id}/edit")}
      sortable
    >
      <:col :let={{_id, _challenge}} label="">
        <.icon name="hero-bars-3" class="w-5 h-5 handle cursor-pointer ml-4" />
      </:col>
      ...

After doing all this, you can handle the order changing event on the challenge index live view.

lib/safira/minigames.ex Outdated Show resolved Hide resolved
@joaodiaslobo joaodiaslobo merged commit d161a75 into main Jan 28, 2025
2 checks passed
@joaodiaslobo joaodiaslobo deleted the ro/feat/challenges branch January 28, 2025 17:46
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.

2 participants