1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2025-01-18 07:52:23 +01:00

display validity for each pack

This commit is contained in:
Sylvain 2021-06-28 12:24:31 +02:00
parent 86de1f6253
commit bbb1aca4fb
6 changed files with 24 additions and 4 deletions

View File

@ -61,6 +61,15 @@ export const ProposePacksModal: React.FC<ProposePacksModalProps> = ({ isOpen, to
const formatDuration = (minutes: number): string => { const formatDuration = (minutes: number): string => {
return t('app.logged.propose_packs_modal.pack_DURATION', { DURATION: minutes / 60 }); return t('app.logged.propose_packs_modal.pack_DURATION', { DURATION: minutes / 60 });
} }
/**
* Return a user-friendly string for the validity of the provided pack
*/
const formatValidity = (pack: PrepaidPack): string => {
const period = t(`app.logged.propose_packs_modal.period.${pack.validity_interval}`, { COUNT: pack.validity_count });
return t('app.logged.propose_packs_modal.validity', { COUNT: pack.validity_count, PERIODS: period });
}
/** /**
* The user has declined to buy a pack * The user has declined to buy a pack
*/ */
@ -89,6 +98,7 @@ export const ProposePacksModal: React.FC<ProposePacksModalProps> = ({ isOpen, to
<span className="duration">{formatDuration(pack.minutes)}</span> <span className="duration">{formatDuration(pack.minutes)}</span>
<span className="amount">{formatPrice(pack.amount)}</span> <span className="amount">{formatPrice(pack.amount)}</span>
{pack.amount < normalPrice && <span className="crossed-out-price">{formatPrice(normalPrice)}</span>} {pack.amount < normalPrice && <span className="crossed-out-price">{formatPrice(normalPrice)}</span>}
<span className="validity">{formatValidity(pack)}</span>
<FabButton className="buy-button" onClick={handleBuyPack(pack)} icon={<i className="fas fa-shopping-cart" />}> <FabButton className="buy-button" onClick={handleBuyPack(pack)} icon={<i className="fas fa-shopping-cart" />}>
{t('app.logged.propose_packs_modal.buy_this_pack')} {t('app.logged.propose_packs_modal.buy_this_pack')}
</FabButton> </FabButton>

View File

@ -15,6 +15,5 @@ export interface PrepaidPack {
validity_count?: number, validity_count?: number,
minutes: number, minutes: number,
amount: number, amount: number,
usages?: number,
disabled?: boolean, disabled?: boolean,
} }

View File

@ -2,6 +2,8 @@
.list-of-packs { .list-of-packs {
display: flex; display: flex;
flex-wrap: wrap; flex-wrap: wrap;
justify-content: center;
.pack { .pack {
border-width: 3px; border-width: 3px;
border-style: solid; border-style: solid;
@ -33,6 +35,11 @@
text-decoration: line-through; text-decoration: line-through;
} }
.validity {
display: block;
font-style: italic;
}
.buy-button { .buy-button {
margin-top: 10px; margin-top: 10px;
margin-bottom: 5px; margin-bottom: 5px;

View File

@ -2,4 +2,3 @@
json.extract! pack, :id, :priceable_id, :priceable_type, :group_id, :validity_interval, :validity_count, :minutes, :disabled json.extract! pack, :id, :priceable_id, :priceable_type, :group_id, :validity_interval, :validity_count, :minutes, :disabled
json.amount pack.amount / 100.0 json.amount pack.amount / 100.0
json.usages pack.statistic_profile_prepaid_packs.count

View File

@ -1,6 +1,5 @@
# frozen_string_literal: true # frozen_string_literal: true
json.array! @packs do |pack| json.array! @packs do |pack|
json.extract! pack, :id, :priceable_id, :priceable_type, :group_id, :minutes, :disabled json.partial! 'api/prepaid_packs/pack', pack: pack
json.amount pack.amount / 100.0
end end

View File

@ -184,6 +184,12 @@ en:
no_thanks: "No, thanks" no_thanks: "No, thanks"
pack_DURATION: "{DURATION} hours" pack_DURATION: "{DURATION} hours"
buy_this_pack: "Buy this pack" buy_this_pack: "Buy this pack"
validity: "Usable for {COUNT} {PERIODS}"
period:
day: "{COUNT, plural, one{day} other{days}}"
week: "{COUNT, plural, one{week} other{weeks}}"
month: "{COUNT, plural, one{month} other{months}}"
year: "{COUNT, plural, one{year} other{years}}"
#book a training #book a training
trainings_reserve: trainings_reserve:
trainings_planning: "Trainings planning" trainings_planning: "Trainings planning"