feat:새 계약 생성 테스트 데이터 자동입력 버튼 추가

- 번개 아이콘 클릭 시 랜덤 계약정보/서명자 자동 입력
- 슈퍼관리자/관리자에게만 표시
- 이메일은 테스트용 고정값 사용

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
김보곤
2026-02-12 19:59:18 +09:00
parent 16fce75760
commit c6116ad611

View File

@@ -9,11 +9,17 @@
@push('scripts')
@include('partials.react-cdn')
<script>
window.__esignCreate = {
isAdmin: @json(auth()->user()?->is_super_admin || auth()->user()?->hasRole(['admin', 'super-admin'])),
};
</script>
@verbatim
<script type="text/babel">
const { useState, useEffect, useRef } = React;
const csrfToken = document.querySelector('meta[name="csrf-token"]')?.content || '';
const IS_ADMIN = window.__esignCreate?.isAdmin || false;
const Input = ({ label, name, value, error, onChange, type = 'text', required = false, placeholder = '', style }) => (
<div style={style}>
@@ -67,6 +73,26 @@ className="w-full border border-gray-300 rounded-lg px-3 py-2 text-sm focus:ring
const handleChange = (key, val) => setForm(f => ({...f, [key]: val}));
const fillTestData = () => {
const pick = arr => arr[Math.floor(Math.random() * arr.length)];
const lastNames = ['김','이','박','최','정','강','조','윤','장','임'];
const firstNames = ['민수','서연','지훈','수빈','현우','하은','도윤','예진','준호','소영'];
const types = ['공급','납품','업무협약','기술이전','유지보수','컨설팅','위탁제조','OEM'];
const year = new Date().getFullYear();
const rPhone = () => `010-${String(Math.floor(Math.random()*9000)+1000)}-${String(Math.floor(Math.random()*9000)+1000)}`;
setForm(f => ({
...f,
title: `${year}년 ${pick(types)} 계약서`,
description: `테스트용 ${pick(types)} 계약 (자동생성)`,
creator_name: pick(lastNames) + pick(firstNames),
creator_email: 'awesomemyword@gmail.com',
creator_phone: rPhone(),
counterpart_name: pick(lastNames) + pick(firstNames),
counterpart_email: 'lightone2017@codebridge-x.com',
counterpart_phone: rPhone(),
}));
};
const handleSubmit = async (e) => {
e.preventDefault();
setSubmitting(true);
@@ -112,6 +138,14 @@ className="w-full border border-gray-300 rounded-lg px-3 py-2 text-sm focus:ring
<div className="flex items-center gap-3 mb-6">
<a href="/esign" className="text-gray-400 hover:text-gray-600 text-lg" hx-boost="false">&larr;</a>
<h1 className="text-xl font-bold text-gray-900"> 계약 생성</h1>
{IS_ADMIN && (
<button type="button" onClick={fillTestData} title="테스트 데이터 자동 입력"
className="w-8 h-8 flex items-center justify-center rounded-lg text-amber-500 hover:bg-amber-50 hover:text-amber-600 transition-colors">
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
<path d="M13 2L3 14h9l-1 8 10-12h-9l1-8z"/>
</svg>
</button>
)}
</div>
{errors.general && <div className="bg-red-50 border border-red-200 text-red-700 px-4 py-3 rounded-lg mb-4 text-sm">{errors.general}</div>}