@@ -0,0 +1,140 @@
|
||||
import { Link, useForm } from '@inertiajs/react';
|
||||
import { Management, Pagination, button, control, states } from './shared';
|
||||
import type { Paginated } from './shared';
|
||||
|
||||
type Record = {
|
||||
id: number;
|
||||
name?: string;
|
||||
title?: string;
|
||||
reference?: string;
|
||||
slug: string;
|
||||
is_active?: boolean;
|
||||
status?: string;
|
||||
};
|
||||
export default function Catalog({
|
||||
resource,
|
||||
records,
|
||||
filters,
|
||||
sectors,
|
||||
}: {
|
||||
resource: 'sectors' | 'opportunities';
|
||||
records: Paginated<Record>;
|
||||
filters: { q?: string; status?: string; sector_id?: number | string };
|
||||
sectors: { id: number; name: string }[];
|
||||
}) {
|
||||
const form = useForm({
|
||||
q: filters.q ?? '',
|
||||
status: filters.status ?? '',
|
||||
sector_id: String(filters.sector_id ?? ''),
|
||||
});
|
||||
return (
|
||||
<Management
|
||||
title={resource === 'sectors' ? 'Sectores' : 'Oportunidades'}
|
||||
>
|
||||
<Link className={button} href={`/management/${resource}/create`}>
|
||||
Criar {resource === 'sectors' ? 'sector' : 'oportunidade'}
|
||||
</Link>
|
||||
<form
|
||||
className="flex flex-wrap gap-3"
|
||||
onSubmit={(event) => {
|
||||
event.preventDefault();
|
||||
form.get(`/management/${resource}`, {
|
||||
preserveState: false,
|
||||
});
|
||||
}}
|
||||
>
|
||||
<input
|
||||
aria-label="Pesquisar catálogo"
|
||||
placeholder="Nome, título, referência ou slug"
|
||||
className={`${control} max-w-sm`}
|
||||
value={form.data.q}
|
||||
onChange={(event) => form.setData('q', event.target.value)}
|
||||
maxLength={150}
|
||||
/>
|
||||
<select
|
||||
aria-label="Estado"
|
||||
className={`${control} max-w-xs`}
|
||||
value={form.data.status}
|
||||
onChange={(event) =>
|
||||
form.setData('status', event.target.value)
|
||||
}
|
||||
>
|
||||
<option value="">Todos os estados</option>
|
||||
{(resource === 'sectors'
|
||||
? ['active', 'inactive']
|
||||
: ['draft', 'published', 'archived']
|
||||
).map((status) => (
|
||||
<option key={status} value={status}>
|
||||
{status === 'active'
|
||||
? 'Activo'
|
||||
: status === 'inactive'
|
||||
? 'Inactivo'
|
||||
: states[status]}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
{resource === 'opportunities' && (
|
||||
<select
|
||||
aria-label="Sector"
|
||||
className={`${control} max-w-xs`}
|
||||
value={form.data.sector_id}
|
||||
onChange={(event) =>
|
||||
form.setData('sector_id', event.target.value)
|
||||
}
|
||||
>
|
||||
<option value="">Todos os sectores</option>
|
||||
{sectors.map((sector) => (
|
||||
<option key={sector.id} value={sector.id}>
|
||||
{sector.name}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
)}
|
||||
<button className={button} disabled={form.processing}>
|
||||
Pesquisar
|
||||
</button>
|
||||
<Link
|
||||
className="p-2 underline"
|
||||
href={`/management/${resource}`}
|
||||
>
|
||||
Limpar filtros
|
||||
</Link>
|
||||
{Object.values(form.errors).map((error) => (
|
||||
<p key={error} role="alert" className="w-full text-red-600">
|
||||
{error}
|
||||
</p>
|
||||
))}
|
||||
</form>
|
||||
<div className="space-y-3">
|
||||
{records.data.map((record) => (
|
||||
<article
|
||||
key={record.id}
|
||||
className="flex flex-wrap items-center justify-between gap-3 rounded border p-4"
|
||||
>
|
||||
<div>
|
||||
<h2 className="font-semibold">
|
||||
{record.name ?? record.title}
|
||||
</h2>
|
||||
<p className="text-muted-foreground text-sm">
|
||||
{record.reference ?? record.slug} ·{' '}
|
||||
{resource === 'sectors'
|
||||
? record.is_active
|
||||
? 'Activo'
|
||||
: 'Inactivo'
|
||||
: states[record.status ?? 'draft']}
|
||||
</p>
|
||||
</div>
|
||||
<Link
|
||||
className="underline"
|
||||
href={`/management/${resource}/${record.id}/edit`}
|
||||
>
|
||||
Editar
|
||||
</Link>
|
||||
</article>
|
||||
))}
|
||||
</div>
|
||||
{!records.data.length && <p>Nenhum registo encontrado.</p>}
|
||||
<Pagination page={records} />
|
||||
</Management>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,182 @@
|
||||
import { Link, useForm } from "@inertiajs/react";
|
||||
import { Management, Field, button, control, states } from "./shared";
|
||||
|
||||
type Values = Record<string, string | boolean>;
|
||||
type Entry = Record<string, string | number | boolean | null> & { id: number };
|
||||
const opportunityFields = {
|
||||
reference: "Referência",
|
||||
title: "Título",
|
||||
slug: "Slug (endereço)",
|
||||
summary: "Resumo",
|
||||
description: "Descrição",
|
||||
province: "Província",
|
||||
district: "Distrito",
|
||||
promoter_name: "Promotor",
|
||||
promoter_type: "Tipo de promotor",
|
||||
estimated_investment_amount: "Investimento estimado",
|
||||
estimated_investment_currency: "Moeda (código de três letras)",
|
||||
financing_modality: "Modalidade de financiamento",
|
||||
expected_impact: "Impacto esperado",
|
||||
};
|
||||
const sectorFields = {
|
||||
name: "Nome",
|
||||
slug: "Slug (endereço)",
|
||||
short_description: "Descrição curta",
|
||||
description: "Descrição",
|
||||
sort_order: "Ordem de apresentação",
|
||||
};
|
||||
const maturities = [
|
||||
"Ideia identificada",
|
||||
"Pré-estudo disponível",
|
||||
"Estudo de viabilidade em curso",
|
||||
"Projecto estruturado",
|
||||
"Pronto para investimento",
|
||||
"Em negociação ou implementação",
|
||||
];
|
||||
|
||||
export default function Editor({
|
||||
resource,
|
||||
record,
|
||||
sectors,
|
||||
}: {
|
||||
resource: "sectors" | "opportunities";
|
||||
record: Entry | null;
|
||||
sectors: { id: number; name: string }[];
|
||||
}) {
|
||||
const isSector = resource === "sectors";
|
||||
const fields = isSector ? sectorFields : opportunityFields;
|
||||
const initial: Values = Object.fromEntries(
|
||||
Object.keys(fields).map((key) => [
|
||||
key,
|
||||
String(
|
||||
record?.[key] ??
|
||||
(key === "estimated_investment_currency"
|
||||
? "USD"
|
||||
: key === "sort_order"
|
||||
? "0"
|
||||
: ""),
|
||||
),
|
||||
]),
|
||||
);
|
||||
if (isSector) initial.is_active = Boolean(record?.is_active ?? true);
|
||||
else {
|
||||
initial.sector_id = String(record?.sector_id ?? "");
|
||||
initial.maturity_level = String(record?.maturity_level ?? "");
|
||||
initial.status = String(record?.status ?? "draft");
|
||||
initial.is_featured = Boolean(record?.is_featured ?? false);
|
||||
}
|
||||
const form = useForm<Values>(initial);
|
||||
return (
|
||||
<Management
|
||||
title={`${record ? "Editar" : "Criar"} ${isSector ? "sector" : "oportunidade"}`}
|
||||
>
|
||||
{!isSector && record && (
|
||||
<Link className="underline" href={`/management/opportunities/${record.id}/context`}>
|
||||
Gerir clusters, corredores, projectos, educação e necessidades
|
||||
</Link>
|
||||
)}
|
||||
<form
|
||||
className="max-w-3xl space-y-5"
|
||||
onSubmit={(event) => {
|
||||
event.preventDefault();
|
||||
if (record) form.put(`/management/${resource}/${record.id}`);
|
||||
else form.post(`/management/${resource}`);
|
||||
}}
|
||||
>
|
||||
<fieldset disabled={form.processing} className="space-y-5">
|
||||
{Object.entries(fields).map(([key, label]) => (
|
||||
<Field key={key} label={label} error={form.errors[key]}>
|
||||
{[
|
||||
"description",
|
||||
"summary",
|
||||
"short_description",
|
||||
"expected_impact",
|
||||
].includes(key) ? (
|
||||
<textarea
|
||||
className={control}
|
||||
rows={key === "description" ? 6 : 3}
|
||||
value={String(form.data[key])}
|
||||
onChange={(e) => form.setData(key, e.target.value)}
|
||||
/>
|
||||
) : (
|
||||
<input
|
||||
className={control}
|
||||
value={String(form.data[key])}
|
||||
onChange={(e) => form.setData(key, e.target.value)}
|
||||
/>
|
||||
)}
|
||||
</Field>
|
||||
))}
|
||||
{!isSector && (
|
||||
<>
|
||||
<Field label="Sector" error={form.errors.sector_id}>
|
||||
<select
|
||||
className={control}
|
||||
value={String(form.data.sector_id)}
|
||||
onChange={(e) => form.setData("sector_id", e.target.value)}
|
||||
>
|
||||
<option value="">Seleccione</option>
|
||||
{sectors.map((sector) => (
|
||||
<option key={sector.id} value={sector.id}>
|
||||
{sector.name}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</Field>
|
||||
<Field label="Maturidade" error={form.errors.maturity_level}>
|
||||
<select
|
||||
className={control}
|
||||
value={String(form.data.maturity_level)}
|
||||
onChange={(e) => form.setData("maturity_level", e.target.value)}
|
||||
>
|
||||
<option value="">Por indicar</option>
|
||||
{maturities.map((label, index) => (
|
||||
<option key={label} value={index + 1}>
|
||||
{label}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</Field>
|
||||
<Field label="Estado" error={form.errors.status}>
|
||||
<select
|
||||
className={control}
|
||||
value={String(form.data.status)}
|
||||
onChange={(e) => form.setData("status", e.target.value)}
|
||||
>
|
||||
{["draft", "published", "archived"].map((key) => (
|
||||
<option key={key} value={key}>
|
||||
{states[key]}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</Field>
|
||||
</>
|
||||
)}
|
||||
<Field
|
||||
label={isSector ? "Activo" : "Em destaque"}
|
||||
error={form.errors[isSector ? "is_active" : "is_featured"]}
|
||||
>
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={Boolean(form.data[isSector ? "is_active" : "is_featured"])}
|
||||
onChange={(e) =>
|
||||
form.setData(
|
||||
isSector ? "is_active" : "is_featured",
|
||||
e.target.checked,
|
||||
)
|
||||
}
|
||||
/>
|
||||
</Field>
|
||||
<div className="flex gap-4">
|
||||
<button className={button} disabled={form.processing}>
|
||||
{form.processing ? "A guardar…" : "Guardar"}
|
||||
</button>
|
||||
<Link className="p-2 underline" href={`/management/${resource}`}>
|
||||
Cancelar
|
||||
</Link>
|
||||
</div>
|
||||
</fieldset>
|
||||
</form>
|
||||
</Management>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,135 @@
|
||||
import { Management, Pagination } from './shared';
|
||||
import type { Paginated } from './shared';
|
||||
|
||||
type Event = {
|
||||
id: string;
|
||||
entity_type: string;
|
||||
action: string;
|
||||
occurred_at: string;
|
||||
actor: string | null;
|
||||
before_data: { values: Record<string, unknown> };
|
||||
after_data: {
|
||||
record_id: number | string;
|
||||
changed_fields: string[];
|
||||
values: Record<string, unknown>;
|
||||
};
|
||||
};
|
||||
const entities: Record<string, string> = {
|
||||
investment_accounts: 'Perfil de investimento',
|
||||
investment_company_declarations: 'Declaração de empresa',
|
||||
investment_submissions: 'Manifestação de interesse',
|
||||
investment_messages: 'Mensagem de acompanhamento',
|
||||
investment_reference_options: 'Opção de formulário',
|
||||
opportunity_context: 'Contexto da oportunidade',
|
||||
sectors: 'Sector',
|
||||
opportunities: 'Oportunidade',
|
||||
interest_requests: 'Pedido',
|
||||
investors: 'Investidor',
|
||||
contacts: 'Contacto',
|
||||
leads: 'Lead',
|
||||
tasks: 'Tarefa',
|
||||
projects: 'Projecto',
|
||||
economic_clusters: 'Cluster',
|
||||
cluster_projects: 'Associação projecto–cluster',
|
||||
value_chains: 'Etapa da cadeia de valor',
|
||||
value_chain_links: 'Ligação entre etapas',
|
||||
investment_gaps: 'Lacuna de investimento',
|
||||
};
|
||||
const fields: Record<string, string> = {
|
||||
version: 'Versão',
|
||||
active: 'Activo',
|
||||
name: 'Nome',
|
||||
slug: 'Endereço',
|
||||
description: 'Descrição',
|
||||
short_description: 'Descrição curta',
|
||||
status: 'Estado',
|
||||
is_active: 'Activo',
|
||||
is_featured: 'Destaque',
|
||||
sort_order: 'Ordem',
|
||||
sector_id: 'Sector',
|
||||
maturity_level: 'Maturidade',
|
||||
maturity_label: 'Descrição da maturidade',
|
||||
estimated_investment_amount: 'Investimento',
|
||||
estimated_investment_currency: 'Moeda',
|
||||
reference: 'Referência',
|
||||
title: 'Título',
|
||||
summary: 'Resumo',
|
||||
province: 'Província',
|
||||
district: 'Distrito',
|
||||
promoter_name: 'Promotor',
|
||||
promoter_type: 'Tipo de promotor',
|
||||
financing_modality: 'Financiamento',
|
||||
expected_impact: 'Impacto',
|
||||
published_at: 'Publicação',
|
||||
reviewed_at: 'Data de revisão',
|
||||
reviewed_by: 'Responsável pela revisão',
|
||||
};
|
||||
function display(value: unknown): string {
|
||||
if (value === null || value === undefined) return '—';
|
||||
if (typeof value === 'boolean') return value ? 'Sim' : 'Não';
|
||||
if (typeof value === 'object') return JSON.stringify(value);
|
||||
if (typeof value === 'string') return value;
|
||||
if (typeof value === 'number') return value.toString();
|
||||
return '—';
|
||||
}
|
||||
export default function History({ events }: { events: Paginated<Event> }) {
|
||||
return (
|
||||
<Management title="Histórico de alterações">
|
||||
<p className="text-muted-foreground">
|
||||
Alterações efectuadas na gestão do portal. Os textos e contactos
|
||||
pessoais não são copiados para o histórico.
|
||||
</p>
|
||||
<div className="space-y-4">
|
||||
{events.data.map((event) => (
|
||||
<article
|
||||
key={event.id}
|
||||
className="space-y-2 rounded border p-4"
|
||||
>
|
||||
<h2 className="font-semibold break-words">
|
||||
{entities[event.entity_type] ?? event.entity_type} #
|
||||
{event.after_data.record_id} ·{' '}
|
||||
{event.action === 'created'
|
||||
? 'Criado'
|
||||
: 'Actualizado'}
|
||||
</h2>
|
||||
<p>
|
||||
{event.actor ?? 'Utilizador indisponível'} ·{' '}
|
||||
{new Intl.DateTimeFormat('pt-MZ', {
|
||||
dateStyle: 'medium',
|
||||
timeStyle: 'short',
|
||||
timeZone: 'Africa/Maputo',
|
||||
}).format(new Date(event.occurred_at))}{' '}
|
||||
(Maputo)
|
||||
</p>
|
||||
<p className="text-sm break-words">
|
||||
Campos:{' '}
|
||||
{event.after_data.changed_fields
|
||||
.map((key) => fields[key] ?? key)
|
||||
.join(', ')}
|
||||
</p>
|
||||
{Object.entries(event.after_data.values)
|
||||
.filter(
|
||||
([key, value]) =>
|
||||
JSON.stringify(
|
||||
event.before_data.values[key],
|
||||
) !== JSON.stringify(value),
|
||||
)
|
||||
.map(([key, value]) => (
|
||||
<p key={key} className="text-sm break-words">
|
||||
{fields[key] ?? key}:{' '}
|
||||
{display(
|
||||
event.before_data.values[key] ?? '—',
|
||||
)}{' '}
|
||||
→ {display(value)}
|
||||
</p>
|
||||
))}
|
||||
</article>
|
||||
))}
|
||||
</div>
|
||||
{!events.data.length && (
|
||||
<p>Ainda não existem alterações registadas.</p>
|
||||
)}
|
||||
<Pagination page={events} />
|
||||
</Management>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,119 @@
|
||||
import { Link, useForm } from "@inertiajs/react";
|
||||
import { Management, Field, button, control, states } from "./shared";
|
||||
|
||||
type Interest = {
|
||||
id: number;
|
||||
reference: string;
|
||||
full_name: string;
|
||||
email: string;
|
||||
phone: string | null;
|
||||
investor_type: string;
|
||||
country: string;
|
||||
sector_interest: string;
|
||||
opportunity_reference: string | null;
|
||||
investment_range: string | null;
|
||||
message: string;
|
||||
status: string;
|
||||
consented_at: string | null;
|
||||
reviewed_at: string | null;
|
||||
reviewed_by: number | null;
|
||||
created_at: string;
|
||||
metadata?: {
|
||||
submission_id?: string;
|
||||
journey_id?: string;
|
||||
dossier_id?: string;
|
||||
role?: string;
|
||||
horizon?: string;
|
||||
};
|
||||
};
|
||||
function dateTime(value: string | null) {
|
||||
if (!value) return "—";
|
||||
return new Intl.DateTimeFormat("pt-MZ", {
|
||||
dateStyle: "medium",
|
||||
timeStyle: "short",
|
||||
timeZone: "Africa/Maputo",
|
||||
}).format(new Date(value));
|
||||
}
|
||||
export default function InterestDetail({ interest }: { interest: Interest }) {
|
||||
const form = useForm({ status: interest.status });
|
||||
const rows: [string, string | number | null][] = [
|
||||
["Nome", interest.full_name],
|
||||
["Email", interest.email],
|
||||
["Telefone", interest.phone],
|
||||
["Tipo de investidor", interest.investor_type],
|
||||
["País", interest.country],
|
||||
["Sector", interest.sector_interest],
|
||||
["Oportunidade", interest.opportunity_reference],
|
||||
["Faixa de investimento", interest.investment_range],
|
||||
["Recebido em (Maputo)", dateTime(interest.created_at)],
|
||||
["Consentimento em (Maputo)", dateTime(interest.consented_at)],
|
||||
["Revisto em (Maputo)", dateTime(interest.reviewed_at)],
|
||||
["Revisto pelo utilizador", interest.reviewed_by],
|
||||
];
|
||||
return (
|
||||
<Management title={interest.reference}>
|
||||
{interest.metadata?.submission_id && (
|
||||
<Link
|
||||
className="underline"
|
||||
href={`/investidor/manifestacoes/${interest.metadata.submission_id}`}
|
||||
>
|
||||
Consultar manifestação completa, necessidades e anexos privados
|
||||
</Link>
|
||||
)}
|
||||
{interest.metadata?.dossier_id && (
|
||||
<section className="space-y-2 rounded border p-4">
|
||||
<h2 className="font-semibold">Contexto de investimento</h2>
|
||||
<Link
|
||||
className="underline"
|
||||
href={`/management/portfolio/${interest.metadata.dossier_id}`}
|
||||
>
|
||||
Consultar corredor, cluster ou projecto de origem
|
||||
</Link>
|
||||
<p>Jornada: {interest.metadata.journey_id}</p>
|
||||
<p>
|
||||
Papel: {interest.metadata.role} · Horizonte: {interest.metadata.horizon}
|
||||
</p>
|
||||
</section>
|
||||
)}
|
||||
<Link className={button} href={`/management/crm/convert/${interest.id}`}>
|
||||
Encaminhar para o CRM
|
||||
</Link>
|
||||
<dl className="grid gap-4 sm:grid-cols-2">
|
||||
{rows.map(([label, value]) => (
|
||||
<div key={label}>
|
||||
<dt className="text-muted-foreground text-sm">{label}</dt>
|
||||
<dd className="break-words">{value ?? "—"}</dd>
|
||||
</div>
|
||||
))}
|
||||
</dl>
|
||||
<section>
|
||||
<h2 className="font-semibold">Mensagem</h2>
|
||||
<p className="mt-2 break-words whitespace-pre-wrap">{interest.message}</p>
|
||||
</section>
|
||||
<form
|
||||
className="max-w-sm space-y-4"
|
||||
onSubmit={(e) => {
|
||||
e.preventDefault();
|
||||
form.patch(`/management/interests/${interest.id}`);
|
||||
}}
|
||||
>
|
||||
<Field label="Estado do pedido" error={form.errors.status}>
|
||||
<select
|
||||
className={control}
|
||||
value={form.data.status}
|
||||
onChange={(e) => form.setData("status", e.target.value)}
|
||||
>
|
||||
{["received", "in_review", "contacted", "closed"].map((key) => (
|
||||
<option key={key} value={key}>
|
||||
{states[key]}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</Field>
|
||||
<button className={button} disabled={form.processing}>
|
||||
{form.processing ? "A guardar…" : "Guardar estado"}
|
||||
</button>
|
||||
</form>
|
||||
</Management>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
import { Link, router } from '@inertiajs/react';
|
||||
import { useState } from 'react';
|
||||
import { Management, Pagination, button, control, states } from './shared';
|
||||
import type { Paginated } from './shared';
|
||||
|
||||
type Interest = {
|
||||
id: number;
|
||||
reference: string;
|
||||
full_name: string;
|
||||
email: string;
|
||||
sector_interest: string;
|
||||
status: string;
|
||||
};
|
||||
export default function Interests({
|
||||
requests,
|
||||
filters,
|
||||
}: {
|
||||
requests: Paginated<Interest>;
|
||||
filters: { q?: string; status?: string };
|
||||
}) {
|
||||
const [q, setQ] = useState(filters.q ?? '');
|
||||
const [status, setStatus] = useState(filters.status ?? '');
|
||||
return (
|
||||
<Management title="Manifestações de interesse">
|
||||
<form
|
||||
className="flex flex-wrap gap-3"
|
||||
onSubmit={(e) => {
|
||||
e.preventDefault();
|
||||
router.get('/management/interests', { q, status });
|
||||
}}
|
||||
>
|
||||
<input
|
||||
aria-label="Pesquisar pedidos"
|
||||
className={`${control} max-w-sm`}
|
||||
placeholder="Referência, nome ou email"
|
||||
value={q}
|
||||
onChange={(e) => setQ(e.target.value)}
|
||||
/>
|
||||
<select
|
||||
aria-label="Estado"
|
||||
className={`${control} max-w-xs`}
|
||||
value={status}
|
||||
onChange={(e) => setStatus(e.target.value)}
|
||||
>
|
||||
<option value="">Todos os estados</option>
|
||||
{['received', 'in_review', 'contacted', 'closed'].map(
|
||||
(key) => (
|
||||
<option key={key} value={key}>
|
||||
{states[key]}
|
||||
</option>
|
||||
),
|
||||
)}
|
||||
</select>
|
||||
<button className={button}>Pesquisar</button>
|
||||
</form>
|
||||
<div className="overflow-x-auto">
|
||||
<table className="w-full text-left text-sm">
|
||||
<thead>
|
||||
<tr>
|
||||
{[
|
||||
'Referência',
|
||||
'Nome',
|
||||
'Email',
|
||||
'Sector',
|
||||
'Estado',
|
||||
].map((label) => (
|
||||
<th key={label} className="border-b p-3">
|
||||
{label}
|
||||
</th>
|
||||
))}
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{requests.data.map((item) => (
|
||||
<tr key={item.id}>
|
||||
<td className="border-b p-3">
|
||||
<Link
|
||||
className="underline"
|
||||
href={`/management/interests/${item.id}`}
|
||||
>
|
||||
{item.reference}
|
||||
</Link>
|
||||
</td>
|
||||
<td className="border-b p-3">
|
||||
{item.full_name}
|
||||
</td>
|
||||
<td className="border-b p-3">{item.email}</td>
|
||||
<td className="border-b p-3">
|
||||
{item.sector_interest}
|
||||
</td>
|
||||
<td className="border-b p-3">
|
||||
{states[item.status] ?? item.status}
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{!requests.data.length && <p>Nenhum pedido encontrado.</p>}
|
||||
<Pagination page={requests} />
|
||||
</Management>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
import { Head, Link, usePage } from "@inertiajs/react";
|
||||
import type { ReactNode } from "react";
|
||||
import { cloneElement, isValidElement, useId } from "react";
|
||||
|
||||
export type Paginated<T> = {
|
||||
data: T[];
|
||||
total: number;
|
||||
current_page: number;
|
||||
last_page: number;
|
||||
prev_page_url: string | null;
|
||||
next_page_url: string | null;
|
||||
};
|
||||
export const control = "w-full rounded-md border border-input bg-background p-2 text-foreground";
|
||||
export const button =
|
||||
"inline-flex items-center rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground disabled:opacity-50";
|
||||
export const states: Record<string, string> = {
|
||||
received: "Recebido",
|
||||
in_review: "Em análise",
|
||||
contacted: "Contactado",
|
||||
closed: "Encerrado",
|
||||
draft: "Rascunho",
|
||||
published: "Publicado",
|
||||
archived: "Arquivado",
|
||||
};
|
||||
|
||||
export function Management({ title, children }: { title: string; children: ReactNode }) {
|
||||
const { flash, educationEnabled, aiEnabled } = usePage<{
|
||||
flash?: { success?: string };
|
||||
educationEnabled?: boolean;
|
||||
aiEnabled?: boolean;
|
||||
}>().props;
|
||||
return (
|
||||
<main className="space-y-6 p-4 md:p-8">
|
||||
<Head title={title} />
|
||||
<nav className="flex flex-wrap gap-4 text-sm underline" aria-label="Gestão do portal">
|
||||
<Link href="/management/interests">Pedidos de interesse</Link>
|
||||
<Link href="/management/sectors">Sectores</Link>
|
||||
<Link href="/management/opportunities">Oportunidades</Link>
|
||||
<Link href="/management/history">Histórico</Link>
|
||||
<Link href="/management/crm/leads">CRM</Link>
|
||||
<Link href="/management/crm/investors">Investidores</Link>
|
||||
<Link href="/management/projects">Projectos</Link>
|
||||
<Link href="/management/clusters">Clusters</Link>
|
||||
<Link href="/management/investment/zones">ZEE, ZFI e parques</Link>
|
||||
{educationEnabled && (
|
||||
<Link href="/management/education">Competências e formação</Link>
|
||||
)}
|
||||
{aiEnabled && <Link href="/management/ai">Assistência e fontes</Link>}
|
||||
<Link href="/management/portfolio">Corredores e matriz de investimento</Link>
|
||||
<Link href="/management/portal-services">Documentos e parcerias</Link>
|
||||
<Link href="/management/investment/references">Referências e formulários</Link>
|
||||
<a href="/">Portal público</a>
|
||||
</nav>
|
||||
<h1 className="text-2xl font-semibold break-words">{title}</h1>
|
||||
{flash?.success && (
|
||||
<p role="status" className="rounded border border-emerald-600 p-3">
|
||||
{flash.success}
|
||||
</p>
|
||||
)}
|
||||
{children}
|
||||
</main>
|
||||
);
|
||||
}
|
||||
|
||||
export function Pagination<T>({ page }: { page: Paginated<T> }) {
|
||||
return (
|
||||
<nav aria-label="Paginação" className="flex flex-wrap items-center gap-4">
|
||||
{page.prev_page_url && (
|
||||
<Link className={button} href={page.prev_page_url}>
|
||||
Anterior
|
||||
</Link>
|
||||
)}
|
||||
<span>
|
||||
{page.total} registos · Página {page.current_page} de {page.last_page}
|
||||
</span>
|
||||
{page.next_page_url && (
|
||||
<Link className={button} href={page.next_page_url}>
|
||||
Seguinte
|
||||
</Link>
|
||||
)}
|
||||
</nav>
|
||||
);
|
||||
}
|
||||
|
||||
export function Field({
|
||||
label,
|
||||
error,
|
||||
children,
|
||||
}: {
|
||||
label: string;
|
||||
error?: string;
|
||||
children: ReactNode;
|
||||
}) {
|
||||
const id = useId();
|
||||
return (
|
||||
<label className="block space-y-1">
|
||||
<span id={id} className="text-sm font-medium">
|
||||
{label}
|
||||
</span>
|
||||
{isValidElement<{
|
||||
"aria-labelledby"?: string;
|
||||
"aria-describedby"?: string;
|
||||
"aria-invalid"?: boolean;
|
||||
}>(children)
|
||||
? cloneElement(children, {
|
||||
"aria-labelledby": id,
|
||||
"aria-describedby": error ? `${id}-error` : undefined,
|
||||
"aria-invalid": Boolean(error),
|
||||
})
|
||||
: children}
|
||||
{error && (
|
||||
<span id={`${id}-error`} role="alert" className="block text-sm text-red-600">
|
||||
{error}
|
||||
</span>
|
||||
)}
|
||||
</label>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user