Skip to content

Commit 06ebf81

Browse files
committed
fix: use premium license instead premium addon
1 parent 1c35369 commit 06ebf81

File tree

7 files changed

+23
-82
lines changed

7 files changed

+23
-82
lines changed

src/components/customers/CustomerInvoicesList.tsx

+3-15
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ import {
4444
InvoiceStatusTypeEnum,
4545
InvoiceTaxStatusTypeEnum,
4646
LagoApiError,
47-
PremiumIntegrationTypeEnum,
4847
TimezoneEnum,
4948
useDownloadInvoiceItemMutation,
5049
useRetryInvoicePaymentMutation,
@@ -418,23 +417,12 @@ export const CustomerInvoicesList: FC<CustomerInvoicesListProps> = ({
418417
startIcon: 'receipt',
419418
title: translate('text_1737471851634wpeojigr27w'),
420419

421-
endIcon: premiumIntegrations?.includes(
422-
PremiumIntegrationTypeEnum.ManualPayments,
423-
)
424-
? undefined
425-
: 'sparkles',
420+
endIcon: isPremium ? undefined : 'sparkles',
426421
onAction: ({ id }) => {
427-
if (
428-
premiumIntegrations?.includes(PremiumIntegrationTypeEnum.ManualPayments)
429-
) {
422+
if (isPremium) {
430423
navigate(generatePath(CREATE_INVOICE_PAYMENT_ROUTE, { invoiceId: id }))
431424
} else {
432-
premiumWarningDialogRef.current?.openDialog({
433-
title: translate('text_1738059367337v2tfzq3mr5u'),
434-
description: translate('text_1738059367337mm2dwg2af6g'),
435-
mailtoSubject: translate('text_1738059367337hy6e2c7pa3t'),
436-
mailtoBody: translate('text_1738059367337km2lr0xueue'),
437-
})
425+
premiumWarningDialogRef.current?.openDialog()
438426
}
439427
},
440428
}

src/components/customers/CustomerPaymentsTab.tsx

+4-6
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ import { generatePath } from 'react-router-dom'
44
import { CustomerPaymentsList } from '~/components/customers/CustomerPaymentsList'
55
import { ButtonLink, Skeleton, Typography } from '~/components/designSystem'
66
import { CREATE_PAYMENT_ROUTE } from '~/core/router'
7-
import { PremiumIntegrationTypeEnum, useGetPaymentListQuery } from '~/generated/graphql'
7+
import { useGetPaymentListQuery } from '~/generated/graphql'
88
import { useInternationalization } from '~/hooks/core/useInternationalization'
9-
import { useOrganizationInfos } from '~/hooks/useOrganizationInfos'
9+
import { useCurrentUser } from '~/hooks/useCurrentUser'
1010
import { usePermissions } from '~/hooks/usePermissions'
1111

1212
interface CustomerPaymentsTabProps {
@@ -16,7 +16,7 @@ interface CustomerPaymentsTabProps {
1616
export const CustomerPaymentsTab: FC<CustomerPaymentsTabProps> = ({ externalCustomerId }) => {
1717
const { translate } = useInternationalization()
1818
const { hasPermissions } = usePermissions()
19-
const { organization: { premiumIntegrations } = {} } = useOrganizationInfos()
19+
const { isPremium } = useCurrentUser()
2020

2121
const { data, loading, fetchMore } = useGetPaymentListQuery({
2222
variables: { externalCustomerId: externalCustomerId as string, limit: 20 },
@@ -27,9 +27,7 @@ export const CustomerPaymentsTab: FC<CustomerPaymentsTabProps> = ({ externalCust
2727

2828
const urlSearchParams = new URLSearchParams({ externalId: externalCustomerId })
2929

30-
const canRecordPayment =
31-
hasPermissions(['paymentsCreate']) &&
32-
premiumIntegrations?.includes(PremiumIntegrationTypeEnum.ManualPayments)
30+
const canRecordPayment = hasPermissions(['paymentsCreate']) && isPremium
3331

3432
return (
3533
<div className="flex flex-col gap-4">

src/components/invoices/InvoicePaymentList.tsx

+3-6
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,18 @@ import {
1313
AllInvoiceDetailsForCustomerInvoiceDetailsFragment,
1414
CurrencyEnum,
1515
PaymentTypeEnum,
16-
PremiumIntegrationTypeEnum,
1716
useGetPaymentListQuery,
1817
} from '~/generated/graphql'
1918
import { useInternationalization } from '~/hooks/core/useInternationalization'
20-
import { useOrganizationInfos } from '~/hooks/useOrganizationInfos'
19+
import { useCurrentUser } from '~/hooks/useCurrentUser'
2120
import { usePermissions } from '~/hooks/usePermissions'
2221

2322
export const InvoicePaymentList: FC<{
2423
invoiceTotalDueAmount: AllInvoiceDetailsForCustomerInvoiceDetailsFragment['totalDueAmountCents']
2524
}> = ({ invoiceTotalDueAmount }) => {
2625
const { translate } = useInternationalization()
2726
const { hasPermissions } = usePermissions()
28-
const { organization: { premiumIntegrations } = {} } = useOrganizationInfos()
27+
const { isPremium } = useCurrentUser()
2928
const { invoiceId } = useParams()
3029

3130
const { data, loading, error, fetchMore } = useGetPaymentListQuery({
@@ -36,9 +35,7 @@ export const InvoicePaymentList: FC<{
3635
const payments = data?.payments.collection || []
3736

3837
const canRecordPayment =
39-
invoiceTotalDueAmount > 0 &&
40-
hasPermissions(['paymentsCreate']) &&
41-
premiumIntegrations?.includes(PremiumIntegrationTypeEnum.ManualPayments)
38+
invoiceTotalDueAmount > 0 && hasPermissions(['paymentsCreate']) && isPremium
4239

4340
return (
4441
<>

src/components/invoices/InvoicesList.tsx

+3-14
Original file line numberDiff line numberDiff line change
@@ -256,23 +256,12 @@ const InvoicesList = ({
256256
startIcon: 'receipt',
257257
title: translate('text_1737471851634wpeojigr27w'),
258258

259-
endIcon: premiumIntegrations?.includes(
260-
PremiumIntegrationTypeEnum.ManualPayments,
261-
)
262-
? undefined
263-
: 'sparkles',
259+
endIcon: isPremium ? undefined : 'sparkles',
264260
onAction: ({ id }) => {
265-
if (
266-
premiumIntegrations?.includes(PremiumIntegrationTypeEnum.ManualPayments)
267-
) {
261+
if (isPremium) {
268262
navigate(generatePath(CREATE_INVOICE_PAYMENT_ROUTE, { invoiceId: id }))
269263
} else {
270-
premiumWarningDialogRef.current?.openDialog({
271-
title: translate('text_1738059367337v2tfzq3mr5u'),
272-
description: translate('text_1738059367337mm2dwg2af6g'),
273-
mailtoSubject: translate('text_1738059367337hy6e2c7pa3t'),
274-
mailtoBody: translate('text_1738059367337km2lr0xueue'),
275-
})
264+
premiumWarningDialogRef.current?.openDialog()
276265
}
277266
},
278267
}

src/pages/CustomerInvoiceDetails.tsx

+4-16
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ import {
7777
LagoApiError,
7878
NetsuiteIntegration,
7979
NetsuiteIntegrationInfosForInvoiceOverviewFragmentDoc,
80-
PremiumIntegrationTypeEnum,
8180
SalesforceIntegration,
8281
SalesforceIntegrationInfosForInvoiceOverviewFragmentDoc,
8382
useDownloadInvoiceMutation,
@@ -88,7 +87,7 @@ import {
8887
useRetryTaxProviderVoidingMutation,
8988
useSyncHubspotIntegrationInvoiceMutation,
9089
useSyncIntegrationInvoiceMutation,
91-
useSyncSalesforceInvoiceMutation,
90+
useSyncSalesforceInvoiceMutation
9291
} from '~/generated/graphql'
9392
import { useInternationalization } from '~/hooks/core/useInternationalization'
9493
import { useLocationHistory } from '~/hooks/core/useLocationHistory'
@@ -740,27 +739,16 @@ const CustomerInvoiceDetails = () => {
740739
<Button
741740
variant="quaternary"
742741
align="left"
743-
endIcon={
744-
premiumIntegrations?.includes(PremiumIntegrationTypeEnum.ManualPayments)
745-
? undefined
746-
: 'sparkles'
747-
}
742+
endIcon={isPremium ? undefined : 'sparkles'}
748743
onClick={() => {
749-
if (
750-
premiumIntegrations?.includes(PremiumIntegrationTypeEnum.ManualPayments)
751-
) {
744+
if (isPremium) {
752745
navigate(
753746
generatePath(CREATE_INVOICE_PAYMENT_ROUTE, {
754747
invoiceId: invoiceId as string,
755748
}),
756749
)
757750
} else {
758-
premiumWarningDialogRef.current?.openDialog({
759-
title: translate('text_1738059367337v2tfzq3mr5u'),
760-
description: translate('text_1738059367337mm2dwg2af6g'),
761-
mailtoSubject: translate('text_1738059367337hy6e2c7pa3t'),
762-
mailtoBody: translate('text_1738059367337km2lr0xueue'),
763-
})
751+
premiumWarningDialogRef.current?.openDialog()
764752
}
765753
closePopper()
766754
}}

src/pages/InvoicesPage.tsx

+6-21
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ import {
3636
InvoiceListItemFragmentDoc,
3737
LagoApiError,
3838
PaymentForPaymentsListFragmentDoc,
39-
PremiumIntegrationTypeEnum,
4039
useCreateCreditNotesDataExportMutation,
4140
useCreateInvoicesDataExportMutation,
4241
useGetCreditNotesListLazyQuery,
@@ -45,6 +44,7 @@ import {
4544
useRetryAllInvoicePaymentsMutation,
4645
} from '~/generated/graphql'
4746
import { useInternationalization } from '~/hooks/core/useInternationalization'
47+
import { useCurrentUser } from '~/hooks/useCurrentUser'
4848
import { useDebouncedSearch } from '~/hooks/useDebouncedSearch'
4949
import { useOrganizationInfos } from '~/hooks/useOrganizationInfos'
5050
import { usePermissions } from '~/hooks/usePermissions'
@@ -210,10 +210,10 @@ const InvoicesPage = () => {
210210
const { hasPermissions } = usePermissions()
211211
const { organization } = useOrganizationInfos()
212212
const navigate = useNavigate()
213-
213+
const { isPremium } = useCurrentUser()
214+
const [searchParams] = useSearchParams()
214215
const amountCurrency = organization?.defaultCurrency
215216
const { tab = InvoiceListTabEnum.invoices } = useParams<{ tab?: InvoiceListTabEnum }>()
216-
const [searchParams] = useSearchParams()
217217

218218
const premiumWarningDialogRef = useRef<PremiumWarningDialogRef>(null)
219219
const finalizeInvoiceRef = useRef<FinalizeInvoiceDialogRef>(null)
@@ -398,28 +398,13 @@ const InvoicesPage = () => {
398398
<Button
399399
variant="primary"
400400
onClick={() => {
401-
if (
402-
organization?.premiumIntegrations.includes(
403-
PremiumIntegrationTypeEnum.ManualPayments,
404-
)
405-
) {
401+
if (isPremium) {
406402
navigate(CREATE_PAYMENT_ROUTE)
407403
} else {
408-
premiumWarningDialogRef.current?.openDialog({
409-
title: translate('text_1738059367337v2tfzq3mr5u'),
410-
description: translate('text_1738059367337mm2dwg2af6g'),
411-
mailtoSubject: translate('text_1738059367337hy6e2c7pa3t'),
412-
mailtoBody: translate('text_1738059367337km2lr0xueue'),
413-
})
404+
premiumWarningDialogRef.current?.openDialog()
414405
}
415406
}}
416-
endIcon={
417-
organization?.premiumIntegrations.includes(
418-
PremiumIntegrationTypeEnum.ManualPayments,
419-
)
420-
? undefined
421-
: 'sparkles'
422-
}
407+
endIcon={isPremium ? undefined : 'sparkles'}
423408
>
424409
{translate('text_1737471851634wpeojigr27w')}
425410
</Button>

translations/base.json

-4
Original file line numberDiff line numberDiff line change
@@ -2854,10 +2854,6 @@
28542854
"text_1738056040178gw94jzmzckx": "No payments have been recorded for invoices. Please record a payment or connect your customer to a payment provider to view all payments here.",
28552855
"text_17380560401785kuvb6m2yfm": "No payments have been recorded for this invoice. Please record a payment or connect your customer to a payment provider to view all payments here.",
28562856
"text_17380560401786gmefzvw1rl": "No payments have been recorded for invoices. Please record a payment or connect your customer to a payment provider to view all payments here.",
2857-
"text_1738059367337v2tfzq3mr5u": "This is a premium add-on feature",
2858-
"text_1738059367337mm2dwg2af6g": "Premium add-on are available to users with a specific license. Please contact Lago to unlock this feature.",
2859-
"text_1738059367337hy6e2c7pa3t": "Request access to manual payment",
2860-
"text_1738059367337km2lr0xueue": "Hello, I would like to access your manual payment add-on. \nPlease let me know if you need more info!",
28612857
"text_1738063681339ucxmt3asspd": "Amount paid",
28622858
"text_1738063764295zomiafl8b4s": "Total",
28632859
"text_1738071221799vib0l2z1bxe": "Partially paid",

0 commit comments

Comments
 (0)