Spaces:
Running
Running
File size: 30,890 Bytes
33d9e63 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 | /**
* @license
* SPDX-License-Identifier: Apache-2.0
*/
import React from 'react';
import { NetworkType, StrengthOption, Question } from '../../types';
import { defaultsService, SystemDefaults } from '../../services/defaultsService';
import { Tabs } from '../common/Tabs';
import { Button } from '../common/Button';
import { Input } from '../common/Input';
import { TextArea } from '../common/TextArea';
import { PjtBodyCard } from '../pjt/PjtBodyCard';
import { QuestionRow } from '../pjt/QuestionRow';
import { Modal } from '../common/Modal';
import {
Plus,
Save,
Trash2,
ChevronUp,
ChevronDown,
RotateCcw,
ArrowLeft,
} from 'lucide-react';
import {
Table,
TableHeader,
TableBody,
TableRow,
TableHead,
TableCell,
} from '../common/Table';
interface OpsDefaultsProps {
onNavigateHome: () => void;
}
export const OpsDefaults: React.FC<OpsDefaultsProps> = ({ onNavigateHome }) => {
const [activeTab, setActiveTab] = React.useState<'questions' | 'network_types' | 'strength_scales' | 'notice_template'>('questions');
const [defaults, setDefaults] = React.useState<SystemDefaults | null>(null);
// Modal alert/confirm configuration state
const [modalConfig, setModalConfig] = React.useState<{
isOpen: boolean;
title: string;
message: string;
onConfirm?: () => void;
showCancel?: boolean;
}>({
isOpen: false,
title: '',
message: '',
});
const showAlert = (title: string, message: string) => {
setModalConfig({
isOpen: true,
title,
message,
showCancel: false,
});
};
const showConfirm = (title: string, message: string, onConfirm: () => void) => {
setModalConfig({
isOpen: true,
title,
message,
onConfirm,
showCancel: true,
});
};
// Load defaults on mount
React.useEffect(() => {
defaultsService.getDefaults().then((data) => {
setDefaults(data);
});
}, []);
// 1. Question states & actions
const [newQuestionText, setNewQuestionText] = React.useState('');
const [newNetworkType, setNewNetworkType] = React.useState('work');
const [newMaxSelections, setNewMaxSelections] = React.useState(5);
const handleUpdateQuestion = (qId: string, updates: Partial<Question>) => {
if (!defaults) return;
const updatedQs = defaults.QUESTIONS.map((q) =>
q.question_id === qId ? { ...q, ...updates } : q
);
setDefaults({ ...defaults, QUESTIONS: updatedQs });
};
const handleMoveQuestion = (index: number, direction: 'up' | 'down') => {
if (!defaults) return;
const targetIdx = direction === 'up' ? index - 1 : index + 1;
if (targetIdx < 0 || targetIdx >= defaults.QUESTIONS.length) return;
const copy = [...defaults.QUESTIONS];
const temp = copy[index];
copy[index] = copy[targetIdx];
copy[targetIdx] = temp;
const remapped = copy.map((q, idx) => ({ ...q, order_no: idx + 1 }));
setDefaults({ ...defaults, QUESTIONS: remapped });
};
const handleDeleteQuestion = (qId: string) => {
if (!defaults) return;
showConfirm(
'기본 질문 삭제',
'이 질문 문항을 기본 템플릿에서 삭제하시겠습니까? 이후 생성되는 프로젝트의 기본 문항 목록에 영향을 줍니다.',
() => {
const updatedQs = defaults.QUESTIONS.filter((q) => q.question_id !== qId);
const remapped = updatedQs.map((q, idx) => ({ ...q, order_no: idx + 1 }));
setDefaults({ ...defaults, QUESTIONS: remapped });
}
);
};
const handleAddQuestion = (e: React.FormEvent) => {
e.preventDefault();
if (!defaults || !newQuestionText.trim()) return;
const newQ: Question = {
question_id: `Q${defaults.QUESTIONS.length + 1}_${Date.now().toString().slice(-4)}`,
network_type: newNetworkType,
question_text: newQuestionText.trim(),
max_selections: Number(newMaxSelections),
is_required: true,
order_no: defaults.QUESTIONS.length + 1,
strength_options: defaults.STRENGTH_OPTIONS, // Use template strength options
};
setDefaults({
...defaults,
QUESTIONS: [...defaults.QUESTIONS, newQ],
});
setNewQuestionText('');
showAlert('알림', '기본 질문 문항이 추가되었습니다. 저장하기를 누르시면 최종 저장됩니다.');
};
// 2. Network type states & actions
const [newTypeName, setNewTypeName] = React.useState('');
const [newTypeEnglish, setNewTypeEnglish] = React.useState('');
const handleUpdateNetworkType = (index: number, field: 'value' | 'label', val: string) => {
if (!defaults) return;
const updated = [...defaults.NETWORK_TYPES];
updated[index] = {
...updated[index],
[field]: field === 'value' ? val.trim().toLowerCase().replace(/\s+/g, '_') : val,
};
setDefaults({ ...defaults, NETWORK_TYPES: updated });
};
const handleMoveNetworkType = (index: number, direction: 'up' | 'down') => {
if (!defaults) return;
const targetIdx = direction === 'up' ? index - 1 : index + 1;
if (targetIdx < 0 || targetIdx >= defaults.NETWORK_TYPES.length) return;
const copy = [...defaults.NETWORK_TYPES];
const temp = copy[index];
copy[index] = copy[targetIdx];
copy[targetIdx] = temp;
setDefaults({ ...defaults, NETWORK_TYPES: copy });
};
const handleDeleteNetworkType = (code: string) => {
if (!defaults) return;
showConfirm(
'기본 네트워크 분류 삭제',
'이 네트워크 분류를 기본 템플릿에서 삭제하시겠습니까?',
() => {
const updated = defaults.NETWORK_TYPES.filter((t) => t.value !== code);
setDefaults({ ...defaults, NETWORK_TYPES: updated });
}
);
};
const handleAddNetworkType = (e: React.FormEvent) => {
e.preventDefault();
if (!defaults) return;
const english = newTypeEnglish.trim().toLowerCase().replace(/\s+/g, '_');
const name = newTypeName.trim();
if (!english || !name) return;
if (defaults.NETWORK_TYPES.some((t) => t.value === english)) {
showAlert('알림', '이미 존재하는 영문 분류 코드입니다.');
return;
}
setDefaults({
...defaults,
NETWORK_TYPES: [...defaults.NETWORK_TYPES, { value: english, label: name }],
});
setNewTypeEnglish('');
setNewTypeName('');
showAlert('알림', '새로운 네트워크 분류가 임시 추가되었습니다. 저장하기를 누르시면 최종 저장됩니다.');
};
// 3. Strength Option states & actions
const [newStrengthLabel, setNewStrengthLabel] = React.useState('');
const handleUpdateStrengthLabel = (index: number, label: string) => {
if (!defaults) return;
const updated = [...defaults.STRENGTH_OPTIONS];
updated[index] = { ...updated[index], label };
setDefaults({ ...defaults, STRENGTH_OPTIONS: updated });
};
const handleMoveStrength = (index: number, direction: 'up' | 'down') => {
if (!defaults) return;
const targetIdx = direction === 'up' ? index - 1 : index + 1;
if (targetIdx < 0 || targetIdx >= defaults.STRENGTH_OPTIONS.length) return;
const copy = [...defaults.STRENGTH_OPTIONS];
const temp = copy[index];
copy[index] = copy[targetIdx];
copy[targetIdx] = temp;
const updated = copy.map((opt, idx) => ({
...opt,
value: String(idx + 1),
}));
setDefaults({ ...defaults, STRENGTH_OPTIONS: updated });
};
const handleDeleteStrength = (value: string) => {
if (!defaults) return;
showConfirm(
'기본 관계 척도 삭제',
'이 관계 빈도 척도를 기본 템플릿에서 삭제하시겠습니까?',
() => {
const filtered = defaults.STRENGTH_OPTIONS.filter((opt) => opt.value !== value);
const updated = filtered.map((opt, idx) => ({
...opt,
value: String(idx + 1),
}));
setDefaults({ ...defaults, STRENGTH_OPTIONS: updated });
}
);
};
const handleAddStrength = (e: React.FormEvent) => {
e.preventDefault();
if (!defaults || !newStrengthLabel.trim()) return;
const nextIndex = defaults.STRENGTH_OPTIONS.length + 1;
const val = String(nextIndex);
const lbl = newStrengthLabel.trim();
setDefaults({
...defaults,
STRENGTH_OPTIONS: [...defaults.STRENGTH_OPTIONS, { value: val, label: lbl }],
});
setNewStrengthLabel('');
showAlert('알림', '새로운 관계 빈도 척도가 임시 추가되었습니다. 저장하기를 누르시면 최종 저장됩니다.');
};
// 4. Notice template actions
const handleUpdateNoticeTemplate = (text: string) => {
if (!defaults) return;
setDefaults({ ...defaults, NOTICE_TEMPLATE: text });
};
// Save / Factory Reset
const handleSaveAll = () => {
if (!defaults) return;
defaultsService.saveDefaults(defaults)
.then(() => {
showAlert('성공', '시스템 초기값 설정이 성공적으로 저장되었습니다. 이후 생성되는 프로젝트에 자동 적용됩니다.');
})
.catch((err) => {
console.error(err);
showAlert('오류', '시스템 초기값 설정 저장 중 오류가 발생했습니다.');
});
};
const handleFactoryReset = () => {
showConfirm(
'시스템 초기값 완전 초기화',
'모든 설정을 공장 출시 시점의 defaults.json 파일 내용으로 초기화하시겠습니까? 기존 커스텀 초기 설정은 모두 삭제됩니다.',
() => {
defaultsService.resetDefaults()
.then((initial) => {
setDefaults(initial);
showAlert('알림', '모든 초기값 설정이 공장 출시 상태로 초기화되었습니다.');
})
.catch((err) => {
console.error(err);
showAlert('오류', '시스템 초기값 초기화 중 오류가 발생했습니다.');
});
}
);
};
if (!defaults) {
return (
<div className="flex items-center justify-center p-12 text-sm font-semibold text-slate-500">
설정 정보 로딩 중...
</div>
);
}
return (
<div className="space-y-6 font-sans antialiased" id="ops-defaults-view">
{/* Top Header Controls */}
<div className="flex flex-col md:flex-row justify-between items-start md:items-center gap-4 pb-2">
<div>
<button
onClick={onNavigateHome}
className="flex items-center gap-1.5 text-sm font-semibold text-slate-500 hover:text-slate-800 transition-colors border-0 bg-transparent cursor-pointer p-0 mb-1"
>
<ArrowLeft className="w-4 h-4" />
<span>홈으로 이동</span>
</button>
<h2 className="text-xl md:text-2xl font-bold text-slate-900 tracking-tight">시스템 초기값 설정 관리</h2>
<p className="text-sm text-slate-400 font-medium">
새 프로젝트 생성 시 자동으로 적용되는 기본 문항 및 템플릿을 설정합니다.
</p>
</div>
<div className="flex items-center gap-2 w-full md:w-auto">
<Button
onClick={handleFactoryReset}
variant="outline"
size="md"
leftIcon={<RotateCcw className="w-4 h-4" />}
id="factory-reset-defaults-btn"
className="flex-1 md:flex-initial"
>
초기 기본값 리셋
</Button>
<Button
onClick={handleSaveAll}
size="md"
leftIcon={<Save className="w-4 h-4" />}
id="save-defaults-btn"
className="flex-1 md:flex-initial"
>
전체 저장하기
</Button>
</div>
</div>
{/* Tabs */}
<Tabs
options={[
{ key: 'network_types', label: '네트워크 분류', mobileLabel: '분류' },
{ key: 'questions', label: '기본 질문', mobileLabel: '질문' },
{ key: 'strength_scales', label: '기본 척도', mobileLabel: '척도' },
{ key: 'notice_template', label: '안내문 템플릿', mobileLabel: '안내문' },
]}
activeKey={activeTab}
onChange={(key) => setActiveTab(key as any)}
/>
{/* Pane content matching active tab */}
<div className="grid grid-cols-1 gap-6" id="defaults-settings-pane">
{/* 1. Questions Tab */}
{activeTab === 'questions' && (
<div className="space-y-6">
<PjtBodyCard
title="기본 질문 목록"
info="새 프로젝트 생성 시 적용될 기본 질문 목록입니다."
>
<div className="border-0 md:border md:border-slate-100 md:rounded-lg overflow-x-auto">
<Table id="defaults-questions-table" className="w-full block md:table [&_td]:py-2">
<TableHeader className="hidden md:table-header-group">
<TableRow className="bg-slate-50 border-b border-slate-100 text-slate-400 text-sm font-bold uppercase tracking-tight">
<TableHead className="p-2 text-center">순서</TableHead>
<TableHead className="p-2 text-center min-w-30">유형</TableHead>
<TableHead className="p-2 text-center min-w-100">질문 문구</TableHead>
<TableHead className="p-2 text-center">최대 지목 인원</TableHead>
<TableHead className="p-2 text-center">정렬</TableHead>
<TableHead className="p-2 text-center">작업</TableHead>
</TableRow>
</TableHeader>
<TableBody className="block md:table-row-group space-y-3 md:space-y-0">
{defaults.QUESTIONS.map((question, idx) => (
<QuestionRow
key={question.question_id}
question={question}
index={idx}
isFirst={idx === 0}
isLast={idx === defaults.QUESTIONS.length - 1}
onMove={(direction) => handleMoveQuestion(idx, direction)}
onDelete={() => handleDeleteQuestion(question.question_id)}
onUpdateQuestion={handleUpdateQuestion}
networkTypes={defaults.NETWORK_TYPES}
/>
))}
{defaults.QUESTIONS.length === 0 && (
<TableRow>
<TableCell colSpan={6} className="p-6 text-center text-slate-400 block md:table-cell">
등록된 기본 질문이 없습니다. 아래에서 새로 추가해주세요.
</TableCell>
</TableRow>
)}
</TableBody>
</Table>
</div>
</PjtBodyCard>
<PjtBodyCard
title="새로운 기본 질문 추가"
info="템플릿에 등록할 기본 네트워크 질문 문항을 생성합니다."
>
<form onSubmit={handleAddQuestion} className="space-y-4" id="new-default-q-form">
<div className="grid grid-cols-1 md:grid-cols-2 gap-8">
<Input
label="네트워크 분류 *"
type="select"
value={newNetworkType}
onChange={(e) => setNewNetworkType(e.target.value)}
options={defaults.NETWORK_TYPES}
required
/>
<Input
label="최대 지목 인원 수 *"
type="number"
min={1}
max={20}
value={newMaxSelections}
onChange={(e) => setNewMaxSelections(Number(e.target.value))}
required
/>
</div>
<Input
label="질문 문구 *"
type="text"
value={newQuestionText}
onChange={(e) => setNewQuestionText(e.target.value)}
placeholder="예: 업무적으로 조언을 구하는 사람은?"
required
/>
<Button
type="submit"
id="add-default-question-btn"
leftIcon={<Plus className="w-4 h-4" />}
className="w-full"
>
기본 질문 목록에 추가
</Button>
</form>
</PjtBodyCard>
</div>
)}
{/* 2. Network Types Tab */}
{activeTab === 'network_types' && (
<div className="space-y-6">
<PjtBodyCard
title="기본 네트워크 분류 목록"
info="설문 문항 분류 필터 및 분석 등에 기본 제공되는 네트워크 유형입니다."
>
<div className="border border-slate-100 rounded-lg overflow-x-auto">
<Table id="defaults-network-type-table" className="text-xs sm:text-sm">
<TableHeader>
<TableRow className="bg-slate-50 border-b border-slate-100 text-slate-400 font-bold uppercase tracking-tight">
<TableHead className="p-2 text-center">순서</TableHead>
<TableHead className="p-2 text-center min-w-30">영문 코드</TableHead>
<TableHead className="p-2 text-center min-w-30">분류 표시 문구</TableHead>
<TableHead className="p-2 text-center">정렬</TableHead>
<TableHead className="p-2 text-center">작업</TableHead>
</TableRow>
</TableHeader>
<TableBody>
{defaults.NETWORK_TYPES.map((type, idx) => (
<TableRow key={idx}>
<TableCell className="p-3 text-center font-semibold text-slate-500">{idx + 1}</TableCell>
<TableCell className="p-3">
<input
type="text"
value={type.value}
onChange={(e) => handleUpdateNetworkType(idx, 'value', e.target.value)}
className="w-full px-2 py-1 text-sm border border-slate-200 focus:border-orange-500 focus:ring-1 focus:ring-orange-500/20 rounded outline-none text-slate-600"
required
/>
</TableCell>
<TableCell className="p-3">
<input
type="text"
value={type.label}
onChange={(e) => handleUpdateNetworkType(idx, 'label', e.target.value)}
className="w-full px-2 py-1 text-sm border border-slate-200 focus:border-orange-500 focus:ring-1 focus:ring-orange-500/20 rounded outline-none text-slate-800"
required
/>
</TableCell>
<TableCell className="p-3 text-center">
<div className="flex justify-center gap-1">
<button
type="button"
onClick={() => handleMoveNetworkType(idx, 'up')}
disabled={idx === 0}
className="p-1 text-slate-400 hover:text-slate-600 disabled:opacity-30 rounded cursor-pointer"
>
<ChevronUp className="w-4 h-4" />
</button>
<button
type="button"
onClick={() => handleMoveNetworkType(idx, 'down')}
disabled={idx === defaults.NETWORK_TYPES.length - 1}
className="p-1 text-slate-400 hover:text-slate-600 disabled:opacity-30 rounded cursor-pointer"
>
<ChevronDown className="w-4 h-4" />
</button>
</div>
</TableCell>
<TableCell className="p-3 text-center">
<button
type="button"
onClick={() => handleDeleteNetworkType(type.value)}
className="p-1 text-slate-300 hover:text-red-500 hover:bg-red-50 rounded cursor-pointer inline-flex items-center justify-center"
>
<Trash2 className="w-4 h-4" />
</button>
</TableCell>
</TableRow>
))}
{defaults.NETWORK_TYPES.length === 0 && (
<TableRow>
<TableCell colSpan={5} className="p-6 text-center text-slate-400">등록된 기본 네트워크 분류가 없습니다.</TableCell>
</TableRow>
)}
</TableBody>
</Table>
</div>
</PjtBodyCard>
<PjtBodyCard
title="네트워크 분류 추가"
info="기본 템플릿에 적용될 네트워크 유형 분류 옵션을 추가합니다."
>
<form onSubmit={handleAddNetworkType} className="space-y-4">
<div className="grid grid-cols-1 md:grid-cols-2 gap-8">
<Input
label="영문 분류 코드 *"
value={newTypeEnglish}
onChange={(e) => setNewTypeEnglish(e.target.value)}
placeholder="예: work, cooperation"
required
/>
<Input
label="분류 표시 문구 *"
value={newTypeName}
onChange={(e) => setNewTypeName(e.target.value)}
placeholder="예: 업무 협력, 동적 네트워크"
required
/>
</div>
<Button
type="submit"
size="md"
leftIcon={<Plus className="w-4 h-4" />}
id="add-default-network-type-btn"
className="w-full"
>
기본 분류에 추가
</Button>
</form>
</PjtBodyCard>
</div>
)}
{/* 3. Strength Scales Tab */}
{activeTab === 'strength_scales' && (
<div className="space-y-6">
<PjtBodyCard
title="기본 관계 척도 목록"
info="지목한 동료와의 관계 빈도/강도를 묻는 척도의 초기 템플릿입니다."
>
<div className="border border-slate-100 rounded-lg overflow-x-auto">
<Table id="defaults-scales-table" className="text-xs sm:text-sm">
<TableHeader>
<TableRow className="bg-slate-50 border-b border-slate-100 text-slate-400 font-bold uppercase tracking-tight">
<TableHead className="p-2 text-center">순서</TableHead>
<TableHead className="p-2 text-center min-w-20">척도 표시 문구</TableHead>
<TableHead className="p-2 text-center">정렬</TableHead>
<TableHead className="p-2 text-center">작업</TableHead>
</TableRow>
</TableHeader>
<TableBody>
{defaults.STRENGTH_OPTIONS.map((opt, idx) => (
<TableRow key={idx}>
<TableCell className="p-3 text-center font-semibold text-slate-500">{idx + 1}</TableCell>
<TableCell className="p-3">
<input
type="text"
value={opt.label}
onChange={(e) => handleUpdateStrengthLabel(idx, e.target.value)}
className="w-full px-2 py-1 text-sm border border-slate-200 focus:border-orange-500 focus:ring-1 focus:ring-orange-500/20 rounded outline-none text-slate-800"
required
/>
</TableCell>
<TableCell className="p-3 text-center">
<div className="flex justify-center gap-0.5">
<button
type="button"
onClick={() => handleMoveStrength(idx, 'up')}
disabled={idx === 0}
className="p-1 text-slate-400 hover:text-slate-600 disabled:opacity-30 rounded cursor-pointer"
>
<ChevronUp className="w-4 h-4" />
</button>
<button
type="button"
onClick={() => handleMoveStrength(idx, 'down')}
disabled={idx === defaults.STRENGTH_OPTIONS.length - 1}
className="p-1 text-slate-400 hover:text-slate-600 disabled:opacity-30 rounded cursor-pointer"
>
<ChevronDown className="w-4 h-4" />
</button>
</div>
</TableCell>
<TableCell className="p-3 text-center">
<button
type="button"
onClick={() => handleDeleteStrength(opt.value)}
className="p-1 text-slate-300 hover:text-red-500 hover:bg-red-50 rounded cursor-pointer inline-flex items-center justify-center"
>
<Trash2 className="w-4 h-4" />
</button>
</TableCell>
</TableRow>
))}
{defaults.STRENGTH_OPTIONS.length === 0 && (
<TableRow>
<TableCell colSpan={4} className="p-6 text-center text-slate-400">등록된 기본 척도가 없습니다.</TableCell>
</TableRow>
)}
</TableBody>
</Table>
</div>
</PjtBodyCard>
<PjtBodyCard
title="새로운 척도 추가"
info="기본 템플릿에 관계 강도/빈도 척도 옵션을 추가합니다."
>
<form onSubmit={handleAddStrength} className="space-y-4">
<div className="flex items-end gap-4 w-full">
<div className="flex-1 w-full">
<Input
label="척도 표시 문구 *"
type="text"
value={newStrengthLabel}
onChange={(e) => setNewStrengthLabel(e.target.value)}
placeholder="예: 거의 매일, 주 1~2회"
required
/>
</div>
<Button type="submit" className="w-auto">추가</Button>
</div>
</form>
</PjtBodyCard>
</div>
)}
{/* 4. Notice Template Tab */}
{activeTab === 'notice_template' && (
<div className="space-y-6">
<PjtBodyCard
title="기본 안내문 템플릿 편집"
info="임직원 설문 안내 시 활용되는 공통 공지 템플릿입니다."
>
<div className="space-y-4">
<TextArea
label="본문 내용 *"
value={defaults.NOTICE_TEMPLATE}
onChange={(e) => handleUpdateNoticeTemplate(e.target.value)}
rows={15}
required
className="font-mono"
/>
<div className="p-4 bg-slate-50 border border-slate-100 rounded-lg text-slate-500 text-sm leading-relaxed space-y-2">
<p className="font-bold text-slate-700">⚠️ 템플릿 치환자(Placeholder) 수정 금지</p>
<p>안내문 발송 시점에 프로젝트 정보로 자동 치환되는 특수 키워드들입니다. 템플릿 작성 시 그대로 포함하여 작성해 주세요.</p>
<ul className="list-disc list-inside space-y-1 font-semibold text-slate-600 pl-1">
<li><code className="text-orange-600 font-mono font-bold bg-orange-50 px-1 py-0.5 rounded">{"{start_date}"}</code> : 설문 시작 일자</li>
<li><code className="text-orange-600 font-mono font-bold bg-orange-50 px-1 py-0.5 rounded">{"{end_date}"}</code> : 설문 종료 일자</li>
<li><code className="text-orange-600 font-mono font-bold bg-orange-50 px-1 py-0.5 rounded">{"{common_survey_url}"}</code> : 설문 조사 참여용 공통 URL</li>
<li><code className="text-orange-600 font-mono font-bold bg-orange-50 px-1 py-0.5 rounded">{"{survey_login_id}"}</code> : 설문 참여용 로그인 ID</li>
<li><code className="text-orange-600 font-mono font-bold bg-orange-50 px-1 py-0.5 rounded">{"{survey_password_hash}"}</code> : 설문 참여용 비밀번호</li>
</ul>
</div>
</div>
</PjtBodyCard>
</div>
)}
</div>
{/* Modal dialog */}
<Modal
isOpen={modalConfig.isOpen}
onClose={() => setModalConfig({ ...modalConfig, isOpen: false })}
title={modalConfig.title}
showCloseButton={true}
footerActions={
<div className="flex justify-end gap-2 w-full">
{modalConfig.showCancel && (
<Button variant="secondary" onClick={() => setModalConfig({ ...modalConfig, isOpen: false })}>
취소
</Button>
)}
<Button
variant="primary"
onClick={() => {
modalConfig.onConfirm?.();
setModalConfig({ ...modalConfig, isOpen: false });
}}
>
확인
</Button>
</div>
}
>
<div className="py-2 text-sm text-slate-600 leading-relaxed">
{modalConfig.message}
</div>
</Modal>
</div>
);
};
|