diff --git a/src/app/user/membership/layout.tsx b/src/app/user/membership/layout.tsx new file mode 100644 index 000000000..e98b0bd64 --- /dev/null +++ b/src/app/user/membership/layout.tsx @@ -0,0 +1,19 @@ +import Invoices from '@/components/invoices' + +export default async function MembershipPageLayout({ + children, +}: { + children: React.ReactNode +}) { + return ( +
+

+ Membership +

+
+ {children} +
+ +
+ ) +} diff --git a/src/app/user/membership/page.tsx b/src/app/user/membership/page.tsx index b4716864a..deaec8b89 100644 --- a/src/app/user/membership/page.tsx +++ b/src/app/user/membership/page.tsx @@ -111,15 +111,10 @@ const Membership = () => { ) case hasStripeAccount: return ( -
- - - - -
+ ) case isTeamMember: return ( diff --git a/src/components/invoices/index.tsx b/src/components/invoices/index.tsx index 0747c3fc4..dda2ca668 100644 --- a/src/components/invoices/index.tsx +++ b/src/components/invoices/index.tsx @@ -1,7 +1,8 @@ +'use client' + import * as React from 'react' -import axios from '@/utils/configured-axios' -import {isEmpty} from 'lodash' import {format, parseISO} from 'date-fns' +import {trpc} from '@/app/_trpc/client' type HeadingProps = React.ComponentPropsWithoutRef & { headingAs?: 'h1' | 'h2' | 'h3' | 'h4' | 'p' @@ -10,31 +11,18 @@ type HeadingProps = React.ComponentPropsWithoutRef & { const Invoices: React.FunctionComponent< React.PropsWithChildren > = ({headingAs}) => { - const [transactions, setTransactions] = React.useState([]) - const [transactionsLoading, setTransactionsLoading] = React.useState(true) + const {data: transactions, status} = + trpc.user.transactionsForCurrent.useQuery() const Heading = headingAs ?? 'p' - React.useEffect(() => { - axios - .get(`${process.env.NEXT_PUBLIC_AUTH_DOMAIN}/api/v1/transactions`) - .then(({data}) => { - setTransactionsLoading(false) - setTransactions(data) - }) - }, []) - return (
- {transactionsLoading ? ( + {status === 'loading' ? (
) : (
- {isEmpty(transactions) ? ( - - No Transactions - - ) : ( + {!transactions ? null : (
Transactions diff --git a/src/components/pages/user/components/subscription-details.tsx b/src/components/pages/user/components/subscription-details.tsx index 4f892189f..a9bbf7c8b 100644 --- a/src/components/pages/user/components/subscription-details.tsx +++ b/src/components/pages/user/components/subscription-details.tsx @@ -201,7 +201,7 @@ const SubscriptionDetails: React.FunctionComponent< } return ( -
+
{subscriptionName ? (
@@ -228,7 +228,7 @@ const SubscriptionDetails: React.FunctionComponent<
) : ( -
+
{(viewer.is_pro || viewer.is_instructor) && (

You still have access to a Pro Membership. If you feel this is in diff --git a/src/pages/invoices/index.tsx b/src/pages/invoices/index.tsx index cd463935a..8cfde4f8f 100644 --- a/src/pages/invoices/index.tsx +++ b/src/pages/invoices/index.tsx @@ -7,7 +7,9 @@ const InvoicesPage: React.FunctionComponent< > = () => { return ( - +

+ +
) } diff --git a/src/server/routers/user.ts b/src/server/routers/user.ts index b38e12b62..60b8f906b 100644 --- a/src/server/routers/user.ts +++ b/src/server/routers/user.ts @@ -52,6 +52,11 @@ export const userRouter = router({ }, ).then((res) => res.json())) || [] + if (transactions?.error) { + console.error('error fetching transactions: ', transactions.error) + return null + } + return transactionsSchema.parse(transactions) }), accountsForCurrent: baseProcedure.query(async ({input, ctx}) => {