'use client'; import { CreateClientSuccess } from '@/components/clients/create-client-success'; import { LogoSquare } from '@/components/logo'; import { Button, buttonVariants } from '@/components/ui/button'; import { Input } from '@/components/ui/input'; import { Label } from '@/components/ui/label'; import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs'; import { cn } from '@/utils/cn'; import { zodResolver } from '@hookform/resolvers/zod'; import { SaveIcon, WallpaperIcon } from 'lucide-react'; import { useRouter } from 'next/navigation'; import type { SubmitHandler } from 'react-hook-form'; import { useForm } from 'react-hook-form'; import { z } from 'zod'; import { api, handleError } from '../_trpc/client'; const validation = z .object({ organization: z.string().min(3), project: z.string().min(3), cors: z.string().nullable(), tab: z.string(), }) .refine( (data) => data.tab === 'other' || (data.tab === 'website' && data.cors !== ''), { message: 'Cors is required', path: ['cors'], } ); type IForm = z.infer; export function CreateOrganization() { const router = useRouter(); const form = useForm({ resolver: zodResolver(validation), defaultValues: { organization: '', project: '', cors: '', tab: 'website', }, }); const mutation = api.onboarding.organziation.useMutation({ onError: handleError, }); const onSubmit: SubmitHandler = (values) => { mutation.mutate({ ...values, cors: values.tab === 'website' ? values.cors : null, }); }; if (mutation.isSuccess && mutation.data.client) { return (

Nice job!

You're ready to start using our SDK. Save the client ID and secret (if you have any)
Read docs
); } return (

Welcome to Openpanel

Create your organization below (can be personal or a company) and your first project.
form.setValue('tab', val)} className="h-28" > Website Other
🔑 You will get a secret to use for your API requests.
); }