klg-asutk-app/components/OrganizationEditModal.tsx
Yuriy aa052763f6 Безопасность и качество: 8 исправлений + обновления
- .env.example: полный шаблон, защита секретов
- .gitignore: явное исключение .env.* и секретов
- layout.tsx: XSS — заменён dangerouslySetInnerHTML на next/script для SW
- ESLint: no-console error (allow warn/error), ignore scripts/
- scripts/remove-console-logs.js: очистка console.log без glob
- backend/routes/modules: README с планом рефакторинга крупных файлов
- SECURITY.md: гид по секретам, XSS, CORS, auth, линту
- .husky/pre-commit: запуск npm run lint

+ прочие правки приложения и бэкенда

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-14 21:29:16 +03:00

28 lines
2.2 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, useEffect } from 'react';
import { Modal } from '@/components/ui';
import FormField from '@/components/ui/FormField';
interface Props { isOpen: boolean; onClose: () => void; organization: any; onSave: (data: any) => void; }
export default function OrganizationEditModal({ isOpen, onClose, organization, onSave }: Props) {
const [form, setForm] = useState({ name: '', kind: 'operator', inn: '', address: '', contact_email: '', contact_phone: '' });
const set = (k: string, v: string) => setForm(f => ({ ...f, [k]: v }));
useEffect(() => {
if (organization) setForm({ name: organization.name || '', kind: organization.kind || 'operator', inn: organization.inn || '', address: organization.address || '', contact_email: organization.contact_email || '', contact_phone: organization.contact_phone || '' });
}, [organization]);
return (
<Modal isOpen={isOpen} onClose={onClose} title={`Редактировать: ${organization?.name || ''}`} size="md"
footer={<><button onClick={onClose} className="btn-secondary">Отмена</button><button onClick={() => onSave(form)} className="btn-primary">Сохранить</button></>}>
<FormField label="Название" required><input value={form.name} onChange={e => set('name', e.target.value)} className="input-field" /></FormField>
<FormField label="Тип"><select value={form.kind} onChange={e => set('kind', e.target.value)} className="input-field"><option value="operator">Оператор</option><option value="mro">ТОиР</option><option value="authority">Орган власти</option></select></FormField>
<FormField label="ИНН"><input value={form.inn} onChange={e => set('inn', e.target.value)} className="input-field" /></FormField>
<FormField label="Адрес"><input value={form.address} onChange={e => set('address', e.target.value)} className="input-field" /></FormField>
<FormField label="Email"><input type="email" value={form.contact_email} onChange={e => set('contact_email', e.target.value)} className="input-field" /></FormField>
<FormField label="Телефон"><input value={form.contact_phone} onChange={e => set('contact_phone', e.target.value)} className="input-field" /></FormField>
</Modal>
);
}