diff --git a/components/StartupForm.tsx b/components/StartupForm.tsx index be4729c..596e386 100644 --- a/components/StartupForm.tsx +++ b/components/StartupForm.tsx @@ -1,6 +1,6 @@ "use client"; -import React, { useState, useActionState } from "react"; +import React, { useState } from "react"; import { Input } from "@/components/ui/input"; import { Textarea } from "@/components/ui/textarea"; import MDEditor from "@uiw/react-md-editor"; @@ -29,40 +29,32 @@ const StartupForm = () => { }; await formSchema.parseAsync(formValues); - const result = await createPitch(prevState, formData, pitch); - if (result.status == "SUCCESS") { + if (result.status === "SUCCESS") { toast({ title: "Success", description: "Your startup pitch has been created successfully", }); - router.push(`/startup/${result._id}`); } - return result; } catch (error) { if (error instanceof z.ZodError) { - const fieldErorrs = error.flatten().fieldErrors; - - setErrors(fieldErorrs as unknown as Record); - + const fieldErrors = error.flatten().fieldErrors; + setErrors(fieldErrors as unknown as Record); toast({ title: "Error", description: "Please check your inputs and try again", variant: "destructive", }); - return { ...prevState, error: "Validation failed", status: "ERROR" }; } - toast({ title: "Error", description: "An unexpected error has occurred", variant: "destructive", }); - return { ...prevState, error: "An unexpected error has occurred", @@ -75,104 +67,82 @@ const StartupForm = () => { error: "", status: "INITIAL", }); - +//updated ui for cleaner modern look :)) return ( -
+
- + - - {errors.title &&

{errors.title}

} + {errors.title &&

{errors.title}

}
- +