신규 회원사 가입을 간편하게 테스트하실 수 있도록 '자동 완성(⚡)' 기능을 추가하였습니다.
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -3,24 +3,34 @@ header('Content-Type: application/json');
|
||||
require_once("../lib/mydb.php");
|
||||
|
||||
$method = $_SERVER['REQUEST_METHOD'];
|
||||
$pdo = db_connect();
|
||||
try {
|
||||
$pdo = db_connect();
|
||||
|
||||
switch ($method) {
|
||||
case 'GET':
|
||||
handleGet($pdo);
|
||||
break;
|
||||
case 'POST':
|
||||
handlePost($pdo);
|
||||
break;
|
||||
case 'PUT':
|
||||
handlePut($pdo);
|
||||
break;
|
||||
case 'DELETE':
|
||||
handleDelete($pdo);
|
||||
break;
|
||||
default:
|
||||
echo json_encode(['error' => 'Method not allowed']);
|
||||
break;
|
||||
switch ($method) {
|
||||
case 'GET':
|
||||
handleGet($pdo);
|
||||
break;
|
||||
case 'POST':
|
||||
handlePost($pdo);
|
||||
break;
|
||||
case 'PUT':
|
||||
handlePut($pdo);
|
||||
break;
|
||||
case 'DELETE':
|
||||
handleDelete($pdo);
|
||||
break;
|
||||
default:
|
||||
http_response_code(405);
|
||||
echo json_encode(['error' => 'Method not allowed']);
|
||||
break;
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
http_response_code(500);
|
||||
echo json_encode([
|
||||
'error' => 'Backend Error',
|
||||
'message' => $e->getMessage(),
|
||||
'hint' => 'Check if the database table exists by running init_db.php'
|
||||
]);
|
||||
}
|
||||
|
||||
function handleGet($pdo) {
|
||||
@@ -122,4 +132,3 @@ function handleDelete($pdo) {
|
||||
echo json_encode(['error' => $e->getMessage()]);
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
@@ -25,10 +25,18 @@
|
||||
}
|
||||
</script>
|
||||
|
||||
<!-- React & ReactDOM -->
|
||||
<script crossorigin src="https://unpkg.com/react@18/umd/react.development.js"></script>
|
||||
<script crossorigin src="https://unpkg.com/react-dom@18/umd/react-dom.development.js"></script>
|
||||
<!-- React & ReactDOM (Production) -->
|
||||
<script crossorigin src="https://unpkg.com/react@18/umd/react.production.min.js"></script>
|
||||
<script crossorigin src="https://unpkg.com/react-dom@18/umd/react-dom.production.min.js"></script>
|
||||
|
||||
<!--
|
||||
Note: For production, Babel and Tailwind CDN should be pre-compiled.
|
||||
Currently kept for rapid development and mobility.
|
||||
-->
|
||||
<!-- Babel for JSX -->
|
||||
<script src="https://unpkg.com/@babel/standalone/babel.min.js"></script>
|
||||
|
||||
<!-- Icons: Lucide -->
|
||||
<script src="https://unpkg.com/lucide@latest"></script>
|
||||
</head>
|
||||
<body class="bg-background text-slate-800 antialiased font-sans">
|
||||
@@ -187,14 +195,30 @@
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [activeTab, setActiveTab] = useState('list');
|
||||
const [editingMember, setEditingMember] = useState(null);
|
||||
|
||||
// Auto-fill feature states
|
||||
const [registerKey, setRegisterKey] = useState(0);
|
||||
const [initialTestData, setInitialTestData] = useState({});
|
||||
|
||||
const fetchMembers = async () => {
|
||||
setLoading(true);
|
||||
try {
|
||||
const res = await fetch('api.php');
|
||||
const data = await res.json();
|
||||
setMembers(data.members || []);
|
||||
} catch (e) { console.error(e); }
|
||||
const text = await res.text();
|
||||
try {
|
||||
const data = JSON.parse(text);
|
||||
if (data.error) {
|
||||
alert(`서버 오류: ${data.message || data.error}\n${data.hint || ''}`);
|
||||
}
|
||||
setMembers(data.members || []);
|
||||
} catch (parseError) {
|
||||
console.error("Invalid JSON response:", text);
|
||||
alert("서버로부터 올바르지 않은 응답이 수신되었습니다. DB 연결 또는 테이블 생성 여부를 확인해주세요.");
|
||||
}
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
alert("통신 오류가 발생했습니다.");
|
||||
}
|
||||
setLoading(false);
|
||||
};
|
||||
|
||||
@@ -319,12 +343,44 @@
|
||||
</div>
|
||||
) : (
|
||||
<div className="max-w-3xl animate-in slide-in-from-right-4 duration-300">
|
||||
<div className="mb-6">
|
||||
<h3 className="text-xl font-bold text-slate-900">신규 회원사 가입</h3>
|
||||
<p className="text-xs text-slate-400">입력된 정보로 바로빌 RegistCorp API가 호출됩니다.</p>
|
||||
<div className="mb-6 flex justify-between items-center">
|
||||
<div>
|
||||
<h3 className="text-xl font-bold text-slate-900">신규 회원사 가입</h3>
|
||||
<p className="text-xs text-slate-400">입력된 정보로 바로빌 RegistCorp API가 호출됩니다.</p>
|
||||
</div>
|
||||
<button
|
||||
onClick={() => {
|
||||
const randomId = Math.random().toString(36).substring(2, 8);
|
||||
const randomBiz = `123-45-${Math.floor(10000 + Math.random() * 90000)}`;
|
||||
const testData = {
|
||||
bizNo: randomBiz,
|
||||
corpName: `테스트기업_${randomId}`,
|
||||
ceoName: '홍길동',
|
||||
addr: '서울특별시 강남구 테헤란로 123',
|
||||
bizType: '서비스',
|
||||
bizClass: '소프트웨어',
|
||||
id: `test_${randomId}`,
|
||||
pwd: 'password123!',
|
||||
managerName: '김철수',
|
||||
managerHP: '010-1234-5678',
|
||||
managerEmail: `test_${randomId}@example.com`
|
||||
};
|
||||
// Trigger a custom event or use a state update mechanism
|
||||
// provided by the child component if available.
|
||||
// Since we're in the parent, we'll pass it down via a key or ref if needed,
|
||||
// but for simpler implementation, we'll use a unique key to reset the form component with new initialData.
|
||||
setRegisterKey(prev => prev + 1);
|
||||
setInitialTestData(testData);
|
||||
}}
|
||||
className="flex items-center gap-2 px-4 py-2 bg-amber-100 text-amber-700 rounded-lg hover:bg-amber-200 transition-all font-bold text-xs"
|
||||
title="랜덤 테스트 데이터 입력"
|
||||
>
|
||||
<i data-lucide="zap" className="w-4 h-4 fill-amber-500"></i>
|
||||
자동 완성
|
||||
</button>
|
||||
</div>
|
||||
<div className="bg-white rounded-card p-6 shadow-sm border border-slate-100">
|
||||
<MemberForm onSubmit={handleRegister} />
|
||||
<MemberForm key={registerKey} initialData={initialTestData} onSubmit={handleRegister} />
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
@@ -9,4 +9,3 @@ try {
|
||||
} catch (Exception $e) {
|
||||
echo "Error: " . $e->getMessage();
|
||||
}
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user