Merge pull request #1027 from automatisch/hide-invoices-when-empty

fix: hide empty invoices section
This commit is contained in:
Ali BARIN
2023-03-27 23:39:27 +02:00
committed by GitHub
2 changed files with 8 additions and 1 deletions

View File

@@ -7,6 +7,11 @@ const getInvoices = async (
context: Context context: Context
) => { ) => {
const subscription = await context.currentUser.$relatedQuery('subscription'); const subscription = await context.currentUser.$relatedQuery('subscription');
if (!subscription) {
return;
}
const invoices = await Billing.paddleClient.getInvoices( const invoices = await Billing.paddleClient.getInvoices(
Number(subscription.paddleSubscriptionId) Number(subscription.paddleSubscriptionId)
); );

View File

@@ -13,7 +13,9 @@ import useFormatMessage from 'hooks/useFormatMessage';
export default function Invoices() { export default function Invoices() {
const formatMessage = useFormatMessage(); const formatMessage = useFormatMessage();
const { invoices } = useInvoices(); const { invoices, loading } = useInvoices();
if (loading || invoices.length === 0) return <React.Fragment />;
return ( return (
<React.Fragment> <React.Fragment>