Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: add link to PDF receipt in confirmation receipt #6878

Merged
merged 13 commits into from
Aug 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 35 additions & 25 deletions src/DonationForms/FormDesigns/ClassicFormDesign/css/_receipt.scss
Original file line number Diff line number Diff line change
Expand Up @@ -170,50 +170,60 @@
}
}


.receipt-footer {
display: flex;
justify-content: space-between;
flex-direction: column;
align-items: center;
margin-block-start: 2rem;
padding-block-end: fn.scaleBetween(1.5rem, 3.625rem);
padding-inline: fn.scaleBetween(1.25rem, 4.25rem);

.donor-dashboard-link {
#give-pdf-receipt-link,
#give-pdf-receipt-link:visited {
display: flex;
cursor: pointer;
text-decoration: none;
font-weight: 600;
width: fit-content;
padding: 0.75rem 2rem 0.75rem 2rem;
margin-top: 1.5rem;
margin-bottom: 1.75rem;
border-radius: 0.2rem;
border: thin solid var(--givewp-primary-color);
background-color: #fff;
color: var(--givewp-primary-color);

> i {
margin-inline-start: 0.25rem;
transform: translateY(0.18em);
font-size: 1.5rem;
text-decoration: none;
line-height: 0.5;

&::before {
display: inline-block;
content: '\f1c1';
font-family: 'Font Awesome 6 Free';
font-weight: 900;
font-size: 1.25rem;
line-height: 1;
margin-right: 0.5rem;
}
}

#give-pdf-receipt-link:hover {
background-color: var(--givewp-primary-color);
color: #fff;
}

.donor-dashboard-link {
color: var(--givewp-primary-color);
text-decoration: underline;
font-weight: 400;
}

.download-btn {
font-size: inherit;
padding-block: 0.75rem;
padding-inline: 1.6875rem;
}
}

#give-pdf-receipt-link,
#give-pdf-receipt-link:visited {
display: flex;
column-gap: 0.9375rem;
align-items: center;
text-decoration: none;
color: #fff;

&::after {
display: inline-block;
content: '\f1c1';
font-family: 'Font Awesome 6 Free';
font-weight: 900;
font-size: 1.625rem;
line-height: 1;
}
}
}

