|
|
@@ -91,6 +91,7 @@
|
|
|
const emptyForm = () => ({
|
|
|
name: '',
|
|
|
email: '',
|
|
|
+ password: '',
|
|
|
department: 'SAC',
|
|
|
channels: [],
|
|
|
status: 'Ativo',
|
|
|
@@ -110,6 +111,7 @@
|
|
|
form = {
|
|
|
name: agent.name,
|
|
|
email: agent.email ?? '',
|
|
|
+ password: '',
|
|
|
department: agent.department,
|
|
|
channels: [...agent.channels],
|
|
|
status: agent.status,
|
|
|
@@ -133,6 +135,10 @@
|
|
|
saveError = 'Nome e e-mail são obrigatórios.';
|
|
|
return;
|
|
|
}
|
|
|
+ if (editingId === null && form.password.trim().length < 8) {
|
|
|
+ saveError = 'A senha é obrigatória e deve ter pelo menos 8 caracteres.';
|
|
|
+ return;
|
|
|
+ }
|
|
|
saving = true;
|
|
|
saveError = '';
|
|
|
try {
|
|
|
@@ -144,6 +150,7 @@
|
|
|
status: form.status,
|
|
|
availableForEscalation: form.availableForEscalation
|
|
|
};
|
|
|
+ if (form.password.trim()) body.password = form.password.trim();
|
|
|
if (editingId !== null) body.id = editingId;
|
|
|
await api.post('/v1/agents', { body });
|
|
|
showModal = false;
|
|
|
@@ -302,6 +309,27 @@
|
|
|
/>
|
|
|
</div>
|
|
|
|
|
|
+ <div>
|
|
|
+ <label
|
|
|
+ for="op-password"
|
|
|
+ class="mb-1.5 block text-xs font-semibold uppercase tracking-wide text-slate-500 dark:text-slate-400"
|
|
|
+ >
|
|
|
+ {editingId !== null ? 'Nova senha' : 'Senha'}
|
|
|
+ </label>
|
|
|
+ <input
|
|
|
+ id="op-password"
|
|
|
+ type="password"
|
|
|
+ bind:value={form.password}
|
|
|
+ placeholder={editingId !== null ? 'Deixe em branco para manter a atual' : 'Mínimo de 8 caracteres'}
|
|
|
+ class="w-full rounded-lg border border-slate-300 bg-slate-50 px-3 py-2 text-sm text-slate-900 placeholder-slate-400 transition-colors focus:border-indigo-500 focus:bg-white focus:ring-1 focus:ring-indigo-500 focus:outline-none dark:border-slate-700 dark:bg-slate-900 dark:text-slate-200 dark:placeholder-slate-500 dark:focus:bg-slate-900"
|
|
|
+ />
|
|
|
+ <p class="mt-1 text-xs text-slate-500 dark:text-slate-400">
|
|
|
+ {editingId !== null
|
|
|
+ ? 'Preencha apenas se quiser trocar a senha do agente.'
|
|
|
+ : 'Campo obrigatório para criar o agente.'}
|
|
|
+ </p>
|
|
|
+ </div>
|
|
|
+
|
|
|
<!-- Departamento -->
|
|
|
<div>
|
|
|
<label
|
|
|
@@ -401,7 +429,7 @@
|
|
|
</button>
|
|
|
<button
|
|
|
onclick={saveAgent}
|
|
|
- disabled={!form.name.trim() || saving}
|
|
|
+ disabled={!form.name.trim() || (editingId === null && form.password.trim().length < 8) || saving}
|
|
|
class="rounded-lg bg-indigo-600 px-4 py-2 text-sm font-semibold text-white transition-colors hover:bg-indigo-700 disabled:cursor-not-allowed disabled:opacity-50 dark:bg-indigo-500 dark:hover:bg-indigo-600"
|
|
|
>
|
|
|
{saving ? 'Salvando…' : 'Salvar'}
|