mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-21 23:30:32 +00:00
feat: Hook orgnization name and logo to payment page
This commit is contained in:
@@ -1,6 +1,8 @@
|
|||||||
|
import { Transform } from 'form-data';
|
||||||
import { ItemEntryTransformer } from './ItemEntryTransformer';
|
import { ItemEntryTransformer } from './ItemEntryTransformer';
|
||||||
import { SaleInvoiceTaxEntryTransformer } from './SaleInvoiceTaxEntryTransformer';
|
import { SaleInvoiceTaxEntryTransformer } from './SaleInvoiceTaxEntryTransformer';
|
||||||
import { SaleInvoiceTransformer } from './SaleInvoiceTransformer';
|
import { SaleInvoiceTransformer } from './SaleInvoiceTransformer';
|
||||||
|
import { Transformer } from '@/lib/Transformer/Transformer';
|
||||||
|
|
||||||
export class GetInvoicePaymentLinkMetaTransformer extends SaleInvoiceTransformer {
|
export class GetInvoicePaymentLinkMetaTransformer extends SaleInvoiceTransformer {
|
||||||
/**
|
/**
|
||||||
@@ -17,7 +19,6 @@ export class GetInvoicePaymentLinkMetaTransformer extends SaleInvoiceTransformer
|
|||||||
*/
|
*/
|
||||||
public includeAttributes = (): string[] => {
|
public includeAttributes = (): string[] => {
|
||||||
return [
|
return [
|
||||||
'companyName',
|
|
||||||
'customerName',
|
'customerName',
|
||||||
'dueAmount',
|
'dueAmount',
|
||||||
'dueDateFormatted',
|
'dueDateFormatted',
|
||||||
@@ -39,6 +40,7 @@ export class GetInvoicePaymentLinkMetaTransformer extends SaleInvoiceTransformer
|
|||||||
'termsConditions',
|
'termsConditions',
|
||||||
'entries',
|
'entries',
|
||||||
'taxes',
|
'taxes',
|
||||||
|
'organization',
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -46,8 +48,15 @@ export class GetInvoicePaymentLinkMetaTransformer extends SaleInvoiceTransformer
|
|||||||
return invoice.customer.displayName;
|
return invoice.customer.displayName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public companyName() {
|
/**
|
||||||
return 'Bigcapital Technology, Inc.';
|
* Retrieves the organization metadata for the payment link.
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
public organization(invoice) {
|
||||||
|
return this.item(
|
||||||
|
this.context.organization,
|
||||||
|
new GetPaymentLinkOrganizationMetaTransformer()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -82,6 +91,20 @@ export class GetInvoicePaymentLinkMetaTransformer extends SaleInvoiceTransformer
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class GetPaymentLinkOrganizationMetaTransformer extends Transformer {
|
||||||
|
/**
|
||||||
|
* Include these attributes to item entry object.
|
||||||
|
* @returns {Array}
|
||||||
|
*/
|
||||||
|
public includeAttributes = (): string[] => {
|
||||||
|
return ['primaryColor', 'name', 'address', 'logoUri'];
|
||||||
|
};
|
||||||
|
|
||||||
|
public excludeAttributes = (): string[] => {
|
||||||
|
return ['*'];
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
class GetInvoicePaymentLinkEntryMetaTransformer extends ItemEntryTransformer {
|
class GetInvoicePaymentLinkEntryMetaTransformer extends ItemEntryTransformer {
|
||||||
/**
|
/**
|
||||||
* Include these attributes to item entry object.
|
* Include these attributes to item entry object.
|
||||||
|
|||||||
@@ -17,7 +17,6 @@
|
|||||||
width :50px;
|
width :50px;
|
||||||
border-radius: 50px;
|
border-radius: 50px;
|
||||||
background-color: #dfdfdf;
|
background-color: #dfdfdf;
|
||||||
background-image: url('https://pbs.twimg.com/profile_images/1381635804397703182/x5chIdsO_400x400.png');
|
|
||||||
background-position: center center;
|
background-position: center center;
|
||||||
background-size: cover;
|
background-size: cover;
|
||||||
background-repeat: no-repeat;
|
background-repeat: no-repeat;
|
||||||
|
|||||||
@@ -38,13 +38,20 @@ export function PaymentPortal() {
|
|||||||
<Stack spacing={0} className={styles.body}>
|
<Stack spacing={0} className={styles.body}>
|
||||||
<Stack>
|
<Stack>
|
||||||
<Group spacing={10}>
|
<Group spacing={10}>
|
||||||
<Box className={styles.companyLogoWrap}></Box>
|
{sharableLinkMeta?.organization?.logoUri && (
|
||||||
<Text>{sharableLinkMeta?.companyName}</Text>
|
<Box
|
||||||
|
className={styles.companyLogoWrap}
|
||||||
|
style={{
|
||||||
|
backgroundImage: `url(${sharableLinkMeta?.organization?.logoUri})`,
|
||||||
|
}}
|
||||||
|
></Box>
|
||||||
|
)}
|
||||||
|
<Text>{sharableLinkMeta?.organization?.name}</Text>
|
||||||
</Group>
|
</Group>
|
||||||
|
|
||||||
<Stack spacing={6}>
|
<Stack spacing={6}>
|
||||||
<h1 className={styles.bigTitle}>
|
<h1 className={styles.bigTitle}>
|
||||||
{sharableLinkMeta?.companyName} Sent an Invoice for{' '}
|
{sharableLinkMeta?.organization?.name} Sent an Invoice for{' '}
|
||||||
{sharableLinkMeta?.totalFormatted}
|
{sharableLinkMeta?.totalFormatted}
|
||||||
</h1>
|
</h1>
|
||||||
<Text className={clsx(Classes.TEXT_MUTED, styles.invoiceDueDate)}>
|
<Text className={clsx(Classes.TEXT_MUTED, styles.invoiceDueDate)}>
|
||||||
|
|||||||
@@ -54,6 +54,15 @@ export function useCreatePaymentLink(
|
|||||||
|
|
||||||
// Get Invoice Payment Link
|
// Get Invoice Payment Link
|
||||||
// -----------------------------------------
|
// -----------------------------------------
|
||||||
|
interface GetInvoicePaymentLinkAddressResponse {
|
||||||
|
address_1: string;
|
||||||
|
address_2: string;
|
||||||
|
postal_code: string;
|
||||||
|
city: string;
|
||||||
|
state_province: string;
|
||||||
|
phone: string;
|
||||||
|
}
|
||||||
|
|
||||||
export interface GetInvoicePaymentLinkResponse {
|
export interface GetInvoicePaymentLinkResponse {
|
||||||
dueAmount: number;
|
dueAmount: number;
|
||||||
dueAmountFormatted: string;
|
dueAmountFormatted: string;
|
||||||
@@ -70,7 +79,6 @@ export interface GetInvoicePaymentLinkResponse {
|
|||||||
totalFormatted: string;
|
totalFormatted: string;
|
||||||
totalLocalFormatted: string;
|
totalLocalFormatted: string;
|
||||||
customerName: string;
|
customerName: string;
|
||||||
companyName: string;
|
|
||||||
invoiceMessage: string;
|
invoiceMessage: string;
|
||||||
termsConditions: string;
|
termsConditions: string;
|
||||||
entries: Array<{
|
entries: Array<{
|
||||||
@@ -89,7 +97,17 @@ export interface GetInvoicePaymentLinkResponse {
|
|||||||
taxRateAmountFormatted: string;
|
taxRateAmountFormatted: string;
|
||||||
taxRateCode: string;
|
taxRateCode: string;
|
||||||
}>;
|
}>;
|
||||||
|
organization: Record<
|
||||||
|
string,
|
||||||
|
{
|
||||||
|
address: Record<string, GetInvoicePaymentLinkAddressResponse>;
|
||||||
|
name: string;
|
||||||
|
primaryColor: string;
|
||||||
|
logoUri: string;
|
||||||
|
}
|
||||||
|
>;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetches the sharable invoice link metadata for a given link ID.
|
* Fetches the sharable invoice link metadata for a given link ID.
|
||||||
* @param {string} linkId - The ID of the link to fetch metadata for.
|
* @param {string} linkId - The ID of the link to fetch metadata for.
|
||||||
|
|||||||
Reference in New Issue
Block a user