MCPcopy Create free account
hub / github.com/Openpanel-dev/openpanel / AddProject

Function AddProject

apps/start/src/modals/add-project.tsx:30–243  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

28type IForm = z.infer<typeof validator>;
29
30export 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({

Callers

nothing calls this directly

Calls 2

useAppParamsFunction · 0.90
mapMethod · 0.45

Tested by

no test coverage detected