Skip to content

Commit

Permalink
fix: use premium license instead premium addon
Browse files Browse the repository at this point in the history
  • Loading branch information
keellyp committed Feb 5, 2025
1 parent 1c35369 commit 2d2ea9a
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 83 deletions.
20 changes: 3 additions & 17 deletions src/components/customers/CustomerInvoicesList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,12 @@ import {
InvoiceStatusTypeEnum,
InvoiceTaxStatusTypeEnum,
LagoApiError,
PremiumIntegrationTypeEnum,
TimezoneEnum,
useDownloadInvoiceItemMutation,
useRetryInvoicePaymentMutation,
} from '~/generated/graphql'
import { useInternationalization } from '~/hooks/core/useInternationalization'
import { useCurrentUser } from '~/hooks/useCurrentUser'
import { useOrganizationInfos } from '~/hooks/useOrganizationInfos'
import { usePermissions } from '~/hooks/usePermissions'

gql`
Expand Down Expand Up @@ -146,7 +144,6 @@ export const CustomerInvoicesList: FC<CustomerInvoicesListProps> = ({
const { isPremium } = useCurrentUser()
const { translate } = useInternationalization()
const { hasPermissions } = usePermissions()
const { organization: { premiumIntegrations } = {} } = useOrganizationInfos()

const premiumWarningDialogRef = useRef<PremiumWarningDialogRef>(null)

Expand Down Expand Up @@ -418,23 +415,12 @@ export const CustomerInvoicesList: FC<CustomerInvoicesListProps> = ({
startIcon: 'receipt',
title: translate('text_1737471851634wpeojigr27w'),

endIcon: premiumIntegrations?.includes(
PremiumIntegrationTypeEnum.ManualPayments,
)
? undefined
: 'sparkles',
endIcon: isPremium ? undefined : 'sparkles',
onAction: ({ id }) => {
if (
premiumIntegrations?.includes(PremiumIntegrationTypeEnum.ManualPayments)
) {
if (isPremium) {
navigate(generatePath(CREATE_INVOICE_PAYMENT_ROUTE, { invoiceId: id }))
} else {
premiumWarningDialogRef.current?.openDialog({
title: translate('text_1738059367337v2tfzq3mr5u'),
description: translate('text_1738059367337mm2dwg2af6g'),
mailtoSubject: translate('text_1738059367337hy6e2c7pa3t'),
mailtoBody: translate('text_1738059367337km2lr0xueue'),
})
premiumWarningDialogRef.current?.openDialog()
}
},
}
Expand Down
10 changes: 4 additions & 6 deletions src/components/customers/CustomerPaymentsTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import { generatePath } from 'react-router-dom'
import { CustomerPaymentsList } from '~/components/customers/CustomerPaymentsList'
import { ButtonLink, Skeleton, Typography } from '~/components/designSystem'
import { CREATE_PAYMENT_ROUTE } from '~/core/router'
import { PremiumIntegrationTypeEnum, useGetPaymentListQuery } from '~/generated/graphql'
import { useGetPaymentListQuery } from '~/generated/graphql'
import { useInternationalization } from '~/hooks/core/useInternationalization'
import { useOrganizationInfos } from '~/hooks/useOrganizationInfos'
import { useCurrentUser } from '~/hooks/useCurrentUser'
import { usePermissions } from '~/hooks/usePermissions'

interface CustomerPaymentsTabProps {
Expand All @@ -16,7 +16,7 @@ interface CustomerPaymentsTabProps {
export const CustomerPaymentsTab: FC<CustomerPaymentsTabProps> = ({ externalCustomerId }) => {
const { translate } = useInternationalization()
const { hasPermissions } = usePermissions()
const { organization: { premiumIntegrations } = {} } = useOrganizationInfos()
const { isPremium } = useCurrentUser()

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

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

const canRecordPayment =
hasPermissions(['paymentsCreate']) &&
premiumIntegrations?.includes(PremiumIntegrationTypeEnum.ManualPayments)
const canRecordPayment = hasPermissions(['paymentsCreate']) && isPremium

return (
<div className="flex flex-col gap-4">
Expand Down
9 changes: 3 additions & 6 deletions src/components/invoices/InvoicePaymentList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,18 @@ import {
AllInvoiceDetailsForCustomerInvoiceDetailsFragment,
CurrencyEnum,
PaymentTypeEnum,
PremiumIntegrationTypeEnum,
useGetPaymentListQuery,
} from '~/generated/graphql'
import { useInternationalization } from '~/hooks/core/useInternationalization'
import { useOrganizationInfos } from '~/hooks/useOrganizationInfos'
import { useCurrentUser } from '~/hooks/useCurrentUser'
import { usePermissions } from '~/hooks/usePermissions'

export const InvoicePaymentList: FC<{
invoiceTotalDueAmount: AllInvoiceDetailsForCustomerInvoiceDetailsFragment['totalDueAmountCents']
}> = ({ invoiceTotalDueAmount }) => {
const { translate } = useInternationalization()
const { hasPermissions } = usePermissions()
const { organization: { premiumIntegrations } = {} } = useOrganizationInfos()
const { isPremium } = useCurrentUser()
const { invoiceId } = useParams()

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

const canRecordPayment =
invoiceTotalDueAmount > 0 &&
hasPermissions(['paymentsCreate']) &&
premiumIntegrations?.includes(PremiumIntegrationTypeEnum.ManualPayments)
invoiceTotalDueAmount > 0 && hasPermissions(['paymentsCreate']) && isPremium

return (
<>
Expand Down
17 changes: 3 additions & 14 deletions src/components/invoices/InvoicesList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -256,23 +256,12 @@ const InvoicesList = ({
startIcon: 'receipt',
title: translate('text_1737471851634wpeojigr27w'),

endIcon: premiumIntegrations?.includes(
PremiumIntegrationTypeEnum.ManualPayments,
)
? undefined
: 'sparkles',
endIcon: isPremium ? undefined : 'sparkles',
onAction: ({ id }) => {
if (
premiumIntegrations?.includes(PremiumIntegrationTypeEnum.ManualPayments)
) {
if (isPremium) {
navigate(generatePath(CREATE_INVOICE_PAYMENT_ROUTE, { invoiceId: id }))
} else {
premiumWarningDialogRef.current?.openDialog({
title: translate('text_1738059367337v2tfzq3mr5u'),
description: translate('text_1738059367337mm2dwg2af6g'),
mailtoSubject: translate('text_1738059367337hy6e2c7pa3t'),
mailtoBody: translate('text_1738059367337km2lr0xueue'),
})
premiumWarningDialogRef.current?.openDialog()
}
},
}
Expand Down
18 changes: 3 additions & 15 deletions src/pages/CustomerInvoiceDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ import {
LagoApiError,
NetsuiteIntegration,
NetsuiteIntegrationInfosForInvoiceOverviewFragmentDoc,
PremiumIntegrationTypeEnum,
SalesforceIntegration,
SalesforceIntegrationInfosForInvoiceOverviewFragmentDoc,
useDownloadInvoiceMutation,
Expand Down Expand Up @@ -740,27 +739,16 @@ const CustomerInvoiceDetails = () => {
<Button
variant="quaternary"
align="left"
endIcon={
premiumIntegrations?.includes(PremiumIntegrationTypeEnum.ManualPayments)
? undefined
: 'sparkles'
}
endIcon={isPremium ? undefined : 'sparkles'}
onClick={() => {
if (
premiumIntegrations?.includes(PremiumIntegrationTypeEnum.ManualPayments)
) {
if (isPremium) {
navigate(
generatePath(CREATE_INVOICE_PAYMENT_ROUTE, {
invoiceId: invoiceId as string,
}),
)
} else {
premiumWarningDialogRef.current?.openDialog({
title: translate('text_1738059367337v2tfzq3mr5u'),
description: translate('text_1738059367337mm2dwg2af6g'),
mailtoSubject: translate('text_1738059367337hy6e2c7pa3t'),
mailtoBody: translate('text_1738059367337km2lr0xueue'),
})
premiumWarningDialogRef.current?.openDialog()
}
closePopper()
}}
Expand Down
27 changes: 6 additions & 21 deletions src/pages/InvoicesPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ import {
InvoiceListItemFragmentDoc,
LagoApiError,
PaymentForPaymentsListFragmentDoc,
PremiumIntegrationTypeEnum,
useCreateCreditNotesDataExportMutation,
useCreateInvoicesDataExportMutation,
useGetCreditNotesListLazyQuery,
Expand All @@ -45,6 +44,7 @@ import {
useRetryAllInvoicePaymentsMutation,
} from '~/generated/graphql'
import { useInternationalization } from '~/hooks/core/useInternationalization'
import { useCurrentUser } from '~/hooks/useCurrentUser'
import { useDebouncedSearch } from '~/hooks/useDebouncedSearch'
import { useOrganizationInfos } from '~/hooks/useOrganizationInfos'
import { usePermissions } from '~/hooks/usePermissions'
Expand Down Expand Up @@ -210,10 +210,10 @@ const InvoicesPage = () => {
const { hasPermissions } = usePermissions()
const { organization } = useOrganizationInfos()
const navigate = useNavigate()

const { isPremium } = useCurrentUser()
const [searchParams] = useSearchParams()
const amountCurrency = organization?.defaultCurrency
const { tab = InvoiceListTabEnum.invoices } = useParams<{ tab?: InvoiceListTabEnum }>()
const [searchParams] = useSearchParams()

const premiumWarningDialogRef = useRef<PremiumWarningDialogRef>(null)
const finalizeInvoiceRef = useRef<FinalizeInvoiceDialogRef>(null)
Expand Down Expand Up @@ -398,28 +398,13 @@ const InvoicesPage = () => {
<Button
variant="primary"
onClick={() => {
if (
organization?.premiumIntegrations.includes(
PremiumIntegrationTypeEnum.ManualPayments,
)
) {
if (isPremium) {
navigate(CREATE_PAYMENT_ROUTE)
} else {
premiumWarningDialogRef.current?.openDialog({
title: translate('text_1738059367337v2tfzq3mr5u'),
description: translate('text_1738059367337mm2dwg2af6g'),
mailtoSubject: translate('text_1738059367337hy6e2c7pa3t'),
mailtoBody: translate('text_1738059367337km2lr0xueue'),
})
premiumWarningDialogRef.current?.openDialog()
}
}}
endIcon={
organization?.premiumIntegrations.includes(
PremiumIntegrationTypeEnum.ManualPayments,
)
? undefined
: 'sparkles'
}
endIcon={isPremium ? undefined : 'sparkles'}
>
{translate('text_1737471851634wpeojigr27w')}
</Button>
Expand Down
4 changes: 0 additions & 4 deletions translations/base.json
Original file line number Diff line number Diff line change
Expand Up @@ -2854,10 +2854,6 @@
"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.",
"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.",
"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.",
"text_1738059367337v2tfzq3mr5u": "This is a premium add-on feature",
"text_1738059367337mm2dwg2af6g": "Premium add-on are available to users with a specific license. Please contact Lago to unlock this feature.",
"text_1738059367337hy6e2c7pa3t": "Request access to manual payment",
"text_1738059367337km2lr0xueue": "Hello, I would like to access your manual payment add-on. \nPlease let me know if you need more info!",
"text_1738063681339ucxmt3asspd": "Amount paid",
"text_1738063764295zomiafl8b4s": "Total",
"text_1738071221799vib0l2z1bxe": "Partially paid",
Expand Down

0 comments on commit 2d2ea9a

Please sign in to comment.