diff --git a/src/app/admin/contract-management/components/contractEditor.tsx b/src/app/admin/contract-management/components/contractEditor.tsx index 543e394..d2cb6b8 100644 --- a/src/app/admin/contract-management/components/contractEditor.tsx +++ b/src/app/admin/contract-management/components/contractEditor.tsx @@ -15,7 +15,8 @@ export default function ContractEditor({ onSaved }: Props) { const [statusMsg, setStatusMsg] = useState(null); const [lang, setLang] = useState<'en' | 'de'>('en'); - const [type, setType] = useState('contract'); + const [type, setType] = useState<'contract' | 'bill' | 'other'>('contract'); + const [userType, setUserType] = useState<'personal' | 'company' | 'both'>('personal'); const [description, setDescription] = useState(''); const iframeRef = useRef(null); @@ -94,10 +95,21 @@ export default function ContractEditor({ onSaved }: Props) { const slug = (s: string) => s.toLowerCase().trim().replace(/[^a-z0-9]+/g, '-').replace(/^-+|-+$/g, '') || 'template'; + // NEW: all-fields-required guard + const canSave = Boolean( + name.trim() && + htmlCode.trim() && + description.trim() && + type && + userType && + lang + ) + const save = async (publish: boolean) => { const html = htmlCode.trim(); - if (!name || !html) { - setStatusMsg('Please enter a template name and content.'); + // NEW: validate all fields + if (!canSave) { + setStatusMsg('Please fill all required fields (name, HTML, type, user type, language, description).'); return; } @@ -113,7 +125,7 @@ export default function ContractEditor({ onSaved }: Props) { type, lang, description: description || undefined, - user_type: 'both', + user_type: userType, }); if (publish && created?.id) { @@ -140,6 +152,7 @@ export default function ContractEditor({ onSaved }: Props) { placeholder="Template name" value={name} onChange={(e) => setName(e.target.value)} + required className="w-full sm:w-1/2 rounded-lg border border-gray-300 bg-white px-4 py-2 text-sm text-gray-900 outline-none focus:ring-2 focus:ring-indigo-500/50 shadow" />
@@ -164,16 +177,30 @@ export default function ContractEditor({ onSaved }: Props) { {/* New metadata inputs */}
- setType(e.target.value)} + onChange={(e) => setType(e.target.value as 'contract' | 'bill' | 'other')} + required className="w-full sm:w-1/3 rounded-lg border border-gray-300 bg-white px-4 py-2 text-sm text-gray-900 outline-none focus:ring-2 focus:ring-indigo-500/50 shadow" - /> + > + + + + + { setQuery(e.target.value); setPage(1) }} - placeholder="Search name or email…" // CHANGED + placeholder="Search name or email…" className="md:col-span-2 w-full rounded-md border border-gray-300 px-3 py-2 text-sm focus:ring-2 focus:ring-indigo-500 focus:border-transparent text-gray-900 placeholder:text-gray-700 placeholder:opacity-100" />
- {/* Table */}
@@ -320,7 +269,6 @@ export default function RegisteredUserList({ users, loading }: Props) { - {/* REMOVED: Ref Code column */} @@ -344,7 +292,6 @@ export default function RegisteredUserList({ users, loading }: Props) { - {/* REMOVED: Ref Code cell */}
Email Type RegisteredStatus
{date} {u.status.charAt(0).toUpperCase() + u.status.slice(1)} @@ -358,7 +305,6 @@ export default function RegisteredUserList({ users, loading }: Props) {
- {/* Pagination */}
Showing {pageRows.length} of {filtered.length} users