klg-asutk-app/components/ApplicationCreateModal.tsx
Yuriy 0150aba4f5 Consolidation: KLG ASUTK + PAPA integration
- Unify API: lib/api.ts uses /api/v1, inbox uses /api/inbox (rewrites)
- Remove localhost refs: openapi, inbox page
- Add rewrites: /api/inbox|tmc -> inbox-server, /api/v1 -> FastAPI
- Add stub routes: knowledge/insights, recommendations, search, log-error
- Transfer from PAPA: prompts (inspection, tmc), scripts, supabase, data/tmc-requests
- Fix inbox-server: ORDER BY created_at, package.json
- Remove redundant app/api/inbox/files route (rewrites handle it)
- knowledge/ in gitignore (large PDFs)

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-08 17:18:31 +03:00

283 lines
8.9 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

'use client';
import { useState } from 'react';
interface ApplicationCreateModalProps {
isOpen: boolean;
onClose: () => void;
onCreate?: (application: {
number: string;
type: string;
status: string;
aircraft: string;
date: string;
organization: string;
description?: string;
}) => void;
}
export default function ApplicationCreateModal({ isOpen, onClose, onCreate }: ApplicationCreateModalProps) {
const [formData, setFormData] = useState({
number: '',
type: 'Регистрация ВС',
status: 'В обработке',
aircraft: '',
date: new Date().toISOString().split('T')[0],
organization: '',
description: '',
});
if (!isOpen) {
return null;
}
const handleChange = (field: string, value: string) => {
setFormData({ ...formData, [field]: value });
};
const handleSubmit = () => {
if (!formData.number || !formData.aircraft || !formData.organization) {
alert('Пожалуйста, заполните все обязательные поля');
return;
}
if (onCreate) {
onCreate(formData);
setFormData({
number: '',
type: 'Регистрация ВС',
status: 'В обработке',
aircraft: '',
date: new Date().toISOString().split('T')[0],
organization: '',
description: '',
});
onClose();
}
};
return (
<div
style={{
position: 'fixed',
top: 0,
left: 0,
right: 0,
bottom: 0,
backgroundColor: 'rgba(0, 0, 0, 0.5)',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
zIndex: 1000,
}}
onClick={onClose}
>
<div
style={{
backgroundColor: 'white',
borderRadius: '8px',
padding: '32px',
maxWidth: '600px',
width: '90%',
maxHeight: '90vh',
overflow: 'auto',
boxShadow: '0 4px 6px rgba(0, 0, 0, 0.1)',
}}
onClick={(e) => e.stopPropagation()}
>
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', marginBottom: '24px' }}>
<h2 style={{ fontSize: '24px', fontWeight: 'bold' }}>Создание заявки</h2>
<button
onClick={onClose}
style={{
background: 'none',
border: 'none',
fontSize: '24px',
cursor: 'pointer',
color: '#666',
padding: '0',
width: '32px',
height: '32px',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
}}
>
×
</button>
</div>
<div style={{ display: 'flex', flexDirection: 'column', gap: '20px' }}>
<div>
<label style={{ display: 'block', marginBottom: '8px', fontSize: '14px', fontWeight: '500' }}>
Номер заявки <span style={{ color: 'red' }}>*</span>:
</label>
<input
type="text"
value={formData.number}
onChange={(e) => handleChange('number', e.target.value)}
placeholder="APP-2025-XXX"
style={{
width: '100%',
padding: '12px',
border: '1px solid #ccc',
borderRadius: '4px',
fontSize: '14px',
}}
/>
</div>
<div>
<label style={{ display: 'block', marginBottom: '8px', fontSize: '14px', fontWeight: '500' }}>
Тип заявки:
</label>
<select
value={formData.type}
onChange={(e) => handleChange('type', e.target.value)}
style={{
width: '100%',
padding: '12px',
border: '1px solid #ccc',
borderRadius: '4px',
fontSize: '14px',
}}
>
<option value="Регистрация ВС">Регистрация ВС</option>
<option value="Сертификация">Сертификация</option>
<option value="Изменение регистрации">Изменение регистрации</option>
<option value="Снятие с учёта">Снятие с учёта</option>
</select>
</div>
<div style={{ display: 'grid', gridTemplateColumns: '1fr 1fr', gap: '16px' }}>
<div>
<label style={{ display: 'block', marginBottom: '8px', fontSize: '14px', fontWeight: '500' }}>
ВС <span style={{ color: 'red' }}>*</span>:
</label>
<input
type="text"
value={formData.aircraft}
onChange={(e) => handleChange('aircraft', e.target.value)}
style={{
width: '100%',
padding: '12px',
border: '1px solid #ccc',
borderRadius: '4px',
fontSize: '14px',
}}
/>
</div>
<div>
<label style={{ display: 'block', marginBottom: '8px', fontSize: '14px', fontWeight: '500' }}>
Организация <span style={{ color: 'red' }}>*</span>:
</label>
<input
type="text"
value={formData.organization}
onChange={(e) => handleChange('organization', e.target.value)}
style={{
width: '100%',
padding: '12px',
border: '1px solid #ccc',
borderRadius: '4px',
fontSize: '14px',
}}
/>
</div>
</div>
<div style={{ display: 'grid', gridTemplateColumns: '1fr 1fr', gap: '16px' }}>
<div>
<label style={{ display: 'block', marginBottom: '8px', fontSize: '14px', fontWeight: '500' }}>
Дата:
</label>
<input
type="date"
value={formData.date}
onChange={(e) => handleChange('date', e.target.value)}
style={{
width: '100%',
padding: '12px',
border: '1px solid #ccc',
borderRadius: '4px',
fontSize: '14px',
}}
/>
</div>
<div>
<label style={{ display: 'block', marginBottom: '8px', fontSize: '14px', fontWeight: '500' }}>
Статус:
</label>
<select
value={formData.status}
onChange={(e) => handleChange('status', e.target.value)}
style={{
width: '100%',
padding: '12px',
border: '1px solid #ccc',
borderRadius: '4px',
fontSize: '14px',
}}
>
<option value="В обработке">В обработке</option>
<option value="На рассмотрении">На рассмотрении</option>
</select>
</div>
</div>
<div>
<label style={{ display: 'block', marginBottom: '8px', fontSize: '14px', fontWeight: '500' }}>
Описание:
</label>
<textarea
value={formData.description}
onChange={(e) => handleChange('description', e.target.value)}
rows={4}
style={{
width: '100%',
padding: '12px',
border: '1px solid #ccc',
borderRadius: '4px',
fontSize: '14px',
fontFamily: 'inherit',
}}
placeholder="Введите описание заявки..."
/>
</div>
</div>
<div style={{ display: 'flex', gap: '12px', justifyContent: 'flex-end', marginTop: '32px' }}>
<button
onClick={onClose}
style={{
padding: '10px 20px',
backgroundColor: '#e0e0e0',
color: '#333',
border: 'none',
borderRadius: '4px',
cursor: 'pointer',
fontSize: '14px',
}}
>
Отмена
</button>
<button
onClick={handleSubmit}
style={{
padding: '10px 20px',
backgroundColor: '#1e3a5f',
color: 'white',
border: 'none',
borderRadius: '4px',
cursor: 'pointer',
fontSize: '14px',
}}
>
Создать
</button>
</div>
</div>
</div>
);
}