'use client'; import { Avatar, Input, Select, SelectItem } from '@nextui-org/react'; import clsx from 'clsx'; import { getCountries } from 'lib/utils'; import { Billing } from 'lib/woocomerce/models/billing'; import { useState } from 'react'; const optionalFields = ['company']; export default function ShippingForm({ className, title, handleChangeAction }: { className?: string; title?: string; handleChangeAction?: (data: Billing) => void; }) { const countries = getCountries(); const initialState: Billing = { first_name: '', last_name: '', address_1: '', address_2: '', city: '', state: '', postcode: '', country: '', company: '', phone: '', email: '' }; const [formData, setFormData] = useState(initialState); const onChange = (e: React.ChangeEvent) => { const newData = { ...formData, [e.target.name]: e.target.value }; setFormData(newData); if (handleChangeAction) { handleChangeAction(newData); } }; const getLabel = (key: string) => key.charAt(0).toUpperCase() + key.slice(1).replace('_', ' '); return (
{title &&

{title}

} {Object.entries(formData) .filter(([key]) => key !== 'country') .map(([key, value], index) => (
))}
); }