()
| 28 | type IForm = z.infer<typeof validator>; |
| 29 | |
| 30 | export default function AddProject() { |
| 31 | const { organizationId } = useAppParams(); |
| 32 | const navigate = useNavigate(); |
| 33 | const form = useForm<IForm>({ |
| 34 | resolver: zodResolver(validator), |
| 35 | defaultValues: { |
| 36 | organizationId, |
| 37 | timezone: '', // Not used |
| 38 | project: '', |
| 39 | domain: '', |
| 40 | cors: [], |
| 41 | website: false, |
| 42 | app: false, |
| 43 | backend: false, |
| 44 | }, |
| 45 | }); |
| 46 | const trpc = useTRPC(); |
| 47 | const queryClient = useQueryClient(); |
| 48 | const mutation = useMutation( |
| 49 | trpc.project.create.mutationOptions({ |
| 50 | onError: handleError, |
| 51 | onSuccess: (res) => { |
| 52 | queryClient.invalidateQueries( |
| 53 | trpc.project.list.queryFilter({ organizationId }) |
| 54 | ); |
| 55 | toast.success('Project created', { |
| 56 | description: `${res.name}`, |
| 57 | action: { |
| 58 | label: 'View project', |
| 59 | onClick: () => |
| 60 | navigate({ |
| 61 | to: '/$organizationId/$projectId', |
| 62 | params: { |
| 63 | organizationId, |
| 64 | projectId: res.id, |
| 65 | }, |
| 66 | }), |
| 67 | }, |
| 68 | }); |
| 69 | }, |
| 70 | }) |
| 71 | ); |
| 72 | |
| 73 | const onSubmit = (values: IForm) => { |
| 74 | mutation.mutate(values); |
| 75 | }; |
| 76 | |
| 77 | const isWebsite = useWatch({ |
| 78 | name: 'website', |
| 79 | control: form.control, |
| 80 | }); |
| 81 | |
| 82 | const isApp = useWatch({ |
| 83 | name: 'app', |
| 84 | control: form.control, |
| 85 | }); |
| 86 | |
| 87 | const isBackend = useWatch({ |
nothing calls this directly
no test coverage detected