Skip to content

Commit

Permalink
fix-settings-billing-selfhosted
Browse files Browse the repository at this point in the history
  • Loading branch information
McPizza0 committed Jul 21, 2024
1 parent 891e141 commit d409015
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
import { z } from 'zod';
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 @@ -10,9 +10,20 @@ import Link from 'next/link';
import { cn } from '@/src/lib/utils';
import { PageTitle } from '../../../_components/page-title';
import { Skeleton } from '@/src/components/shadcn-ui/skeleton';
import { useRouter } from 'next/navigation';

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 @@ -11,6 +11,9 @@ import {
import type { SpaceStatus } from '@u22n/utils/spaces';

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 d409015

Please sign in to comment.