import React, { useState } from 'react';
import { Search, Plus, Edit2, Save, X } from 'lucide-react';
const SalonCustomerManagement = () => {
const [customers, setCustomers] = useState([]);
const [searchTerm, setSearchTerm] = useState('');
const [isAdding, setIsAdding] = useState(false);
const [editingId, setEditingId] = useState(null);
const [formData, setFormData] = useState({
name: '',
address: '',
gender: '',
age: '',
firstVisit: '',
lastVisit: '',
menu: '',
price: '',
notes: ''
});
const resetForm = () => {
setFormData({
name: '',
address: '',
gender: '',
age: '',
firstVisit: '',
lastVisit: '',
menu: '',
price: '',
notes: ''
});
};
const handleSubmit = () => {
if (!formData.name.trim()) {
alert('名前を入力してください');
return;
}
if (editingId !== null) {
setCustomers(customers.map(c =>
c.id === editingId ? { ...formData, id: editingId } : c
));
setEditingId(null);
} else {
setCustomers([...customers, { ...formData, id: Date.now() }]);
setIsAdding(false);
}
resetForm();
};
const handleEdit = (customer) => {
setFormData(customer);
setEditingId(customer.id);
setIsAdding(true);
};
const handleCancel = () => {
setIsAdding(false);
setEditingId(null);
resetForm();
};
const filteredCustomers = customers.filter(customer =>
customer.name.toLowerCase().includes(searchTerm.toLowerCase()) ||
customer.address.toLowerCase().includes(searchTerm.toLowerCase())
);
return (
美容室顧客管理システム
{isAdding && (
{editingId ? '顧客情報編集' : '新規顧客登録'}
)}
登録顧客数: {customers.length}名 / 表示中: {filteredCustomers.length}名
名前 |
性別 |
年齢 |
最終来店日 |
利用メニュー |
利用単価 |
操作 |
{filteredCustomers.length === 0 ? (
{customers.length === 0 ? '顧客データがありません。「新規登録」から追加してください。' : '検索条件に一致する顧客が見つかりません。'}
|
) : (
filteredCustomers.map((customer) => (
{customer.name} |
{customer.gender} |
{customer.age}歳 |
{customer.lastVisit} |
{customer.menu} |
¥{customer.price ? Number(customer.price).toLocaleString() : '-'} |
|
))
)}
);
};
export default SalonCustomerManagement;