Untitled

mail@pastecode.io avatar
unknown
typescript
2 months ago
794 B
6
Indexable
Never
export async function addEvent(
  prevState: AddEventFormState,
  formData: FormData,
): Promise<AddEventFormState> {
  const validatedFields = AddEventFormSchema.safeParse({
    title: formData.get('title'),
    description: formData.get('description'),
    dates: formData.get('dates'),
    startTime: formData.get('startTime'),
    endTime: formData.get('endTime'),
    checkbox: formData.get('checkbox'),
  });

  console.log(formData);

  // If any form fields are invalid, return early
  if (!validatedFields.success) {
    const errors = validatedFields.error.flatten().fieldErrors;
    console.log(errors);
    return {
      errors: errors,
    };
  } else {
    try {
    } catch (error) {
      console.error('Registration failed: ', error);
    }
  }
}
Leave a Comment