Skip to content

Commit

Permalink
fix-settings-billing-selfhosted
Browse files Browse the repository at this point in the history
  • Loading branch information
McPizza0 authored and BlankParticle committed Jul 28, 2024
1 parent 07a78f4 commit 24bdecd
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 5 deletions.
7 changes: 7 additions & 0 deletions apps/platform/trpc/routers/orgRouter/iCanHaz/iCanHazRouter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@ import { router, orgProcedure, createCallerFactory } from '~platform/trpc/trpc';
import { billingTrpcClient } from '~platform/utils/tRPCServerClients';

export const iCanHazRouter = router({
billing: orgProcedure.query(async ({ ctx }) => {
const { selfHosted } = ctx;
if (selfHosted) {
return false;
}
return await billingTrpcClient.iCanHaz.billing.query();
}),
domain: orgProcedure.query(async ({ ctx }) => {
const { org, selfHosted } = ctx;
if (selfHosted) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ type NavLinks = {

export default function SettingsSidebar() {
const orgShortcode = useGlobalStore((state) => state.currentOrg.shortcode);
const { data: hazBilling } = platform.org.iCanHaz.billing.useQuery({
orgShortcode
});

const { data: isAdmin } =
platform.org.users.members.isOrgMemberAdmin.useQuery({
Expand Down Expand Up @@ -56,11 +59,15 @@ export default function SettingsSidebar() {
to: `/${orgShortcode}/settings/org`,
icon: <Buildings />
},
{
label: 'Billing',
to: `/${orgShortcode}/settings/org/setup/billing`,
icon: <CreditCard />
}
...(hazBilling
? [
{
label: 'Billing',
to: `/${orgShortcode}/settings/org/setup/billing`,
icon: <CreditCard />
}
]
: [])
];

const orgUserLinks: NavLinks[] = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { Skeleton } from '@/src/components/shadcn-ui/skeleton';
import { PageTitle } from '../../../_components/page-title';
import { Button } from '@/src/components/shadcn-ui/button';
import { PricingTable } from './_components/plans-table';
import { useRouter } from 'next/navigation';
import CalEmbed from '@calcom/embed-react';
import { platform } from '@/src/lib/trpc';
import { cn } from '@/src/lib/utils';
Expand All @@ -13,6 +14,16 @@ import Link from 'next/link';

export default function Page() {
const orgShortcode = useGlobalStore((state) => state.currentOrg.shortcode);

const { data: hazBilling } = platform.org.iCanHaz.billing.useQuery({
orgShortcode
});

const router = useRouter();
if (!hazBilling) {
router.push(`/${orgShortcode}/settings/`);
}

const { data, isLoading } =
platform.org.setup.billing.getOrgBillingOverview.useQuery({
orgShortcode
Expand Down
3 changes: 3 additions & 0 deletions ee/apps/billing/trpc/routers/iCanHazRouter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ import { eq } from '@u22n/database/orm';
import { z } from 'zod';

export const iCanHazRouter = router({
billing: protectedProcedure.query(async ({ ctx, input }) => {
return true;
}),
domain: protectedProcedure
.input(z.object({ orgId: z.number() }))
.query(async ({ ctx, input }) => {
Expand Down

0 comments on commit 24bdecd

Please sign in to comment.