"use client"; import { FC } from "react"; import { UserProfile } from "../lib/db-types"; import { updateUserProfile } from "../lib/actions/userProfileActions"; import { useFormState, useFormStatus } from "react-dom"; import { useLocale, useTranslations } from "next-intl"; import Link from "next/link"; import AccountCircleIcon from "@mui/icons-material/AccountCircle"; export type AccountFormProps = { profile: UserProfile | null; } type FormFieldsProps = { profile: UserProfile | null; errors: any; message: string | null; } const FormFields: FC = ({ profile, errors, message }) => { const { pending } = useFormStatus(); const t = useTranslations("account-form"); const locale = useLocale(); return ( <>
{errors?.firstName && errors.firstName.map((error: string) => (

{error}

))}
{errors?.lastName && errors.lastName.map((error: string) => (

{error}

))}
{errors?.address && errors.address.map((error: string) => (

{error}

))}
{errors?.iban && errors.iban.map((error: string) => (

{error}

))}
{message && (

{message}

)}
{t("cancel-button")}
); }; export const AccountForm: FC = ({ profile }) => { const initialState = { message: null, errors: {} }; const [state, dispatch] = useFormState(updateUserProfile, initialState); const t = useTranslations("account-form"); return (

{t("title")}

); }; export const AccountFormSkeleton: FC = () => { return (
); };