dei voda #25

Merged
Seazn merged 1 commits from refactor/reverseChargeTemplate into dev 2026-05-21 18:32:14 +00:00
2 changed files with 16 additions and 16 deletions

View File

@ -174,7 +174,7 @@ export default function ContractEditor({ onSaved, editingTemplateId, onCancelEdi
type, type,
contract_type: type === 'contract' ? contractType : null, contract_type: type === 'contract' ? contractType : null,
lang, lang,
user_type: type === 'invoice' ? 'both' : userType, user_type: userType,
descriptionLength: description ? description.length : 0, descriptionLength: description ? description.length : 0,
htmlLength: html.length, htmlLength: html.length,
}); });
@ -303,7 +303,6 @@ export default function ContractEditor({ onSaved, editingTemplateId, onCancelEdi
onChange={(e) => { onChange={(e) => {
const newType = e.target.value as 'contract' | 'invoice' | 'other'; const newType = e.target.value as 'contract' | 'invoice' | 'other';
setType(newType); setType(newType);
if (newType === 'invoice') setUserType('both');
}} }}
required 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" 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"
@ -324,18 +323,16 @@ export default function ContractEditor({ onSaved, editingTemplateId, onCancelEdi
<option value="abo">ABO</option> <option value="abo">ABO</option>
</select> </select>
)} )}
{type !== 'invoice' && ( <select
<select value={userType}
value={userType} onChange={(e) => setUserType(e.target.value as 'personal' | 'company' | 'both')}
onChange={(e) => setUserType(e.target.value as 'personal' | 'company' | 'both')} required
required className="w-full sm:w-40 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"
className="w-full sm:w-40 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" >
> <option value="personal">Personal</option>
<option value="personal">Personal</option> <option value="company">Company</option>
<option value="company">Company</option> <option value="both">Both</option>
<option value="both">Both</option> </select>
</select>
)}
<select <select
value={lang} value={lang}
onChange={(e) => setLang(e.target.value as 'en' | 'de')} onChange={(e) => setLang(e.target.value as 'en' | 'de')}

View File

@ -310,7 +310,7 @@ function buildTrack(templates: ContractTemplate[]): TemplateTrack {
if (family === 'invoice') { if (family === 'invoice') {
title = names.length === 1 ? names[0] : 'Invoice Templates'; title = names.length === 1 ? names[0] : 'Invoice Templates';
subtitle = 'All customers'; subtitle = `${formatUserType(lead?.user_type)}${sortedTemplates.length} version${sortedTemplates.length === 1 ? '' : 's'}`;
} }
return { return {
@ -731,6 +731,9 @@ export default function ContractTemplateList({ refreshKey = 0, onEdit }: Props)
{track.family === 'contract' && ( {track.family === 'contract' && (
<Pill className="border-slate-200 bg-white/90 text-slate-700">{formatUserType(track.templates[0]?.user_type)}</Pill> <Pill className="border-slate-200 bg-white/90 text-slate-700">{formatUserType(track.templates[0]?.user_type)}</Pill>
)} )}
{track.family === 'invoice' && track.templates[0]?.user_type && (
<Pill className="border-sky-200 bg-white/90 text-sky-800">{formatUserType(track.templates[0].user_type)}</Pill>
)}
{track.family === 'other' && track.templates[0]?.user_type && ( {track.family === 'other' && track.templates[0]?.user_type && (
<Pill className="border-slate-200 bg-slate-100 text-slate-700">{formatUserType(track.templates[0].user_type)}</Pill> <Pill className="border-slate-200 bg-slate-100 text-slate-700">{formatUserType(track.templates[0].user_type)}</Pill>
)} )}
@ -959,7 +962,7 @@ export default function ContractTemplateList({ refreshKey = 0, onEdit }: Props)
{activeFamily.key === 'invoice' && ( {activeFamily.key === 'invoice' && (
<div className="mt-4 rounded-2xl border border-sky-200 bg-sky-50 px-4 py-3 text-sm text-sky-900"> <div className="mt-4 rounded-2xl border border-sky-200 bg-sky-50 px-4 py-3 text-sm text-sky-900">
Invoice templates always use user type &quot;Both&quot;. Keep one active version per language so the invoice flow stays predictable. Invoice templates can target Personal, Company, or Both. Keep one active version per language and user type so the invoice flow stays predictable.
</div> </div>
)} )}