klg-asutk-app/components/AuditCreateModal.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.8 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 AuditCreateModalProps {
isOpen: boolean;
onClose: () => void;
onCreate?: (audit: {
number: string;
type: string;
status: string;
organization: string;
date: string;
inspector: string;
description?: string;
}) => void;
}
export default function AuditCreateModal({ isOpen, onClose, onCreate }: AuditCreateModalProps) {
const [formData, setFormData] = useState({
number: '',
type: 'Плановый аудит',
status: 'Запланирован',
organization: '',
date: new Date().toISOString().split('T')[0],
inspector: '',
description: '',
});
if (!isOpen) {
return null;
}
const handleChange = (field: string, value: string) => {
setFormData({ ...formData, [field]: value });
};
const handleSubmit = () => {
if (!formData.number || !formData.organization || !formData.inspector) {
alert('Пожалуйста, заполните все обязательные поля');
return;
}
if (onCreate) {
onCreate(formData);
setFormData({
number: '',
type: 'Плановый аудит',
status: 'Запланирован',
organization: '',
date: new Date().toISOString().split('T')[0],
inspector: '',
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="AUD-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>
</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.organization}
onChange={(e) => handleChange('organization', 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.inspector}
onChange={(e) => handleChange('inspector', 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>
<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>
);
}