Files
sam-manage/resources/views/project-management/projects/edit.blade.php

129 lines
5.0 KiB
PHP
Raw Normal View History

@extends('layouts.app')
@section('title', '프로젝트 수정')
@section('content')
<!-- 페이지 헤더 -->
<div class="flex items-center gap-4 mb-6">
<a href="{{ route('pm.projects.show', $project->id) }}" class="text-gray-500 hover:text-gray-700">
프로젝트 상세
</a>
<h1 class="text-2xl font-bold text-gray-800">✏️ 프로젝트 수정</h1>
</div>
<!-- -->
<div class="bg-white rounded-lg shadow-sm p-6 max-w-2xl">
<form id="projectForm">
<!-- 프로젝트명 -->
<div class="mb-6">
<label for="name" class="block text-sm font-medium text-gray-700 mb-2">
프로젝트명 <span class="text-red-500">*</span>
</label>
<input type="text"
id="name"
name="name"
required
value="{{ $project->name }}"
class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500"
placeholder="프로젝트 이름을 입력하세요">
</div>
<!-- 설명 -->
<div class="mb-6">
<label for="description" class="block text-sm font-medium text-gray-700 mb-2">
설명
</label>
<textarea id="description"
name="description"
rows="4"
class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500"
placeholder="프로젝트 설명을 입력하세요">{{ $project->description }}</textarea>
</div>
<!-- 상태 -->
<div class="mb-6">
<label for="status" class="block text-sm font-medium text-gray-700 mb-2">
상태
</label>
<select id="status"
name="status"
class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500">
@foreach($statuses as $value => $label)
<option value="{{ $value }}" {{ $project->status === $value ? 'selected' : '' }}>{{ $label }}</option>
@endforeach
</select>
</div>
<!-- 기간 -->
<div class="grid grid-cols-2 gap-4 mb-6">
<div>
<label for="start_date" class="block text-sm font-medium text-gray-700 mb-2">
시작일
</label>
<input type="date"
id="start_date"
name="start_date"
value="{{ $project->start_date?->format('Y-m-d') }}"
class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500">
</div>
<div>
<label for="end_date" class="block text-sm font-medium text-gray-700 mb-2">
종료일
</label>
<input type="date"
id="end_date"
name="end_date"
value="{{ $project->end_date?->format('Y-m-d') }}"
class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500">
</div>
</div>
<!-- 버튼 -->
<div class="flex gap-4">
<button type="submit"
class="bg-blue-600 hover:bg-blue-700 text-white px-6 py-2 rounded-lg transition">
저장
</button>
<a href="{{ route('pm.projects.show', $project->id) }}"
class="bg-gray-300 hover:bg-gray-400 text-gray-700 px-6 py-2 rounded-lg transition">
취소
</a>
</div>
</form>
</div>
@endsection
@push('scripts')
<script>
document.getElementById('projectForm').addEventListener('submit', async function(e) {
e.preventDefault();
const formData = new FormData(this);
const data = Object.fromEntries(formData.entries());
try {
const response = await fetch('/api/admin/pm/projects/{{ $project->id }}', {
method: 'PUT',
headers: {
'Content-Type': 'application/json',
'X-CSRF-TOKEN': '{{ csrf_token() }}',
'Accept': 'application/json'
},
body: JSON.stringify(data)
});
const result = await response.json();
if (result.success) {
showToast(result.message, 'success');
window.location.href = '{{ route('pm.projects.show', $project->id) }}';
} else {
showToast(result.message || '저장에 실패했습니다.', 'error');
}
} catch (error) {
console.error('Error:', error);
showToast('저장 중 오류가 발생했습니다.', 'error');
}
});
</script>
@endpush