1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2025-01-17 06:52:27 +01:00

show link to pdf in component

This commit is contained in:
Sylvain 2020-11-02 11:16:13 +01:00
parent 408531d13a
commit 465fe8e913
5 changed files with 13 additions and 4 deletions

View File

@ -56,6 +56,12 @@ const PlanCard: React.FC<PlanCardProps> = ({ plan, user, operator, onSelectPlan,
const hasSubscribedToThisPlan = (): boolean => {
return user?.subscription?.plan?.id === plan.id;
}
/**
* Check if the plan has an attached file
*/
const hasAttachment = (): boolean => {
return !!plan.plan_file_url;
}
/**
* Callback triggered when the user select the plan
*/
@ -91,6 +97,7 @@ const PlanCard: React.FC<PlanCardProps> = ({ plan, user, operator, onSelectPlan,
<span>{ t('app.public.plans.i_choose_that_plan') }</span>
</button>
</div>}
{hasAttachment() && <a className="info-link" href={ plan.plan_file_url } target="_blank">{ t('app.public.plans.more_information') }</a>}
</div>
);
}
@ -98,7 +105,7 @@ const PlanCard: React.FC<PlanCardProps> = ({ plan, user, operator, onSelectPlan,
const PlanCardWrapper: React.FC<PlanCardProps> = ({ plan, user, operator, onSelectPlan, isSelected, $filter }) => {
const loading = (
<div className="fa-3x">
<i className="fas fa-circle-notch fa-spin"></i>
<i className="fas fa-circle-notch fa-spin" />
</div>
);
return (

View File

@ -37,5 +37,6 @@ export interface Plan {
id: number,
attachment_identifier: string
},
plan_file_url: string,
partners: Array<Partner>
}

View File

@ -348,6 +348,9 @@
outline: 0;
}
}
.info-link {
margin-top: 1em;
}
}
.well {

View File

@ -37,9 +37,6 @@
on-select-plan="selectPlan"
is-selected="isSelected(plan)">
</plan-card>
<br ng-show="!plan.plan_file_url"> <!-- TODO Refacto with CSS -->
<a ng-href="{{ plan.plan_file_url }}" ng-show="plan.plan_file_url" target="_blank" translate>{{ 'app.public.plans.more_information' }}</a>
</div>
</div>

View File

@ -9,6 +9,7 @@ if plan.plan_file
json.id plan.plan_file.id
json.attachment_identifier plan.plan_file.attachment_identifier
end
json.plan_file_url plan.plan_file.attachment_url
end
if plan.respond_to?(:partners)