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 9768ecc commit efe0de0
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 57 deletions.
13 changes: 3 additions & 10 deletions src/components/customers/CustomerInvoicesList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,9 @@ import {
InvoiceStatusTypeEnum,
InvoiceTaxStatusTypeEnum,
LagoApiError,
PremiumIntegrationTypeEnum,
TimezoneEnum,
useDownloadInvoiceItemMutation,
useRetryInvoicePaymentMutation,
useRetryInvoicePaymentMutation
} from '~/generated/graphql'
import { useInternationalization } from '~/hooks/core/useInternationalization'
import { useCurrentUser } from '~/hooks/useCurrentUser'
Expand Down Expand Up @@ -418,15 +417,9 @@ 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({
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
13 changes: 3 additions & 10 deletions src/components/invoices/InvoicesList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,8 @@ import {
InvoicePaymentStatusTypeEnum,
InvoiceStatusTypeEnum,
LagoApiError,
PremiumIntegrationTypeEnum,
useDownloadInvoiceItemMutation,
useRetryInvoicePaymentMutation,
useRetryInvoicePaymentMutation
} from '~/generated/graphql'
import { useInternationalization } from '~/hooks/core/useInternationalization'
import { useCurrentUser } from '~/hooks/useCurrentUser'
Expand Down Expand Up @@ -256,15 +255,9 @@ 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({
Expand Down
13 changes: 3 additions & 10 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 All @@ -88,7 +87,7 @@ import {
useRetryTaxProviderVoidingMutation,
useSyncHubspotIntegrationInvoiceMutation,
useSyncIntegrationInvoiceMutation,
useSyncSalesforceInvoiceMutation,
useSyncSalesforceInvoiceMutation
} from '~/generated/graphql'
import { useInternationalization } from '~/hooks/core/useInternationalization'
import { useLocationHistory } from '~/hooks/core/useLocationHistory'
Expand Down Expand Up @@ -736,15 +735,9 @@ 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,
Expand Down
20 changes: 5 additions & 15 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,11 +398,7 @@ const InvoicesPage = () => {
<Button
variant="primary"
onClick={() => {
if (
organization?.premiumIntegrations.includes(
PremiumIntegrationTypeEnum.ManualPayments,
)
) {
if (isPremium) {
navigate(CREATE_PAYMENT_ROUTE)
} else {
premiumWarningDialogRef.current?.openDialog({
Expand All @@ -413,13 +409,7 @@ const InvoicesPage = () => {
})
}
}}
endIcon={
organization?.premiumIntegrations.includes(
PremiumIntegrationTypeEnum.ManualPayments,
)
? undefined
: 'sparkles'
}
endIcon={isPremium ? undefined : 'sparkles'}
>
{translate('text_1737471851634wpeojigr27w')}
</Button>
Expand Down

0 comments on commit efe0de0

Please sign in to comment.