MCPcopy Index your code
hub / github.com/CodebuffAI/codebuff / handleSubmit

Function handleSubmit

web/src/app/orgs/new/page.tsx:62–111  ·  view source on GitHub ↗
(e: React.FormEvent)

Source from the content-addressed store, hash-verified

60 }
61
62 const handleSubmit = async (e: React.FormEvent) => {
63 e.preventDefault()
64
65 const nameValidationError = validateName(formData.name)
66 if (nameValidationError) {
67 setNameError(nameValidationError)
68 toast({
69 title: 'Error',
70 description: nameValidationError,
71 variant: 'destructive',
72 })
73 return
74 }
75
76 setIsLoading(true)
77 try {
78 const response = await fetch('/api/orgs', {
79 method: 'POST',
80 headers: {
81 'Content-Type': 'application/json',
82 },
83 body: JSON.stringify({
84 name: formData.name,
85 description: formData.description,
86 }),
87 })
88
89 if (!response.ok) {
90 const error = await response.json()
91 throw new Error(error.error || 'Failed to create organization')
92 }
93
94 const organization = await response.json()
95
96 // Show success modal first, then navigate when user clicks "Get Started"
97 setCreatedOrganization(organization)
98 setSuccessModalOpen(true)
99 } catch (error) {
100 toast({
101 title: 'Error',
102 description:
103 error instanceof Error
104 ? error.message
105 : 'Failed to create organization',
106 variant: 'destructive',
107 })
108 } finally {
109 setIsLoading(false)
110 }
111 }
112
113 const handleContinueToOrganization = () => {
114 if (createdOrganization) {

Callers 1

MultipleChoiceFormFunction · 0.50

Calls 3

toastFunction · 0.90
validateNameFunction · 0.85
fetchFunction · 0.50

Tested by

no test coverage detected