"use client"; import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; import Link from "next/link"; import { signup } from "@/actions/auth-actions"; import { cn } from "@/lib/utils"; import { Loader } from "lucide-react"; import { useActionState } from "react"; import { useSearchParams } from "next/navigation"; import { Atoll, Island, Prisma } from "@prisma/client"; import * as React from "react" import { Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectTrigger, SelectValue, } from "@/components/ui/select" type AtollWithIslands = Prisma.AtollGetPayload<{ include: { islands: true; } }> export default function SignUpForm({ atolls }: { atolls: AtollWithIslands[] }) { const [atoll, setAtoll] = React.useState() const [island, setIsland] = React.useState() const [actionState, action, isPending] = useActionState(signup, { message: "", }); const params = useSearchParams(); const phoneNumberFromUrl = params.get("phone_number"); const NUMBER_WITHOUT_DASH = phoneNumberFromUrl?.split("-").join("") return (
{actionState.errors?.fieldErrors.name && ( {actionState.errors?.fieldErrors.name} )}
{actionState?.errors?.fieldErrors?.id_card?.[0] && ( {actionState.errors.fieldErrors.id_card[0]} )} {actionState.db_error === "id_card" && ( {actionState.message} )}
{/* {actionState?.errors?.fieldErrors.island_name && ( {actionState?.errors?.fieldErrors.island_name} )} */}
{actionState.errors?.fieldErrors?.house_name && ( {actionState.errors?.fieldErrors?.house_name} )}
{actionState.errors?.fieldErrors?.dob && ( {actionState.errors?.fieldErrors?.dob} )}
{actionState?.errors?.fieldErrors?.phone_number?.[0] && ( {actionState.errors.fieldErrors.phone_number[0]} )}
Already have an account?{" "} login
); }