.givewp-layouts-receipt {
Expand Down
1 change: 1 addition & 0 deletions src/DonationForms/resources/propTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ export interface DonationReceiptProps {
heading: string;
description: string;
donorDashboardUrl: string;
pdfReceiptLink: string;
donorDetails: ReceiptDetail[];
donationDetails: ReceiptDetail[];
subscriptionDetails: ReceiptDetail[];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ function DonationConfirmationReceiptApp() {
heading={receipt.settings.heading}
description={receipt.settings.description}
donorDashboardUrl={receipt.settings.donorDashboardUrl}
pdfReceiptLink={receipt.settings.pdfReceiptLink}
donorDetails={receipt.donorDetails}
donationDetails={prepareDetails(receipt.donationDetails)}
subscriptionDetails={prepareDetails(receipt.subscriptionDetails)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const SecureBadge = () => {
*
* @since 3.0.0
*/
const Details = ({id, heading, details}: { id: string; heading: string; details: ReceiptDetail[] }) =>
const Details = ({id, heading, details}: {id: string; heading: string; details: ReceiptDetail[]}) =>
details?.length > 0 && (
<div className={`details details-${id}`}>
<h3 className="headline">{heading}</h3>
Expand All @@ -42,6 +42,7 @@ export default function DonationReceipt({
heading,
description,
donorDashboardUrl,
pdfReceiptLink,
donorDetails,
donationDetails,
subscriptionDetails,
Expand Down Expand Up @@ -73,9 +74,10 @@ export default function DonationReceipt({
</div>

<div className="receipt-footer">
{pdfReceiptLink && <Interweave content={pdfReceiptLink} />}

<a className="donor-dashboard-link" href={donorDashboardUrl} target="_parent">
{__('Go to my Donor Dashboard', 'give')}
<i className="fas fa-long-arrow-alt-right"></i>
</a>
</div>
</article>
Expand Down
59 changes: 34 additions & 25 deletions src/DonationForms/resources/styles/components/_receipt.scss
Original file line number Diff line number Diff line change
Expand Up @@ -176,47 +176,56 @@
.receipt-footer {
display: flex;
justify-content: space-between;
flex-direction: column;
align-items: center;
margin-block-start: 2rem;
padding-block-end: 1.5rem;
padding-inline: 1.25rem;

.donor-dashboard-link {
#give-pdf-receipt-link,
#give-pdf-receipt-link:visited {
display: flex;
cursor: pointer;
text-decoration: none;
font-weight: 600;
width: fit-content;
padding: 0.75rem 2rem 0.75rem 2rem;
margin-top: 1.5rem;
margin-bottom: 1.75rem;
border-radius: 0.2rem;
border: thin solid var(--givewp-primary-color);
background-color: #fff;
color: var(--givewp-primary-color);

> i {
margin-inline-start: 0.25rem;
transform: translateY(0.18em);
font-size: 1.5rem;
text-decoration: none;
line-height: 0.5;

&::before {
display: inline-block;
content: '\f1c1';
font-family: 'Font Awesome 6 Free';
font-weight: 900;
font-size: 1.25rem;
line-height: 1;
margin-right: 0.5rem;
}
}

#give-pdf-receipt-link:hover {
background-color: var(--givewp-primary-color);
color: #fff;
}

.donor-dashboard-link {
color: var(--givewp-primary-color);
text-decoration: underline;
font-weight: 400;
}

.download-btn {
font-size: inherit;
padding-block: 0.75rem;
padding-inline: 1.6875rem;
}
}

#give-pdf-receipt-link,
#give-pdf-receipt-link:visited {
display: flex;
column-gap: 0.9375rem;
align-items: center;
text-decoration: none;
color: #fff;

&::after {
display: inline-block;
content: '\f1c1';
font-family: 'Font Awesome 6 Free';
font-weight: 900;
font-size: 1.625rem;
line-height: 1;
}
}
}

.givewp-layouts-receipt {
Expand Down
3 changes: 2 additions & 1 deletion src/DonationForms/resources/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type {FC} from 'react';
import {FormSettings} from "@givewp/form-builder/types";
import {FormSettings} from '@givewp/form-builder/types';

/**
* Used for a single currency. The amount is an integer in the smallest unit of the currency.
Expand Down Expand Up @@ -57,6 +57,7 @@ export interface DonationConfirmationReceiptServerExports {
description: string;
currency: string;
donorDashboardUrl: string;
pdfReceiptLink: string;
};
donorDetails: ReceiptDetail[];
donationDetails: ReceiptDetail[];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,11 @@ private function fillSettings(DonationReceipt $receipt)

$receipt->settings->addSetting('currency', $receipt->donation->amount->getCurrency()->getCode());
$receipt->settings->addSetting('donorDashboardUrl', get_permalink(give_get_option('donor_dashboard_page')));

$receipt->settings->addSetting(
'pdfReceiptLink',
apply_filters('givewp_confirmation_page_receipt_settings_pdfReceiptLink', '', $receipt)
);
}

/**
Expand Down
2 changes: 2 additions & 0 deletions tests/Unit/Framework/Receipts/TestDonationReceipt.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ public function testToArrayReturnsExpectedArrayShape()
$receipt = new DonationReceipt($donation);
$receipt->settings->addSetting('currency', $receipt->donation->amount->getCurrency()->getCode());
$receipt->settings->addSetting('donorDashboardUrl', get_permalink(give_get_option('donor_dashboard_page')));
$receipt->settings->addSetting('pdfReceiptLink', '');
$receipt->donorDetails->addDetails($donorDetails->getDetails());
$receipt->donationDetails->addDetails($donationDetails->getDetails());

Expand All @@ -69,6 +70,7 @@ public function testToArrayReturnsExpectedArrayShape()
'settings' => [
'currency' => $receipt->donation->amount->getCurrency()->getCode(),
'donorDashboardUrl' => get_permalink(give_get_option('donor_dashboard_page')),
'pdfReceiptLink' => '',
],
'donorDetails' => $donorDetails->toArray(),
'donationDetails' => $donationDetails->toArray(),
Expand Down
3 changes: 2 additions & 1 deletion tests/Unit/Framework/Receipts/TestDonationReceiptBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public function testToConfirmationPageShouldReturnDonationReceipt()
)
);
}

if ($receipt->donation->anonymous) {
$additionalDetails->addDetail(
new ReceiptDetail(
Expand All @@ -100,6 +100,7 @@ public function testToConfirmationPageShouldReturnDonationReceipt()
'description' => $description,
'currency' => $receipt->donation->amount->getCurrency()->getCode(),
'donorDashboardUrl' => get_permalink(give_get_option('donor_dashboard_page')),
'pdfReceiptLink' => '',
];


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ public function testShouldGenerateReceiptForOneTimeDonation()
'description' => $description,
'currency' => $receipt->donation->amount->getCurrency()->getCode(),
'donorDashboardUrl' => get_permalink(give_get_option('donor_dashboard_page')),
'pdfReceiptLink' => '',
];

$this->assertSame(
Expand Down Expand Up @@ -232,6 +233,7 @@ public function testShouldGenerateReceiptForRecurringDonation()
'description' => $description,
'currency' => $receipt->donation->amount->getCurrency()->getCode(),
'donorDashboardUrl' => get_permalink(give_get_option('donor_dashboard_page')),
'pdfReceiptLink' => '',
];

$this->assertSame(
Expand Down
Loading