import type { CustomerEntity, CustomerUpsertInput } from '../services/api/customers' export type CustomerFormValues = { name: string namePronunciation: string phone: string email: string birthday: string expectContact: 'LINE' | 'PHONE' | 'EMAIL' | 'NONE' hairLength: 'SHORT' | 'MEDIUM' | 'LONG' | 'UNCONFIRM' hairTexture: 'UNCONFIRM' | 'THIN' | 'NORMAL' | 'HARD_CRUDE' | 'CURLY' notice: string allergy: string innerRemark: string followContent: string nextFollowDate: string recommendVisitDate: string firstSuggestHair: 'AUTO' | 'LONG' | 'MEDIUM' | 'SHORT' planDate: string visitPurpose: 'CUT_DYE' | 'CUT' | 'DYE' | 'CONSULT_SIM' | '' trouble: string consultContent: string expectLook: string } export function emptyCustomerForm(): CustomerFormValues { return { name: '', namePronunciation: '', phone: '', email: '', birthday: '', expectContact: 'NONE', hairLength: 'UNCONFIRM', hairTexture: 'UNCONFIRM', notice: '', allergy: '', innerRemark: '', followContent: '', nextFollowDate: '', recommendVisitDate: '', firstSuggestHair: 'AUTO', planDate: '', visitPurpose: '', trouble: '', consultContent: '', expectLook: '', } } export function customerToFormValues(customer: CustomerEntity): CustomerFormValues { return { name: customer.name || '', namePronunciation: customer.namePronunciation || '', phone: customer.phone || '', email: customer.email || '', birthday: customer.birthday || '', expectContact: customer.expectContact || 'NONE', hairLength: customer.hairLength || 'UNCONFIRM', hairTexture: customer.hairTexture || 'UNCONFIRM', notice: customer.notice || '', allergy: customer.allergy || '', innerRemark: customer.innerRemark || '', followContent: customer.followContent || '', nextFollowDate: customer.nextFollowDate || '', recommendVisitDate: customer.recommendVisitDate || '', firstSuggestHair: customer.firstSuggestHair || 'AUTO', planDate: customer.planDate || '', visitPurpose: customer.visitPurpose || '', trouble: customer.trouble || '', consultContent: customer.consultContent || '', expectLook: customer.expectLook || '', } } export function formValuesToPayload(values: CustomerFormValues, avatar?: string): CustomerUpsertInput { const pick = (v: string) => (v.trim() ? v.trim() : undefined) return { name: values.name.trim(), phone: values.phone.trim(), namePronunciation: pick(values.namePronunciation), email: pick(values.email), birthday: pick(values.birthday), avatar, expectContact: values.expectContact, hairLength: values.hairLength, hairTexture: values.hairTexture, notice: pick(values.notice), allergy: pick(values.allergy), innerRemark: pick(values.innerRemark), followContent: pick(values.followContent), nextFollowDate: pick(values.nextFollowDate), recommendVisitDate: pick(values.recommendVisitDate), firstSuggestHair: values.firstSuggestHair, planDate: pick(values.planDate), visitPurpose: values.visitPurpose || undefined, trouble: pick(values.trouble), consultContent: pick(values.consultContent), expectLook: pick(values.expectLook), } }