From cfd7fd9c5e768cef5239b737892afd62817ed57b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Gerhard=20Lindesva=CC=88rd?= Date: Tue, 11 Feb 2025 21:50:51 +0100 Subject: [PATCH] chore: more clean up + ts issues --- .../clients/create-client-success.tsx | 19 +-- apps/dashboard/src/modals/AddClient.tsx | 5 - apps/dashboard/src/modals/EditClient.tsx | 94 +------------- packages/db/code-migrations/1-settings.ts | 118 +----------------- packages/db/src/services/event.service.ts | 2 +- packages/trpc/src/routers/client.ts | 4 - packages/trpc/src/routers/onboarding.ts | 3 +- 7 files changed, 12 insertions(+), 233 deletions(-) diff --git a/apps/dashboard/src/components/clients/create-client-success.tsx b/apps/dashboard/src/components/clients/create-client-success.tsx index 639089ac..09edaba8 100644 --- a/apps/dashboard/src/components/clients/create-client-success.tsx +++ b/apps/dashboard/src/components/clients/create-client-success.tsx @@ -4,30 +4,19 @@ import { RocketIcon } from 'lucide-react'; import type { IServiceClient } from '@openpanel/db'; import CopyInput from '../forms/copy-input'; -import { Label } from '../ui/label'; type Props = IServiceClient; -export function CreateClientSuccess({ id, secret, cors }: Props) { +export function CreateClientSuccess({ id, secret }: Props) { return (
{secret && (
- {cors && ( -

- You will only need the secret if you want to send server events. -

- )} -
- )} - {cors && ( -
- -
- {cors} -
+

+ You will only need the secret if you want to send server events. +

)} diff --git a/apps/dashboard/src/modals/AddClient.tsx b/apps/dashboard/src/modals/AddClient.tsx index 275215e5..7f486093 100644 --- a/apps/dashboard/src/modals/AddClient.tsx +++ b/apps/dashboard/src/modals/AddClient.tsx @@ -1,22 +1,17 @@ 'use client'; -import AnimateHeight from '@/components/animate-height'; import { CreateClientSuccess } from '@/components/clients/create-client-success'; -import TagInput from '@/components/forms/tag-input'; import { Button, buttonVariants } from '@/components/ui/button'; -import { CheckboxInput } from '@/components/ui/checkbox'; import { Combobox } from '@/components/ui/combobox'; import { DialogFooter } from '@/components/ui/dialog'; import { Input } from '@/components/ui/input'; import { Label } from '@/components/ui/label'; -import { Switch } from '@/components/ui/switch'; import { useAppParams } from '@/hooks/useAppParams'; import { api, handleError } from '@/trpc/client'; import { cn } from '@/utils/cn'; import { zodResolver } from '@hookform/resolvers/zod'; import { SaveIcon } from 'lucide-react'; import { useRouter } from 'next/navigation'; -import { useState } from 'react'; import type { SubmitHandler } from 'react-hook-form'; import { Controller, useForm } from 'react-hook-form'; import { toast } from 'sonner'; diff --git a/apps/dashboard/src/modals/EditClient.tsx b/apps/dashboard/src/modals/EditClient.tsx index 2981e2bb..b41d04ab 100644 --- a/apps/dashboard/src/modals/EditClient.tsx +++ b/apps/dashboard/src/modals/EditClient.tsx @@ -1,12 +1,10 @@ import { ButtonContainer } from '@/components/button-container'; -import { InputWithLabel, WithLabel } from '@/components/forms/input-with-label'; -import TagInput from '@/components/forms/tag-input'; +import { InputWithLabel } from '@/components/forms/input-with-label'; import { Button } from '@/components/ui/button'; -import { CheckboxInput } from '@/components/ui/checkbox'; import { api, handleError } from '@/trpc/client'; import { zodResolver } from '@hookform/resolvers/zod'; import { useRouter } from 'next/navigation'; -import { Controller, useForm } from 'react-hook-form'; +import { useForm } from 'react-hook-form'; import { toast } from 'sonner'; import { z } from 'zod'; @@ -20,18 +18,11 @@ type EditClientProps = IServiceClient; const validator = z.object({ id: z.string().min(1), name: z.string().min(1), - cors: z.string().nullable(), - crossDomain: z.boolean().optional(), }); type IForm = z.infer; -export default function EditClient({ - id, - name, - cors, - crossDomain, -}: EditClientProps) { +export default function EditClient({ id, name }: EditClientProps) { const router = useRouter(); const { register, handleSubmit, reset, formState, control, setError } = useForm({ @@ -39,8 +30,6 @@ export default function EditClient({ defaultValues: { id, name, - cors, - crossDomain, }, }); @@ -59,81 +48,8 @@ export default function EditClient({ return ( -
{ - if (!values.cors) { - return setError('cors', { - type: 'required', - message: 'Please add a domain', - }); - } - - mutation.mutate(values); - })} - > -
- - - ( - - (tag === '*' ? 'Allow all domains' : tag)} - onChange={(newValue) => { - field.onChange( - newValue - .map((item) => { - const trimmed = item.trim(); - if ( - trimmed.startsWith('http://') || - trimmed.startsWith('https://') || - trimmed === '*' - ) { - return trimmed; - } - return `https://${trimmed}`; - }) - .join(','), - ); - }} - /> - - )} - /> - - { - return ( - -
Enable cross domain support
-
- This will let you track users across multiple domains -
-
- ); - }} - /> -
+ mutation.mutate(values))}> +