@@ -37,14 +37,16 @@ import {
3737} from "~/utils/pathBuilder" ;
3838import { generateVercelOAuthState } from "~/v3/vercel/vercelOAuthState.server" ;
3939
40+ const WORKING_ON_OTHER = "Other/not sure yet" ;
41+
4042const workingOnOptions = [
4143 "AI agent" ,
4244 "Media processing pipeline" ,
4345 "Media generation with AI" ,
4446 "Event-driven workflow" ,
4547 "Realtime streaming" ,
4648 "Internal tool or background job" ,
47- "Other/not sure yet" ,
49+ WORKING_ON_OTHER ,
4850] as const ;
4951
5052const goalOptions = [
@@ -183,37 +185,40 @@ export const action: ActionFunction = async ({ request, params }) => {
183185 const configurationId = url . searchParams . get ( "configurationId" ) ;
184186 const next = url . searchParams . get ( "next" ) ;
185187
186- const onboardingData : Record < string , Prisma . InputJsonValue > = { } ;
188+ try {
189+ const stringArraySchema = z . array ( z . string ( ) ) ;
190+
191+ const onboardingData : Record < string , Prisma . InputJsonValue > = { } ;
187192
188- if ( submission . value . workingOn ) {
189- const workingOn = JSON . parse ( submission . value . workingOn ) as string [ ] ;
190- if ( workingOn . length > 0 ) {
191- onboardingData . workingOn = workingOn ;
193+ if ( submission . value . workingOn ) {
194+ const workingOn = stringArraySchema . parse ( JSON . parse ( submission . value . workingOn ) ) ;
195+ if ( workingOn . length > 0 ) {
196+ onboardingData . workingOn = workingOn ;
197+ }
192198 }
193- }
194- if ( submission . value . workingOnOther ) {
195- onboardingData . workingOnOther = submission . value . workingOnOther ;
196- }
197- if ( submission . value . technologies ) {
198- const technologies = JSON . parse ( submission . value . technologies ) as string [ ] ;
199- if ( technologies . length > 0 ) {
200- onboardingData . technologies = technologies ;
199+ if ( submission . value . workingOnOther ) {
200+ onboardingData . workingOnOther = submission . value . workingOnOther ;
201201 }
202- }
203- if ( submission . value . technologiesOther ) {
204- const technologiesOther = JSON . parse ( submission . value . technologiesOther ) as string [ ] ;
205- if ( technologiesOther . length > 0 ) {
206- onboardingData . technologiesOther = technologiesOther ;
202+ if ( submission . value . technologies ) {
203+ const technologies = stringArraySchema . parse ( JSON . parse ( submission . value . technologies ) ) ;
204+ if ( technologies . length > 0 ) {
205+ onboardingData . technologies = technologies ;
206+ }
207207 }
208- }
209- if ( submission . value . goals ) {
210- const goals = JSON . parse ( submission . value . goals ) as string [ ] ;
211- if ( goals . length > 0 ) {
212- onboardingData . goals = goals ;
208+ if ( submission . value . technologiesOther ) {
209+ const technologiesOther = stringArraySchema . parse (
210+ JSON . parse ( submission . value . technologiesOther )
211+ ) ;
212+ if ( technologiesOther . length > 0 ) {
213+ onboardingData . technologiesOther = technologiesOther ;
214+ }
215+ }
216+ if ( submission . value . goals ) {
217+ const goals = stringArraySchema . parse ( JSON . parse ( submission . value . goals ) ) ;
218+ if ( goals . length > 0 ) {
219+ onboardingData . goals = goals ;
220+ }
213221 }
214- }
215-
216- try {
217222 const project = await createProject ( {
218223 organizationSlug : organizationSlug ,
219224 name : submission . value . projectName ,
@@ -316,11 +321,11 @@ export default function Page() {
316321 const [ shuffledWorkingOn , setShuffledWorkingOn ] = useState < string [ ] > ( [ ...workingOnOptions ] ) ;
317322
318323 useEffect ( ( ) => {
319- const nonOther = workingOnOptions . filter ( ( o ) => o !== "Other/not sure yet" ) ;
320- setShuffledWorkingOn ( [ ...shuffleArray ( nonOther ) , "Other/not sure yet" ] ) ;
324+ const nonOther = workingOnOptions . filter ( ( o ) => o !== WORKING_ON_OTHER ) ;
325+ setShuffledWorkingOn ( [ ...shuffleArray ( nonOther ) , WORKING_ON_OTHER ] ) ;
321326 } , [ ] ) ;
322327
323- const showWorkingOnOther = selectedWorkingOn . includes ( "Other/not sure yet" ) ;
328+ const showWorkingOnOther = selectedWorkingOn . includes ( WORKING_ON_OTHER ) ;
324329
325330 return (
326331 < AppContainer className = "bg-charcoal-900" >
0 commit comments