Skip to content

Commit

Permalink
chore: fix CI
Browse files Browse the repository at this point in the history
  • Loading branch information
ruioliveira02 committed Nov 4, 2024
1 parent 3558cbb commit 6a32610
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 31 deletions.
47 changes: 24 additions & 23 deletions assets/js/hooks/countdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,27 +26,28 @@ export const Countdown = {
}

function formatTimeRemaining(seconds) {
// Calculate days, hours, minutes, and seconds
const days = Math.floor(seconds / (24 * 60 * 60)); // Calculate total days
seconds %= 24 * 60 * 60; // Get remaining seconds after extracting days
const hours = Math.floor(seconds / 3600); // Calculate hours
seconds %= 3600; // Get remaining seconds after extracting hours
const minutes = Math.floor(seconds / 60); // Calculate minutes
const remainingSeconds = seconds % 60; // Remaining seconds

// Format hours, minutes, and seconds to always be two digits
const formattedHours = String(hours).padStart(2, '0');
const formattedMinutes = String(minutes).padStart(2, '0');
const formattedSeconds = String(remainingSeconds).padStart(2, '0');

if(days > 0)
return `${days} days, ${formattedHours}:${formattedMinutes}:${formattedSeconds}`;

if(hours > 0)
return `${formattedHours}:${formattedMinutes}:${formattedSeconds}`;

if(minutes > 0)
return `${formattedMinutes}:${formattedSeconds}`;

return `${seconds}`;
const timeUnits = {
days: Math.floor(seconds / (24 * 60 * 60)),
hours: Math.floor((seconds % (24 * 60 * 60)) / 3600),
minutes: Math.floor((seconds % 3600) / 60),
seconds: seconds % 60
};

// Format units to two digits except for days
const formattedTime = {
hours: String(timeUnits.hours).padStart(2, '0'),
minutes: String(timeUnits.minutes).padStart(2, '0'),
seconds: String(timeUnits.seconds).padStart(2, '0')
};

if (timeUnits.days > 0) {
return `${timeUnits.days} days, ${formattedTime.hours}:${formattedTime.minutes}:${formattedTime.seconds}`;
}
if (timeUnits.hours > 0) {
return `${formattedTime.hours}:${formattedTime.minutes}:${formattedTime.seconds}`;
}
if (timeUnits.minutes > 0) {
return `${formattedTime.minutes}:${formattedTime.seconds}`;
}
return `${timeUnits.seconds}`;
}
4 changes: 2 additions & 2 deletions lib/safira_web.ex
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ defmodule SafiraWeb do
layouts: [html: SafiraWeb.Layouts]

import Plug.Conn
import SafiraWeb.Gettext
use Gettext, backend: SafiraWeb.Gettext

unquote(verified_routes())
end
Expand Down Expand Up @@ -117,7 +117,7 @@ defmodule SafiraWeb do
# Core UI components and translation
import SafiraWeb.CoreComponents
import SafiraWeb.Components.Page
import SafiraWeb.Gettext
use Gettext, backend: SafiraWeb.Gettext

import SafiraWeb.Helpers

Expand Down
2 changes: 1 addition & 1 deletion lib/safira_web/components/core_components.ex
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ defmodule SafiraWeb.CoreComponents do
alias Phoenix.HTML.Form
alias Phoenix.LiveView.JS

import SafiraWeb.Gettext
use Gettext, backend: SafiraWeb.Gettexttext

@doc """
Renders a modal.
Expand Down
2 changes: 1 addition & 1 deletion lib/safira_web/components/table.ex
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ defmodule SafiraWeb.Components.Table do
use Phoenix.Component

alias Plug.Conn.Query
import SafiraWeb.Gettext
use Gettext, backend: SafiraWeb.Gettexttext
import SafiraWeb.CoreComponents

attr :id, :string, required: true
Expand Down
2 changes: 1 addition & 1 deletion lib/safira_web/components/table_search.ex
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ defmodule SafiraWeb.Components.TableSearch do
Reusable table search component.
"""
use Phoenix.Component
import SafiraWeb.Gettext
use Gettext, backend: SafiraWeb.Gettext

attr :id, :string, required: true
attr :params, :map, required: true
Expand Down
4 changes: 2 additions & 2 deletions lib/safira_web/gettext.ex
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ defmodule SafiraWeb.Gettext do
By using [Gettext](https://hexdocs.pm/gettext),
your module gains a set of macros for translations, for example:
import SafiraWeb.Gettext
use Gettext, backend: SafiraWeb.Gettext
# Simple translation
gettext("Here is the string to translate")
Expand All @@ -20,5 +20,5 @@ defmodule SafiraWeb.Gettext do
See the [Gettext Docs](https://hexdocs.pm/gettext) for detailed usage.
"""
use Gettext, otp_app: :safira
use Gettext.Backend, otp_app: :safira
end
3 changes: 2 additions & 1 deletion lib/safira_web/plugs/user_roles.ex
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ defmodule SafiraWeb.UserRoles do
:error,
"You haven't assigned a credential to your account. You need one to participate in SEI"
)
|> redirect(to: ~p"/app/") #TODO: Add proper route when implemented
# TODO: Add proper route when implemented
|> redirect(to: ~p"/app/")
|> halt()
end
end
Expand Down

0 comments on commit 6a32610

Please sign in to comment.