Version 3 of the kit: - Radix UI replaced with Base UI (using the Shadcn UI patterns) - next-intl replaces react-i18next - enhanceAction deprecated; usage moved to next-safe-action - main layout now wrapped with [locale] path segment - Teams only mode - Layout updates - Zod v4 - Next.js 16.2 - Typescript 6 - All other dependencies updated - Removed deprecated Edge CSRF - Dynamic Github Action runner
64 lines
1.4 KiB
TypeScript
64 lines
1.4 KiB
TypeScript
'use client';
|
|
|
|
import { useState } from 'react';
|
|
|
|
import { CreateTeamAccountDialog } from '@kit/team-accounts/components';
|
|
import { Button } from '@kit/ui/button';
|
|
import {
|
|
Tooltip,
|
|
TooltipContent,
|
|
TooltipProvider,
|
|
TooltipTrigger,
|
|
} from '@kit/ui/tooltip';
|
|
import { Trans } from '@kit/ui/trans';
|
|
|
|
interface HomeAddAccountButtonProps {
|
|
className?: string;
|
|
canCreateTeamAccount?: {
|
|
allowed: boolean;
|
|
reason?: string;
|
|
};
|
|
}
|
|
|
|
export function HomeAddAccountButton(props: HomeAddAccountButtonProps) {
|
|
const [isAddingAccount, setIsAddingAccount] = useState(false);
|
|
|
|
const canCreate = props.canCreateTeamAccount?.allowed ?? true;
|
|
const reason = props.canCreateTeamAccount?.reason;
|
|
|
|
const button = (
|
|
<Button
|
|
className={props.className}
|
|
onClick={() => setIsAddingAccount(true)}
|
|
disabled={!canCreate}
|
|
>
|
|
<Trans i18nKey={'account.createTeamButtonLabel'} />
|
|
</Button>
|
|
);
|
|
|
|
return (
|
|
<>
|
|
{!canCreate && reason ? (
|
|
<TooltipProvider>
|
|
<Tooltip>
|
|
<TooltipTrigger
|
|
render={<span className="cursor-not-allowed">{button}</span>}
|
|
/>
|
|
|
|
<TooltipContent>
|
|
<Trans i18nKey={reason} defaults={reason} />
|
|
</TooltipContent>
|
|
</Tooltip>
|
|
</TooltipProvider>
|
|
) : (
|
|
button
|
|
)}
|
|
|
|
<CreateTeamAccountDialog
|
|
isOpen={isAddingAccount}
|
|
setIsOpen={setIsAddingAccount}
|
|
/>
|
|
</>
|
|
);
|
|
}
|