@@ -0,0 +1,183 @@
|
||||
import { useForm } from '@inertiajs/react';
|
||||
import { Management, Field, button, control } from '../management/shared';
|
||||
import type { Owner } from './types';
|
||||
|
||||
export default function Convert({
|
||||
interest,
|
||||
investors,
|
||||
owners,
|
||||
journeyInvestorId,
|
||||
}: {
|
||||
interest: {
|
||||
id: number;
|
||||
reference: string;
|
||||
full_name: string;
|
||||
sector_interest: string;
|
||||
};
|
||||
investors: { id: string; legal_name: string }[];
|
||||
owners: Owner[];
|
||||
journeyInvestorId?: string | null;
|
||||
}) {
|
||||
const form = useForm({
|
||||
investor_id: journeyInvestorId ?? '',
|
||||
legal_name: '',
|
||||
investor_type: '',
|
||||
owner_user_id: '',
|
||||
title: `${interest.reference} — ${interest.sector_interest}`,
|
||||
next_action: '',
|
||||
due_at: '',
|
||||
});
|
||||
return (
|
||||
<Management title="Converter pedido em lead">
|
||||
{journeyInvestorId && (
|
||||
<p>
|
||||
O investidor da jornada original está seleccionado. A
|
||||
conversão preserva essa identidade.
|
||||
</p>
|
||||
)}
|
||||
<p>
|
||||
{interest.reference} · Contacto: {interest.full_name}
|
||||
</p>
|
||||
<p>
|
||||
Seleccione um investidor existente ou identifique explicitamente
|
||||
o novo investidor. O nome do contacto não é assumido como
|
||||
denominação de uma empresa.
|
||||
</p>
|
||||
<form
|
||||
className="max-w-2xl space-y-4"
|
||||
onSubmit={(e) => {
|
||||
e.preventDefault();
|
||||
form.transform((data) => ({
|
||||
...data,
|
||||
due_at: data.due_at
|
||||
? new Date(data.due_at).toISOString()
|
||||
: '',
|
||||
}));
|
||||
form.post(`/management/crm/convert/${interest.id}`);
|
||||
}}
|
||||
>
|
||||
<fieldset disabled={form.processing} className="space-y-4">
|
||||
<Field
|
||||
label="Investidor existente"
|
||||
error={form.errors.investor_id}
|
||||
>
|
||||
<select
|
||||
className={control}
|
||||
value={form.data.investor_id}
|
||||
onChange={(e) =>
|
||||
form.setData('investor_id', e.target.value)
|
||||
}
|
||||
>
|
||||
<option value="">Criar novo investidor</option>
|
||||
{investors.map((investor) => (
|
||||
<option key={investor.id} value={investor.id}>
|
||||
{investor.legal_name}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</Field>
|
||||
{!form.data.investor_id && (
|
||||
<>
|
||||
<Field
|
||||
label="Nome legal do investidor"
|
||||
error={form.errors.legal_name}
|
||||
>
|
||||
<input
|
||||
className={control}
|
||||
value={form.data.legal_name}
|
||||
onChange={(e) =>
|
||||
form.setData(
|
||||
'legal_name',
|
||||
e.target.value,
|
||||
)
|
||||
}
|
||||
/>
|
||||
</Field>
|
||||
<Field
|
||||
label="Tipo de investidor"
|
||||
error={form.errors.investor_type}
|
||||
>
|
||||
<select
|
||||
className={control}
|
||||
value={form.data.investor_type}
|
||||
onChange={(e) =>
|
||||
form.setData(
|
||||
'investor_type',
|
||||
e.target.value,
|
||||
)
|
||||
}
|
||||
>
|
||||
<option value="">Seleccione</option>
|
||||
<option value="domestic">Nacional</option>
|
||||
<option value="foreign">Estrangeiro</option>
|
||||
<option value="institutional">
|
||||
Institucional
|
||||
</option>
|
||||
<option value="individual">
|
||||
Individual
|
||||
</option>
|
||||
</select>
|
||||
</Field>
|
||||
</>
|
||||
)}
|
||||
<Field
|
||||
label="Responsável"
|
||||
error={form.errors.owner_user_id}
|
||||
>
|
||||
<select
|
||||
className={control}
|
||||
value={form.data.owner_user_id}
|
||||
onChange={(e) =>
|
||||
form.setData('owner_user_id', e.target.value)
|
||||
}
|
||||
>
|
||||
<option value="">Seleccione</option>
|
||||
{owners.map((owner) => (
|
||||
<option key={owner.id} value={owner.id}>
|
||||
{owner.name}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</Field>
|
||||
<Field label="Título do lead" error={form.errors.title}>
|
||||
<input
|
||||
className={control}
|
||||
value={form.data.title}
|
||||
onChange={(e) =>
|
||||
form.setData('title', e.target.value)
|
||||
}
|
||||
/>
|
||||
</Field>
|
||||
<Field
|
||||
label="Próxima acção"
|
||||
error={form.errors.next_action}
|
||||
>
|
||||
<input
|
||||
className={control}
|
||||
value={form.data.next_action}
|
||||
onChange={(e) =>
|
||||
form.setData('next_action', e.target.value)
|
||||
}
|
||||
/>
|
||||
</Field>
|
||||
<Field
|
||||
label="Prazo (hora local)"
|
||||
error={form.errors.due_at}
|
||||
>
|
||||
<input
|
||||
type="datetime-local"
|
||||
className={control}
|
||||
value={form.data.due_at}
|
||||
onChange={(e) =>
|
||||
form.setData('due_at', e.target.value)
|
||||
}
|
||||
/>
|
||||
</Field>
|
||||
<button className={button} disabled={form.processing}>
|
||||
{form.processing ? 'A converter…' : 'Converter em lead'}
|
||||
</button>
|
||||
</fieldset>
|
||||
</form>
|
||||
</Management>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,172 @@
|
||||
import { Link, useForm } from '@inertiajs/react';
|
||||
import { Management, Field, control, button } from '../management/shared';
|
||||
import { leadStates } from './types';
|
||||
|
||||
type Contact = {
|
||||
id: string;
|
||||
full_name: string;
|
||||
email: string | null;
|
||||
phone: string | null;
|
||||
};
|
||||
function ContactForm({
|
||||
contact,
|
||||
investorId,
|
||||
}: {
|
||||
contact: Contact;
|
||||
investorId: string;
|
||||
}) {
|
||||
const form = useForm({
|
||||
full_name: contact.full_name,
|
||||
email: contact.email ?? '',
|
||||
phone: contact.phone ?? '',
|
||||
});
|
||||
return (
|
||||
<form
|
||||
className="space-y-3 rounded border p-4"
|
||||
onSubmit={(e) => {
|
||||
e.preventDefault();
|
||||
form.patch(
|
||||
`/management/crm/investors/${investorId}/contacts/${contact.id}`,
|
||||
);
|
||||
}}
|
||||
>
|
||||
<Field label="Nome do contacto" error={form.errors.full_name}>
|
||||
<input
|
||||
className={control}
|
||||
value={form.data.full_name}
|
||||
onChange={(e) => form.setData('full_name', e.target.value)}
|
||||
/>
|
||||
</Field>
|
||||
<Field label="Email" error={form.errors.email}>
|
||||
<input
|
||||
className={control}
|
||||
type="email"
|
||||
value={form.data.email}
|
||||
onChange={(e) => form.setData('email', e.target.value)}
|
||||
/>
|
||||
</Field>
|
||||
<Field label="Telefone" error={form.errors.phone}>
|
||||
<input
|
||||
className={control}
|
||||
value={form.data.phone}
|
||||
onChange={(e) => form.setData('phone', e.target.value)}
|
||||
/>
|
||||
</Field>
|
||||
<button className={button} disabled={form.processing}>
|
||||
Guardar contacto
|
||||
</button>
|
||||
</form>
|
||||
);
|
||||
}
|
||||
export default function InvestorDetail({
|
||||
investor,
|
||||
contacts,
|
||||
leads,
|
||||
}: {
|
||||
investor: {
|
||||
id: string;
|
||||
legal_name: string;
|
||||
investor_type: string;
|
||||
status: string;
|
||||
};
|
||||
contacts: Contact[];
|
||||
leads: { id: string; title: string; status: string }[];
|
||||
}) {
|
||||
const form = useForm({
|
||||
legal_name: investor.legal_name,
|
||||
investor_type: investor.investor_type,
|
||||
status: investor.status,
|
||||
});
|
||||
return (
|
||||
<Management title={investor.legal_name}>
|
||||
<form
|
||||
className="max-w-xl space-y-4"
|
||||
onSubmit={(e) => {
|
||||
e.preventDefault();
|
||||
form.patch(`/management/crm/investors/${investor.id}`);
|
||||
}}
|
||||
>
|
||||
<Field label="Nome legal" error={form.errors.legal_name}>
|
||||
<input
|
||||
className={control}
|
||||
value={form.data.legal_name}
|
||||
onChange={(e) =>
|
||||
form.setData('legal_name', e.target.value)
|
||||
}
|
||||
/>
|
||||
</Field>
|
||||
<Field
|
||||
label="Tipo de investidor"
|
||||
error={form.errors.investor_type}
|
||||
>
|
||||
<select
|
||||
className={control}
|
||||
value={form.data.investor_type}
|
||||
onChange={(e) =>
|
||||
form.setData('investor_type', e.target.value)
|
||||
}
|
||||
>
|
||||
{Object.entries({
|
||||
domestic: 'Nacional',
|
||||
foreign: 'Estrangeiro',
|
||||
institutional: 'Institucional',
|
||||
individual: 'Individual',
|
||||
}).map(([key, label]) => (
|
||||
<option key={key} value={key}>
|
||||
{label}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</Field>
|
||||
<Field label="Estado" error={form.errors.status}>
|
||||
<select
|
||||
className={control}
|
||||
value={form.data.status}
|
||||
onChange={(e) => form.setData('status', e.target.value)}
|
||||
>
|
||||
{Object.entries({
|
||||
prospect: 'Potencial investidor',
|
||||
active: 'Activo',
|
||||
inactive: 'Inactivo',
|
||||
}).map(([key, label]) => (
|
||||
<option key={key} value={key}>
|
||||
{label}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</Field>
|
||||
<button className={button} disabled={form.processing}>
|
||||
Guardar investidor
|
||||
</button>
|
||||
</form>
|
||||
<section className="max-w-xl space-y-4">
|
||||
<h2 className="text-lg font-semibold">Contactos</h2>
|
||||
<p>
|
||||
Um contacto pode representar vários investidores. Alterações
|
||||
ao contacto são partilhadas entre essas relações.
|
||||
</p>
|
||||
{contacts.map((contact) => (
|
||||
<ContactForm
|
||||
key={contact.id}
|
||||
contact={contact}
|
||||
investorId={investor.id}
|
||||
/>
|
||||
))}
|
||||
</section>
|
||||
<section className="space-y-3">
|
||||
<h2 className="text-lg font-semibold">Leads associados</h2>
|
||||
{leads.map((lead) => (
|
||||
<p key={lead.id}>
|
||||
<Link
|
||||
className="underline"
|
||||
href={`/management/crm/leads/${lead.id}`}
|
||||
>
|
||||
{lead.title}
|
||||
</Link>{' '}
|
||||
· {leadStates[lead.status]}
|
||||
</p>
|
||||
))}
|
||||
</section>
|
||||
</Management>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
import { Link, useForm } from '@inertiajs/react';
|
||||
import { Management, Pagination, control, button } from '../management/shared';
|
||||
import type { Paginated } from '../management/shared';
|
||||
|
||||
export default function Investors({
|
||||
investors,
|
||||
filters,
|
||||
}: {
|
||||
investors: Paginated<{ id: string; legal_name: string; status: string }>;
|
||||
filters: { q?: string };
|
||||
}) {
|
||||
const form = useForm({ q: filters.q ?? '' });
|
||||
return (
|
||||
<Management title="CRM — Investidores">
|
||||
<form
|
||||
className="flex gap-3"
|
||||
onSubmit={(e) => {
|
||||
e.preventDefault();
|
||||
form.get('/management/crm/investors', {
|
||||
preserveState: false,
|
||||
});
|
||||
}}
|
||||
>
|
||||
<input
|
||||
aria-label="Pesquisar investidores"
|
||||
className={control}
|
||||
value={form.data.q}
|
||||
onChange={(e) => form.setData('q', e.target.value)}
|
||||
/>
|
||||
<button className={button} disabled={form.processing}>
|
||||
Pesquisar
|
||||
</button>
|
||||
</form>
|
||||
<p>
|
||||
Os novos investidores são registados ao converter um pedido em
|
||||
lead, com revisão do contacto e da identidade.
|
||||
</p>
|
||||
<div className="space-y-3">
|
||||
{investors.data.map((investor) => (
|
||||
<article key={investor.id} className="rounded border p-4">
|
||||
<Link
|
||||
className="font-semibold underline"
|
||||
href={`/management/crm/investors/${investor.id}`}
|
||||
>
|
||||
{investor.legal_name}
|
||||
</Link>
|
||||
<p>
|
||||
{{
|
||||
prospect: 'Potencial investidor',
|
||||
active: 'Activo',
|
||||
inactive: 'Inactivo',
|
||||
}[investor.status] ?? investor.status}
|
||||
</p>
|
||||
</article>
|
||||
))}
|
||||
</div>
|
||||
{!investors.data.length && <p>Nenhum investidor encontrado.</p>}
|
||||
<Pagination page={investors} />
|
||||
</Management>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,246 @@
|
||||
import { Link, useForm } from '@inertiajs/react';
|
||||
import { Management, Field, button, control } from '../management/shared';
|
||||
import { leadStates, taskStates } from './types';
|
||||
import type { Lead, Owner, Task } from './types';
|
||||
|
||||
function TaskRow({ task, leadId }: { task: Task; leadId: string }) {
|
||||
const form = useForm({ status: task.status });
|
||||
return (
|
||||
<form
|
||||
className="space-y-3 rounded border p-4"
|
||||
onSubmit={(e) => {
|
||||
e.preventDefault();
|
||||
form.patch(`/management/crm/leads/${leadId}/tasks/${task.id}`);
|
||||
}}
|
||||
>
|
||||
<h3 className="font-semibold">{task.title}</h3>
|
||||
<p>
|
||||
{task.due_at
|
||||
? new Intl.DateTimeFormat('pt-MZ', {
|
||||
dateStyle: 'medium',
|
||||
timeStyle: 'short',
|
||||
timeZone: 'Africa/Maputo',
|
||||
}).format(new Date(task.due_at)) + ' (Maputo)'
|
||||
: 'Sem prazo'}{' '}
|
||||
· Responsável #{task.assignee_user_id}
|
||||
</p>
|
||||
<Field
|
||||
label={`Estado da tarefa: ${task.title}`}
|
||||
error={form.errors.status}
|
||||
>
|
||||
<select
|
||||
className={control}
|
||||
value={form.data.status}
|
||||
onChange={(e) => form.setData('status', e.target.value)}
|
||||
>
|
||||
{Object.entries(taskStates).map(([key, label]) => (
|
||||
<option key={key} value={key}>
|
||||
{label}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</Field>
|
||||
<button className={button} disabled={form.processing}>
|
||||
Actualizar tarefa
|
||||
</button>
|
||||
</form>
|
||||
);
|
||||
}
|
||||
export default function LeadDetail({
|
||||
lead,
|
||||
contacts,
|
||||
owners,
|
||||
}: {
|
||||
lead: Lead;
|
||||
contacts: {
|
||||
id: string;
|
||||
full_name: string;
|
||||
email: string | null;
|
||||
phone: string | null;
|
||||
}[];
|
||||
owners: Owner[];
|
||||
}) {
|
||||
const review = useForm({
|
||||
status: lead.status,
|
||||
owner_user_id: String(lead.owner_user_id ?? ''),
|
||||
qualification_reason: '',
|
||||
});
|
||||
const task = useForm({
|
||||
title: '',
|
||||
due_at: '',
|
||||
assignee_user_id: String(lead.owner_user_id ?? ''),
|
||||
});
|
||||
return (
|
||||
<Management title={lead.title}>
|
||||
<Link className="underline" href="/management/crm/leads">
|
||||
Voltar aos leads
|
||||
</Link>
|
||||
<section className="space-y-2">
|
||||
<h2 className="text-xl font-semibold">
|
||||
{lead.investor && (
|
||||
<Link
|
||||
className="underline"
|
||||
href={`/management/crm/investors/${lead.investor.id}`}
|
||||
>
|
||||
{lead.investor.legal_name}
|
||||
</Link>
|
||||
)}
|
||||
</h2>
|
||||
<p>
|
||||
{leadStates[lead.status]} ·{' '}
|
||||
{lead.owner?.name ?? 'Sem responsável'}
|
||||
</p>
|
||||
<p>Origem inicial: {lead.first_source ?? 'Não registada'}</p>
|
||||
{lead.interest_request_id && (
|
||||
<Link
|
||||
className="underline"
|
||||
href={`/management/interests/${lead.interest_request_id}`}
|
||||
>
|
||||
Consultar pedido de origem
|
||||
</Link>
|
||||
)}
|
||||
<div className="space-y-2">
|
||||
{contacts.map((contact) => (
|
||||
<p key={contact.id}>
|
||||
{contact.full_name} · {contact.email ?? '—'} ·{' '}
|
||||
{contact.phone ?? '—'}
|
||||
</p>
|
||||
))}
|
||||
</div>
|
||||
</section>
|
||||
<form
|
||||
className="max-w-xl space-y-4"
|
||||
onSubmit={(e) => {
|
||||
e.preventDefault();
|
||||
review.patch(`/management/crm/leads/${lead.id}`);
|
||||
}}
|
||||
>
|
||||
<h2 className="text-lg font-semibold">
|
||||
Qualificação e atribuição
|
||||
</h2>
|
||||
<Field label="Estado do lead" error={review.errors.status}>
|
||||
<select
|
||||
className={control}
|
||||
value={review.data.status}
|
||||
onChange={(e) =>
|
||||
review.setData('status', e.target.value)
|
||||
}
|
||||
>
|
||||
{Object.entries(leadStates)
|
||||
.filter(([key]) => key !== 'converted')
|
||||
.map(([key, label]) => (
|
||||
<option key={key} value={key}>
|
||||
{label}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</Field>
|
||||
<Field label="Responsável" error={review.errors.owner_user_id}>
|
||||
<select
|
||||
className={control}
|
||||
value={review.data.owner_user_id}
|
||||
onChange={(e) =>
|
||||
review.setData('owner_user_id', e.target.value)
|
||||
}
|
||||
>
|
||||
<option value="">Seleccione</option>
|
||||
{owners.map((owner) => (
|
||||
<option key={owner.id} value={owner.id}>
|
||||
{owner.name}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</Field>
|
||||
<Field
|
||||
label="Fundamento da alteração"
|
||||
error={review.errors.qualification_reason}
|
||||
>
|
||||
<textarea
|
||||
className={control}
|
||||
value={review.data.qualification_reason}
|
||||
onChange={(e) =>
|
||||
review.setData(
|
||||
'qualification_reason',
|
||||
e.target.value,
|
||||
)
|
||||
}
|
||||
/>
|
||||
</Field>
|
||||
{lead.qualification_reason && (
|
||||
<p className="text-sm whitespace-pre-wrap">
|
||||
Último fundamento: {lead.qualification_reason}
|
||||
</p>
|
||||
)}
|
||||
<button
|
||||
className={button}
|
||||
disabled={review.processing || lead.status === 'converted'}
|
||||
>
|
||||
Guardar lead
|
||||
</button>
|
||||
</form>
|
||||
<section className="space-y-4">
|
||||
<h2 className="text-lg font-semibold">Tarefas</h2>
|
||||
{lead.tasks.map((item) => (
|
||||
<TaskRow key={item.id} task={item} leadId={lead.id} />
|
||||
))}
|
||||
{!lead.tasks.length && <p>Não existem tarefas.</p>}
|
||||
</section>
|
||||
<form
|
||||
className="max-w-xl space-y-4"
|
||||
onSubmit={(e) => {
|
||||
e.preventDefault();
|
||||
task.transform((data) => ({
|
||||
...data,
|
||||
due_at: data.due_at
|
||||
? new Date(data.due_at).toISOString()
|
||||
: '',
|
||||
}));
|
||||
task.post(`/management/crm/leads/${lead.id}/tasks`, {
|
||||
onSuccess: () => task.reset('title', 'due_at'),
|
||||
});
|
||||
}}
|
||||
>
|
||||
<h2 className="text-lg font-semibold">
|
||||
Registar próxima acção
|
||||
</h2>
|
||||
<Field label="Tarefa" error={task.errors.title}>
|
||||
<input
|
||||
className={control}
|
||||
value={task.data.title}
|
||||
onChange={(e) => task.setData('title', e.target.value)}
|
||||
/>
|
||||
</Field>
|
||||
<Field label="Prazo (hora local)" error={task.errors.due_at}>
|
||||
<input
|
||||
type="datetime-local"
|
||||
className={control}
|
||||
value={task.data.due_at}
|
||||
onChange={(e) => task.setData('due_at', e.target.value)}
|
||||
/>
|
||||
</Field>
|
||||
<Field
|
||||
label="Responsável pela tarefa"
|
||||
error={task.errors.assignee_user_id}
|
||||
>
|
||||
<select
|
||||
className={control}
|
||||
value={task.data.assignee_user_id}
|
||||
onChange={(e) =>
|
||||
task.setData('assignee_user_id', e.target.value)
|
||||
}
|
||||
>
|
||||
<option value="">Seleccione</option>
|
||||
{owners.map((owner) => (
|
||||
<option key={owner.id} value={owner.id}>
|
||||
{owner.name}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</Field>
|
||||
<button className={button} disabled={task.processing}>
|
||||
Criar tarefa
|
||||
</button>
|
||||
</form>
|
||||
</Management>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
import { Link, useForm } from '@inertiajs/react';
|
||||
import { Management, Pagination, button, control } from '../management/shared';
|
||||
import type { Paginated } from '../management/shared';
|
||||
import { leadStates } from './types';
|
||||
import type { Lead, Owner } from './types';
|
||||
|
||||
export default function Leads({
|
||||
leads,
|
||||
filters,
|
||||
owners,
|
||||
}: {
|
||||
leads: Paginated<Lead>;
|
||||
filters: { q?: string; status?: string; owner_user_id?: number };
|
||||
owners: Owner[];
|
||||
}) {
|
||||
const form = useForm({
|
||||
q: filters.q ?? '',
|
||||
status: filters.status ?? '',
|
||||
owner_user_id: String(filters.owner_user_id ?? ''),
|
||||
});
|
||||
return (
|
||||
<Management title="CRM — Leads">
|
||||
<p>
|
||||
Encaminhe uma manifestação de interesse para iniciar o
|
||||
acompanhamento comercial.
|
||||
</p>
|
||||
<Link className="underline" href="/management/interests">
|
||||
Consultar pedidos recebidos
|
||||
</Link>
|
||||
<form
|
||||
className="flex flex-wrap gap-3"
|
||||
onSubmit={(e) => {
|
||||
e.preventDefault();
|
||||
form.get('/management/crm/leads', { preserveState: false });
|
||||
}}
|
||||
>
|
||||
<input
|
||||
aria-label="Pesquisar leads"
|
||||
placeholder="Título ou investidor"
|
||||
className={`${control} max-w-sm`}
|
||||
value={form.data.q}
|
||||
onChange={(e) => form.setData('q', e.target.value)}
|
||||
/>
|
||||
<select
|
||||
aria-label="Estado"
|
||||
className={`${control} max-w-xs`}
|
||||
value={form.data.status}
|
||||
onChange={(e) => form.setData('status', e.target.value)}
|
||||
>
|
||||
<option value="">Todos os estados</option>
|
||||
{Object.entries(leadStates).map(([key, label]) => (
|
||||
<option key={key} value={key}>
|
||||
{label}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
<select
|
||||
aria-label="Responsável"
|
||||
className={`${control} max-w-xs`}
|
||||
value={form.data.owner_user_id}
|
||||
onChange={(e) =>
|
||||
form.setData('owner_user_id', e.target.value)
|
||||
}
|
||||
>
|
||||
<option value="">Todos os responsáveis</option>
|
||||
{owners.map((owner) => (
|
||||
<option key={owner.id} value={owner.id}>
|
||||
{owner.name}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
<button className={button} disabled={form.processing}>
|
||||
Pesquisar
|
||||
</button>
|
||||
</form>
|
||||
<div className="space-y-3">
|
||||
{leads.data.map((lead) => (
|
||||
<article
|
||||
key={lead.id}
|
||||
className="space-y-2 rounded border p-4"
|
||||
>
|
||||
<Link
|
||||
className="font-semibold underline"
|
||||
href={`/management/crm/leads/${lead.id}`}
|
||||
>
|
||||
{lead.title}
|
||||
</Link>
|
||||
<p>
|
||||
{lead.investor?.legal_name ?? 'Sem investidor'} ·{' '}
|
||||
{leadStates[lead.status]}
|
||||
</p>
|
||||
<p className="text-sm">
|
||||
Responsável: {lead.owner?.name ?? 'Por atribuir'}
|
||||
{Boolean(lead.overdue_tasks_count) && (
|
||||
<span className="ml-3 text-red-600">
|
||||
{lead.overdue_tasks_count} tarefa(s) em
|
||||
atraso
|
||||
</span>
|
||||
)}
|
||||
</p>
|
||||
</article>
|
||||
))}
|
||||
</div>
|
||||
{!leads.data.length && <p>Nenhum lead encontrado.</p>}
|
||||
<Pagination page={leads} />
|
||||
</Management>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
export type Owner = { id: number; name: string };
|
||||
export type Task = {
|
||||
id: string;
|
||||
title: string;
|
||||
status: string;
|
||||
due_at: string | null;
|
||||
assignee_user_id: number | null;
|
||||
};
|
||||
export type Lead = {
|
||||
id: string;
|
||||
title: string;
|
||||
status: string;
|
||||
owner_user_id: number | null;
|
||||
investor: { id: string; legal_name: string } | null;
|
||||
owner: Owner | null;
|
||||
tasks: Task[];
|
||||
overdue_tasks_count?: number;
|
||||
first_source: string | null;
|
||||
last_source: string | null;
|
||||
qualification_reason: string | null;
|
||||
interest_request_id: number | null;
|
||||
};
|
||||
export const leadStates: Record<string, string> = {
|
||||
new: 'Novo',
|
||||
qualified: 'Qualificado',
|
||||
disqualified: 'Desqualificado',
|
||||
converted: 'Convertido',
|
||||
};
|
||||
export const taskStates: Record<string, string> = {
|
||||
open: 'Aberta',
|
||||
in_progress: 'Em curso',
|
||||
done: 'Concluída',
|
||||
cancelled: 'Cancelada',
|
||||
};
|
||||
Reference in New Issue
Block a user