mirror of
https://github.com/shadcn-ui/ui.git
synced 2026-06-11 09:51:40 +00:00
* feat: init * fix * fix * fix * feat * feat * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * feat: implement icons * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * feat: update init command * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * feat: dialog * feat * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * feat: add registry:base item type * feat: rename frame to canva * fix * feat * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fi * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * feat: add all colors * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * feat: add outfit font * fix * fix * fix * fix * fix * chore: changeset * fix * fix * fix * fix * fix * fix * fix * fix
56 lines
1.5 KiB
TypeScript
56 lines
1.5 KiB
TypeScript
"use server"
|
|
|
|
import { type FormState } from "@/app/(internal)/sink/(pages)/next-form/example-form"
|
|
import { exampleFormSchema } from "@/app/(internal)/sink/(pages)/schema"
|
|
|
|
export async function subscriptionAction(
|
|
_prevState: FormState,
|
|
formData: FormData
|
|
): Promise<FormState> {
|
|
// Simulate server processing
|
|
await new Promise((resolve) => setTimeout(resolve, 1000))
|
|
|
|
const values = {
|
|
name: formData.get("name") as string,
|
|
email: formData.get("email") as string,
|
|
plan: formData.get("plan") as "basic" | "pro",
|
|
billingPeriod: formData.get("billingPeriod") as string,
|
|
addons: formData.getAll("addons") as string[],
|
|
teamSize: parseInt(formData.get("teamSize") as string) || 1,
|
|
emailNotifications: formData.get("emailNotifications") === "on",
|
|
startDate: formData.get("startDate")
|
|
? new Date(formData.get("startDate") as string)
|
|
: new Date(),
|
|
theme: formData.get("theme") as string,
|
|
password: formData.get("password") as string,
|
|
comments: formData.get("comments") as string,
|
|
}
|
|
|
|
const result = exampleFormSchema.safeParse(values)
|
|
|
|
if (!result.success) {
|
|
return {
|
|
values,
|
|
success: false,
|
|
errors: result.error.flatten().fieldErrors,
|
|
}
|
|
}
|
|
|
|
// Simulate some business logic validation
|
|
if (result.data.email.includes("invalid")) {
|
|
return {
|
|
values,
|
|
success: false,
|
|
errors: {
|
|
email: ["This email domain is not supported"],
|
|
},
|
|
}
|
|
}
|
|
|
|
return {
|
|
values,
|
|
errors: null,
|
|
success: true,
|
|
}
|
|
}
|