Skip to content

Commit

Permalink
fix: right trimming of zeros when displaying bon earning values
Browse files Browse the repository at this point in the history
  • Loading branch information
Roardom committed Jan 24, 2025
1 parent fb426a8 commit c531e4f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
4 changes: 2 additions & 2 deletions resources/views/Staff/bon_earning/edit.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ class="form__text"
pattern="[0-9.]*"
required
type="text"
value="{{ rtrim($bonEarning->multiplier, '.0') }}"
value="{{ preg_replace('/(\.\d+?)0+$/', '$1', $bonEarning->multiplier) }}"
/>
<label class="form__label form__label--floating" for="multiplier">
Multiplier
Expand Down Expand Up @@ -357,7 +357,7 @@ class="form__text"
x-bind:name="'conditions[' + i + '][operand2]'"
required
type="text"
x-bind:value="condition['operand2'].replace(/[.0]*$/, '')"
x-bind:value="condition['operand2'].replace(/(\.\d+?)0+$/, '$1')"
/>
<label
class="form__label form__label--floating"
Expand Down
6 changes: 4 additions & 2 deletions resources/views/Staff/bon_earning/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,9 @@ class="form__button form__button--text"
{{ __('common.unknown') }}
@endswitch
</td>
<td>{{ rtrim($bonEarning->multiplier, '.0') }}</td>
<td>
{{ preg_replace('/(\.\d+?)0+$/', '$1', $bonEarning->multiplier) }}
</td>
<td>
<ul>
@forelse ($bonEarning->conditions as $condition)
Expand All @@ -122,7 +124,7 @@ class="form__button form__button--text"
'size' => \App\Helpers\StringHelper::formatBytes($condition->operand2),
'seedtime' => \App\Helpers\StringHelper::timeElapsed($condition->operand2),
'type_id' => \App\Models\Type::find($condition->operand2)?->name ?? __('common.unknown'),
default => rtrim($condition->operand2, '.0'),
default => preg_replace('/(\.\d+?)0+$/', '$1', $condition->operand2),
}
}}
</li>
Expand Down
10 changes: 5 additions & 5 deletions resources/views/livewire/user-earnings.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
@endif

{{ $bonEarning->variable }} &times;
{{ rtrim($bonEarning->multiplier, '.0') }}
{{ preg_replace('/(\.\d+?)0+$/', '$1', $bonEarning->multiplier) }}
</td>
</tr>
@endforeach
Expand Down Expand Up @@ -259,16 +259,16 @@ class="{{ config('other.font-awesome') }} text-green fa-wifi"
{{ \App\Helpers\StringHelper::timeElapsed($torrent->age) }}
</td>
<td class="user-earnings__hourly">
{{ rtrim($torrent->hourly_earnings, '.0') }}
{{ preg_replace('/(\.\d+?)0+$/', '$1', $bonEarning->multiplier) }}
</td>
<td class="user-earnings__daily" x-cloak x-show="isToggledOn">
{{ rtrim($torrent->hourly_earnings, '.0') * 24 }}
{{ preg_replace('/(\.\d+?)0+$/', '$1', $bonEarning->multiplier) * 24 }}
</td>
<td class="user-earnings__weekly" x-cloak x-show="isToggledOn">
{{ rtrim($torrent->hourly_earnings, '.0') * 24 * 7 }}
{{ preg_replace('/(\.\d+?)0+$/', '$1', $bonEarning->multiplier) * 24 * 7 }}
</td>
<td class="user-earnings__monthly" x-cloak x-show="isToggledOn">
{{ rtrim($torrent->hourly_earnings, '.0') * 24 * 30 }}
{{ preg_replace('/(\.\d+?)0+$/', '$1', $bonEarning->multiplier) * 24 * 30 }}
</td>
</tr>
@endforeach
Expand Down

0 comments on commit c531e4f

Please sign in to comment.