mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-02-07 01:54:16 +01:00
(bug) wrong number of credits + improved text
This commit is contained in:
parent
1b8282fda4
commit
a41a22a050
@ -30,14 +30,7 @@ const CreditsPanel: React.FC<CreditsPanelProps> = ({ userId, onError, reservable
|
|||||||
* Compute the remainings hours for the given credit
|
* Compute the remainings hours for the given credit
|
||||||
*/
|
*/
|
||||||
const remainingHours = (credit: Credit): number => {
|
const remainingHours = (credit: Credit): number => {
|
||||||
return credit.hours - usedHours(credit);
|
return credit.hours - credit.hours_used;
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Compute the used credits hours for the given credit
|
|
||||||
*/
|
|
||||||
const usedHours = (credit: Credit): number => {
|
|
||||||
return credit.used_credits.map(uc => uc.hours_used).reduce((acc, val) => acc + val, 0);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -64,7 +57,7 @@ const CreditsPanel: React.FC<CreditsPanelProps> = ({ userId, onError, reservable
|
|||||||
<FabPanel className="credits-panel" header={header()}>
|
<FabPanel className="credits-panel" header={header()}>
|
||||||
<ul>
|
<ul>
|
||||||
{credits.map(c => <li key={c.id}>
|
{credits.map(c => <li key={c.id}>
|
||||||
<HtmlTranslate trKey="app.logged.dashboard.reservations.credits_panel.reamaining_credits_html" options={{ NAME: c.creditable.name, REMAINING: remainingHours(c), USED: usedHours(c) }} />
|
<HtmlTranslate trKey="app.logged.dashboard.reservations.credits_panel.reamaining_credits_html" options={{ NAME: c.creditable.name, REMAINING: remainingHours(c), USED: c.hours_used }} />
|
||||||
</li>)}
|
</li>)}
|
||||||
{credits.length === 0 && noCredits()}
|
{credits.length === 0 && noCredits()}
|
||||||
</ul>
|
</ul>
|
||||||
|
@ -14,9 +14,5 @@ export interface Credit {
|
|||||||
id: number,
|
id: number,
|
||||||
name: string
|
name: string
|
||||||
},
|
},
|
||||||
used_credits?: [{
|
hours_used?: number
|
||||||
id: number,
|
|
||||||
created_at: TDateISO,
|
|
||||||
hours_used: number
|
|
||||||
}]
|
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,5 @@
|
|||||||
|
|
||||||
json.array!(@credits) do |credit|
|
json.array!(@credits) do |credit|
|
||||||
json.partial! 'api/credits/credit', credit: credit
|
json.partial! 'api/credits/credit', credit: credit
|
||||||
json.used_credits credit.users_credits do |uc|
|
json.hours_used credit.users_credits.find_by(user_id: @user.id)&.hours_used
|
||||||
json.extract! uc, :id, :created_at, :hours_used
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
@ -154,8 +154,8 @@ en:
|
|||||||
credits_panel:
|
credits_panel:
|
||||||
title_Space: "My space credits"
|
title_Space: "My space credits"
|
||||||
title_Machine: "My machines credits"
|
title_Machine: "My machines credits"
|
||||||
reamaining_credits_html: "<strong>{NAME}</strong>: You can book <em>{REMAINING}</em> slots for free. You have already used {USED} credits."
|
reamaining_credits_html: "<strong>{NAME}</strong>: You can book <em>{REMAINING} {REMAINING, plural, one{slot} other{slots}}</em> for free. You have already used {USED} {USED, plural, one{credit} other{credits}} for your current subscription."
|
||||||
no_credits: "No credits"
|
no_credits: "You don't have any credits yet. Some subscriptions may allow you to book some slots free."
|
||||||
#public profil of a member
|
#public profil of a member
|
||||||
members_show:
|
members_show:
|
||||||
members_list: "Members list"
|
members_list: "Members list"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user