Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NEOS-1415: re enable team accounts in oss #2632

Merged
merged 3 commits into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions backend/services/mgmt/v1alpha1/user-account-service/users.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,9 @@
if !s.cfg.IsAuthEnabled {
return nil, nucleuserrors.NewForbidden("unable to create team account as authentication is not enabled")
}
if s.cfg.IsNeosyncCloud {
return nil, nucleuserrors.NewForbidden("creating team accounts in Neosync Cloud is not currently enabled. Please contact us to gain access to a team account.")

Check warning on line 234 in backend/services/mgmt/v1alpha1/user-account-service/users.go

View check run for this annotation

Codecov / codecov/patch

backend/services/mgmt/v1alpha1/user-account-service/users.go#L234

Added line #L234 was not covered by tests
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The first makes it sound like we don't support it at all when in reality they just need to contact us for it.

Maybe just say, "Please contact us to create a team account."

Eventually, it'll just allow them to upgrade directly to it once the upgrade flow is set up.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, this was moreso to avoid someone circumventing the UI

}
user, err := s.GetUser(ctx, connect.NewRequest(&mgmtv1alpha1.GetUserRequest{}))
if err != nil {
return nil, err
Expand Down
67 changes: 4 additions & 63 deletions frontend/apps/web/app/(mgmt)/[account]/settings/billing/page.tsx
Original file line number Diff line number Diff line change
@@ -1,26 +1,16 @@
'use client';
import { useAccount } from '@/components/providers/account-provider';
import {
CreateNewTeamDialog,
CreateTeamFormValues,
} from '@/components/site-header/AccountSwitcher';
import { Badge } from '@/components/ui/badge';
import { Button } from '@/components/ui/button';
import { Dialog } from '@/components/ui/dialog';
import { Separator } from '@/components/ui/separator';
import { Skeleton } from '@/components/ui/skeleton';
import { useGetSystemAppConfig } from '@/libs/hooks/useGetSystemAppConfig';
import { getErrorMessage, toTitleCase } from '@/util/util';
import { useMutation, useQuery } from '@connectrpc/connect-query';
import { yupResolver } from '@hookform/resolvers/yup';
import { toTitleCase } from '@/util/util';
import { UserAccountType } from '@neosync/sdk';
import { createTeamAccount, getUserAccounts } from '@neosync/sdk/connectquery';
import { CheckCircledIcon, DiscordLogoIcon } from '@radix-ui/react-icons';
import Error from 'next/error';
import Link from 'next/link';
import { ReactElement, useState } from 'react';
import { useForm } from 'react-hook-form';
import { toast } from 'sonner';
import { ReactElement } from 'react';

const plans = [
{
Expand Down Expand Up @@ -68,23 +58,6 @@ export default function Billing(): ReactElement {
const { account } = useAccount();
const { data: systemAppConfigData, isLoading: isSystemAppConfigDataLoading } =
useGetSystemAppConfig();
const [showNewTeamDialog, setShowNewTeamDialog] = useState<boolean>(false);
const { refetch: mutate } = useQuery(getUserAccounts);
const { mutateAsync: createTeamAccountAsync } =
useMutation(createTeamAccount);
async function onSubmit(values: CreateTeamFormValues): Promise<void> {
try {
await createTeamAccountAsync({ name: values.name });
setShowNewTeamDialog(false);
mutate();
toast.success('Successfully created team!');
} catch (err) {
console.error(err);
toast.error('Unable to create team', {
description: getErrorMessage(err),
});
}
}

if (isSystemAppConfigDataLoading || !account?.type) {
return <Skeleton />;
Expand All @@ -107,10 +80,7 @@ export default function Billing(): ReactElement {
<NeedHelp />
<Plans
planType={account.type ?? UserAccountType.PERSONAL}
setShowNewTeamDialog={setShowNewTeamDialog}
showNewTeamDialog={showNewTeamDialog}
onSubmit={onSubmit}
upgradeHref={systemAppConfigData.calendlyUpgradeLink}
upgradeHref={systemAppConfigData?.calendlyUpgradeLink ?? ''}
/>
</div>
</div>
Expand Down Expand Up @@ -142,27 +112,10 @@ function NeedHelp(): ReactElement {

interface PlanProps {
planType: UserAccountType;
setShowNewTeamDialog: (val: boolean) => void;
showNewTeamDialog: boolean;
onSubmit: (values: CreateTeamFormValues) => Promise<void>;
upgradeHref: string;
}

function Plans({
planType,
showNewTeamDialog,
setShowNewTeamDialog,
onSubmit,
upgradeHref,
}: PlanProps): ReactElement {
const form = useForm({
mode: 'onChange',
resolver: yupResolver(CreateTeamFormValues),
defaultValues: {
name: '',
},
});

function Plans({ planType, upgradeHref }: PlanProps): ReactElement {
return (
<div>
<div className="border border-gray-200 rounded-xl p-6 flex flex-col gap-4">
Expand Down Expand Up @@ -202,18 +155,6 @@ function Plans({
<div className="text-sm self-end pb-1">/mo</div>
)}
</div>
<Dialog
open={showNewTeamDialog}
onOpenChange={setShowNewTeamDialog}
>
<CreateNewTeamDialog
form={form}
onSubmit={onSubmit}
setShowNewTeamDialog={setShowNewTeamDialog}
planType={planType}
upgradeHref={upgradeHref}
/>
</Dialog>
<div className="flex flex-col gap-2">
{plan.features.map((feat) => (
<div
Expand Down
Loading
Loading