Home / File/ actions.ts — ui Source File

actions.ts — ui Source File

Architecture documentation for actions.ts, a typescript file in the ui codebase. 2 imports, 1 dependents.

File typescript DocumentationAtlas Changelog 2 imports 1 dependents 1 functions

Entity Profile

Dependency Diagram

graph LR
  62a8cba2_1dbd_c872_f153_9791a4429475["actions.ts"]
  11d387e7_6591_b486_7c74_3e18aafddef9["example-form"]
  62a8cba2_1dbd_c872_f153_9791a4429475 --> 11d387e7_6591_b486_7c74_3e18aafddef9
  98a1257b_f7a4_f49e_a053_05062def12e1["schema"]
  62a8cba2_1dbd_c872_f153_9791a4429475 --> 98a1257b_f7a4_f49e_a053_05062def12e1
  279f4d57_3c20_3ef1_88ba_f4b9142e9a0e["example-form.tsx"]
  279f4d57_3c20_3ef1_88ba_f4b9142e9a0e --> 62a8cba2_1dbd_c872_f153_9791a4429475
  style 62a8cba2_1dbd_c872_f153_9791a4429475 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

"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,
  }
}

Subdomains

Dependencies

  • example-form
  • schema

Frequently Asked Questions

What does actions.ts do?
actions.ts is a source file in the ui codebase, written in typescript. It belongs to the DocumentationAtlas domain, Changelog subdomain.
What functions are defined in actions.ts?
actions.ts defines 1 function(s): subscriptionAction.
What does actions.ts depend on?
actions.ts imports 2 module(s): example-form, schema.
What files import actions.ts?
actions.ts is imported by 1 file(s): example-form.tsx.
Where is actions.ts in the architecture?
actions.ts is located at apps/v4/app/(internal)/sink/(pages)/next-form/actions.ts (domain: DocumentationAtlas, subdomain: Changelog, directory: apps/v4/app/(internal)/sink/(pages)/next-form).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free