+500
@@ -0,0 +1,500 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
use App\Models\Opportunity;
|
||||
use App\Models\User;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
use Opis\JsonSchema\CompliantValidator;
|
||||
use Opis\JsonSchema\Errors\ErrorFormatter;
|
||||
use Opis\JsonSchema\Errors\ValidationError;
|
||||
|
||||
/** Explicit adapter of §25/26 to existing IDs and resource collections; never renumbers records. */
|
||||
class OpportunityCanonicalContract
|
||||
{
|
||||
public const BASE_CATEGORIES = ['investment_project', 'real_estate', 'land_rights', 'business_sale', 'business_partnership', 'franchise'];
|
||||
|
||||
/** Availability of this bounded base-category delivery, without rewriting existing contracts/data. */
|
||||
public function deliveryBlockers(array $payload): array
|
||||
{
|
||||
$errors = [];
|
||||
if (! in_array($payload['opportunity_category'] ?? '', self::BASE_CATEGORIES, true) && ! app(OpportunityModularProfiles::class)->enabled()) {
|
||||
$errors['canonical.opportunity_category'] = 'Categoria fora desta entrega: concessão, financiamento, fornecimento e outros permanecem indisponíveis. Os registos anteriores são preservados.';
|
||||
}
|
||||
if (($payload['opportunity_category'] ?? '') === 'real_estate') {
|
||||
$property = $payload['real_estate'] ?? [];
|
||||
foreach (['construction_status' => ['completed'], 'occupancy_status' => ['vacant'], 'transaction_type' => ['sale', 'lease']] as $field => $values) {
|
||||
if (! empty($property[$field]) && ! in_array($property[$field], $values, true)) {
|
||||
$errors['canonical.real_estate.'.$field] = 'Variante indisponível para submissão nesta entrega. Pode guardar e recuperar a preparação; estão incluídas venda e arrendamento de imóvel concluído e desocupado.';
|
||||
}
|
||||
}
|
||||
if (array_filter($property['encumbrances'] ?? [], fn ($row) => ! empty($row['type']) && $row['type'] !== 'none')) {
|
||||
$errors['canonical.real_estate.encumbrances'] = 'Imóvel com encargos: pode preparar e guardar; a submissão deste ramo não está incluída nesta entrega.';
|
||||
}
|
||||
if (! empty($property['max_built_area']) || ! empty($property['urban_limit_document_id'])) {
|
||||
$errors['canonical.real_estate.max_built_area'] = 'Limitações urbanísticas adicionais: preparação disponível; este ramo de submissão aguarda demonstração própria.';
|
||||
}
|
||||
}
|
||||
|
||||
return $errors;
|
||||
}
|
||||
|
||||
public const VERSION = 'opportunity-canonical-adapter-20261010-semantic1';
|
||||
|
||||
/** @return array<string,mixed> */
|
||||
public function schema(bool $draft = false): array
|
||||
{
|
||||
$bytes = file_get_contents(resource_path('data/investmoz-opportunity-modular.schema.json'));
|
||||
if ($bytes === false) {
|
||||
throw new \RuntimeException('Opportunity schema unavailable.');
|
||||
}
|
||||
$schema = json_decode($bytes, true, 512, JSON_THROW_ON_ERROR);
|
||||
// The original conditions were omitted from the extracted Create/Patch definitions.
|
||||
foreach (['opportunity', 'realEstate', 'landRights', 'businessTransaction'] as $name) {
|
||||
$schema['$defs'][$name.'Create']['allOf'] = $schema['$defs'][$name]['allOf'] ?? [];
|
||||
}
|
||||
$schema = app(OpportunityCategoryFields::class)->enrich($schema);
|
||||
$schema = app(OpportunityModularProfiles::class)->extend($schema);
|
||||
$schema = $this->writeSchema($schema, $draft);
|
||||
$properties = &$schema['$defs']['opportunityCreate']['properties'];
|
||||
unset($properties['mutation_context']); // Actor, audit reason and revision are server-owned.
|
||||
$properties['sector_id'] = ['type' => 'integer', 'minimum' => 1];
|
||||
$properties['promoter_id'] = ['type' => ['string', 'integer']];
|
||||
// References point to the existing collections; their metadata is recovered on the server.
|
||||
foreach (['locations', 'documents', 'images'] as $field) {
|
||||
$properties[$field]['items'] = ['type' => 'string', 'format' => 'uuid'];
|
||||
}
|
||||
$properties['evidences'] = ['type' => 'array', 'items' => ['$ref' => '#/$defs/evidenceCreate']];
|
||||
if (! $draft) {
|
||||
$properties['evidences']['minItems'] = 1;
|
||||
}
|
||||
$properties['evidences']['items'] = ['type' => 'object', 'additionalProperties' => false,
|
||||
'properties' => ['title' => ['type' => 'string'], 'evidence_type' => ['type' => 'string'],
|
||||
'document_id' => ['type' => 'string', 'format' => 'uuid'], 'description' => ['type' => 'string']],
|
||||
...($draft ? [] : ['required' => ['title', 'evidence_type', 'document_id']])];
|
||||
$schema['$ref'] = '#/$defs/opportunityCreate';
|
||||
$schema['$id'] = 'urn:investmoz:'.self::VERSION.($draft ? ':draft' : ':submit');
|
||||
|
||||
return $schema;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string,mixed> $node
|
||||
* @return array<string,mixed>
|
||||
*/
|
||||
private function writeSchema(array $node, bool $draft): array
|
||||
{
|
||||
if (isset($node['$ref']) && preg_match('~^#/\$defs/(.+)$~', $node['$ref'], $match)) {
|
||||
// Collections in the normative Create still referenced response definitions.
|
||||
$defs = ['product', 'asset', 'input', 'market', 'impact', 'moneyItem', 'milestone', 'license', 'risk', 'relation', 'employment', 'environmentalSocial', 'localizedPublication', 'realEstate', 'landRights', 'businessTransaction', 'parcel', 'improvement', 'community'];
|
||||
if (in_array($match[1], $defs, true)) {
|
||||
$node['$ref'] .= 'Create';
|
||||
}
|
||||
}
|
||||
if ($draft) {
|
||||
unset($node['required'], $node['minItems'], $node['minProperties'], $node['contains'], $node['allOf']);
|
||||
if (isset($node['type'])) {
|
||||
$node['type'] = array_values(array_unique([...(array) $node['type'], 'null']));
|
||||
}
|
||||
if (isset($node['enum']) && ! in_array(null, $node['enum'], true)) {
|
||||
$node['enum'][] = null;
|
||||
}
|
||||
if (isset($node['minLength'])) {
|
||||
$node['minLength'] = 0;
|
||||
}
|
||||
if (($node['const'] ?? null) === true) {
|
||||
unset($node['const']);
|
||||
$node['type'] = 'boolean';
|
||||
}
|
||||
}
|
||||
foreach ($node as $key => $value) {
|
||||
if (is_array($value)) {
|
||||
if (in_array($key, ['properties', '$defs'], true)) {
|
||||
foreach ($value as $name => $child) {
|
||||
$value[$name] = $this->writeSchema($child, $draft);
|
||||
}
|
||||
$node[$key] = $value;
|
||||
} elseif (in_array($key, ['items', 'if', 'then', 'else'], true)) {
|
||||
$node[$key] = $this->writeSchema($value, $draft);
|
||||
} elseif (in_array($key, ['allOf', 'oneOf', 'anyOf'], true)) {
|
||||
$node[$key] = array_map(fn ($child) => $this->writeSchema($child, $draft), $value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $node;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string,mixed> $payload
|
||||
* @return array<string,mixed>
|
||||
*/
|
||||
public function draft(array $payload): array
|
||||
{
|
||||
abort_unless(config('portal.opportunity_specialized_drafts_enabled'), 422, 'Contrato especializado indisponível.');
|
||||
$this->validateSchema($payload, true);
|
||||
|
||||
return $payload;
|
||||
}
|
||||
|
||||
/** @param array<string,mixed> $payload */
|
||||
private function validateSchema(array $payload, bool $draft): void
|
||||
{
|
||||
$schema = $this->schema($draft);
|
||||
$validator = new CompliantValidator(null, 100, false);
|
||||
$data = $this->schemaData($payload, $schema['$defs']['opportunityCreate'], $schema['$defs']);
|
||||
$result = $validator->validate($data, json_decode(json_encode($schema, JSON_THROW_ON_ERROR)));
|
||||
if ($error = $result->error()) {
|
||||
$errors = [];
|
||||
foreach ((new ErrorFormatter)->format($error) as $path => $messages) {
|
||||
$errors['canonical'.str_replace('/', '.', $path)] = $messages;
|
||||
}
|
||||
$required = function (ValidationError $node) use (&$required, &$errors): void {
|
||||
if ($node->keyword() === 'required') {
|
||||
$prefix = 'canonical.'.implode('.', $node->data()->fullPath());
|
||||
foreach ($node->args()['missing'] ?? [] as $field) {
|
||||
$errors[rtrim($prefix, '.').'.'.$field] = ['Preencha este campo antes de submeter.'];
|
||||
}
|
||||
}
|
||||
foreach ($node->subErrors() as $child) {
|
||||
$required($child);
|
||||
}
|
||||
};
|
||||
$required($error);
|
||||
throw ValidationException::withMessages($errors);
|
||||
}
|
||||
}
|
||||
|
||||
/** @param array<string,mixed> $node
|
||||
* @param array<string,mixed> $defs
|
||||
*/
|
||||
private function schemaData(mixed $value, array $node, array $defs): mixed
|
||||
{
|
||||
if (isset($node['$ref'])) {
|
||||
$name = basename($node['$ref']);
|
||||
$node = $defs[$name] ?? $node;
|
||||
}
|
||||
if (! is_array($value)) {
|
||||
return $value;
|
||||
}
|
||||
if (in_array('object', (array) ($node['type'] ?? []), true) || isset($node['properties'])) {
|
||||
$result = new \stdClass;
|
||||
foreach ($value as $key => $item) {
|
||||
$result->{$key} = $this->schemaData($item, $node['properties'][$key] ?? [], $defs);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
return array_map(fn ($item) => $this->schemaData($item, $node['items'] ?? [], $defs), $value);
|
||||
}
|
||||
|
||||
/** @return array<string,mixed> */
|
||||
public function validateSubmission(Opportunity $record): array
|
||||
{
|
||||
$values = app(OpportunityManagement::class)->values($record);
|
||||
$payload = $values['canonical'] ?? [];
|
||||
$this->validateSchema($payload, false);
|
||||
$errors = [];
|
||||
$check = function (bool $valid, string $path, string $message) use (&$errors): void {
|
||||
if (! $valid) {
|
||||
$errors['canonical.'.$path] = $message;
|
||||
}
|
||||
};
|
||||
$check(($payload['opportunity_category'] ?? null) === $record->opportunity_category, 'opportunity_category', 'A categoria deve coincidir com o registo e a autorização.');
|
||||
$check(($payload['promoter_id'] ?? null) === ($record->organization_id ?? (int) $record->owner_user_id), 'promoter_id', 'Use a organização representada ou o autor individual; não outra identidade.');
|
||||
$sector = DB::table('sectors')->where('id', $payload['sector_id'])->whereNull('deleted_at')->where('is_active', true)->first();
|
||||
$subsector = DB::table('economic_activities')->where('id', $payload['subsector_id'])->where('status', 'published')->first();
|
||||
$activity = DB::table('economic_activities')->where('id', $payload['economic_activity_id'])->where('status', 'published')->first();
|
||||
$root = $subsector?->parent_id ? DB::table('economic_activities')->where('id', $subsector->parent_id)->where('status', 'published')->first() : null;
|
||||
$check($sector !== null && $root !== null && (int) $root->sector_id === (int) $sector->id
|
||||
&& $activity !== null && $activity->parent_id === $subsector->id && $activity->catalog_version_id === $root->catalog_version_id,
|
||||
'economic_activity_id', 'Sector → subsector → atividade requer referências publicadas da mesma versão e hierarquia.');
|
||||
foreach (['internal_contact_id', 'public_contact_id'] as $field) {
|
||||
if (! empty($payload[$field])) {
|
||||
$contacts = DB::table('contacts')->where('contacts.id', $payload[$field])->whereNull('contacts.deleted_at');
|
||||
if ($record->organization_id) {
|
||||
$contacts->whereExists(fn ($q) => $q->selectRaw('1')->from('investor_contacts as ic')->join('investors as i', 'i.id', '=', 'ic.investor_id')
|
||||
->whereColumn('ic.contact_id', 'contacts.id')->where('i.organization_id', $record->organization_id)->whereNull('i.deleted_at'));
|
||||
} else {
|
||||
$contacts->where('source_system', 'portal-user-contact')->where('external_id', 'user:'.$record->owner_user_id);
|
||||
}
|
||||
$check($contacts->exists(), $field, 'Contacto inexistente ou sem relação com o Promotor.');
|
||||
}
|
||||
}
|
||||
$resources = [];
|
||||
foreach (['locations', 'documents', 'images'] as $kind) {
|
||||
$table = app(OpportunityResources::class)->table($kind);
|
||||
foreach ($payload[$kind] ?? [] as $index => $id) {
|
||||
$row = DB::table($table)->where('id', $id)->where('opportunity_id', $record->id)->whereNull('deleted_at')->first();
|
||||
$check($row !== null, "$kind.$index", 'Recurso inexistente, eliminado ou de outra oportunidade.');
|
||||
if (! $row) {
|
||||
continue;
|
||||
}
|
||||
$row->payload = json_decode($row->payload, true, 512, JSON_THROW_ON_ERROR);
|
||||
if ($kind !== 'locations') {
|
||||
$file = DB::table('documents')->where('id', $row->document_id)->first();
|
||||
$check($file !== null && $file->deleted_at === null && $file->status === 'active' && $file->malware_scan_status === 'clean'
|
||||
&& hash_equals(trim($file->sha256), trim((string) $file->malware_scanned_sha256)), "$kind.$index", 'Original ativo com análise antimalware correspondente obrigatória.');
|
||||
if ($file) {
|
||||
// Verify actual bytes/cipher integrity as well as the recorded scan hash.
|
||||
app(VerifiedDocumentBinary::class)->respond($file);
|
||||
$row->sha256 = trim($file->sha256);
|
||||
}
|
||||
} else {
|
||||
$location = $row->payload;
|
||||
$check(! empty($location['district_id']) && ! empty($location['role']) && array_key_exists('is_primary', $location), "locations.$index", 'Localização requer distrito, papel e indicação de principal.');
|
||||
app(InvestmentGeography::class)->selection($location, true);
|
||||
$country = $location['country_code'] ?? null;
|
||||
$check($country === 'MZ', "locations.$index.country_code", 'A hierarquia administrativa moçambicana deve declarar MZ; outros países exigem localização própria.');
|
||||
}
|
||||
$resources[$kind][$id] = (array) $row;
|
||||
}
|
||||
}
|
||||
$locations = $resources['locations'] ?? [];
|
||||
$primary = array_filter($locations, fn ($l) => $l['payload']['is_primary'] ?? false);
|
||||
$check(count($primary) === 1, 'locations', 'Selecione exatamente uma localização principal.');
|
||||
$check($payload['location_mode'] !== 'single' || count($locations) === 1, 'location_mode', 'Modo single exige uma localização.');
|
||||
foreach ($payload['evidences'] as $i => $evidence) {
|
||||
$check(isset($resources['documents'][$evidence['document_id']]), "evidences.$i.document_id", 'Evidência deve usar um documento ativo desta oportunidade incluído no contrato.');
|
||||
}
|
||||
$this->categoryRules($payload, $record, $resources, $errors);
|
||||
app(OpportunityCategoryFields::class)->validate($payload, $record, $resources, $errors);
|
||||
if ($errors) {
|
||||
throw ValidationException::withMessages($errors);
|
||||
}
|
||||
ksort($payload);
|
||||
$snapshot = ['adapter_version' => self::VERSION, 'schema_sha256' => hash_file('sha256', resource_path('data/investmoz-opportunity-modular.schema.json')),
|
||||
'payload' => $payload, 'resources' => $resources];
|
||||
if (isset(OpportunityModularProfiles::PROFILES[$record->opportunity_category]) || ($payload['module_profile_version'] ?? '') === OpportunityModularProfiles::HISTORY_VERSION) {
|
||||
$snapshot['qa_extension'] = ['version' => OpportunityModularProfiles::VERSION, 'profile_version' => $payload['module_profile_version'],
|
||||
'functional_decision' => 'Experimental QA proposal; functional approval of modular contracts and SLA remains pending. Legacy integration authorization does not approve these modules.',
|
||||
'gates' => $this->gates($record)];
|
||||
if ($record->opportunity_category === 'other') {
|
||||
$snapshot['qa_extension']['subtype'] = config('portal.opportunity_other_qa_subtypes.'.($payload['module_details']['subtype'] ?? ''), []);
|
||||
}
|
||||
// A documentary correction must not rewrite the checksum of an already
|
||||
// signed, unchanged version. Its historical annotation is explicitly
|
||||
// reconciled by the read adapter; new/changed content uses the current note.
|
||||
$prior = $record->workflow_context['submission'] ?? [];
|
||||
if (isset($prior['qa_extension']) && ($prior['payload'] ?? null) == $snapshot['payload'] && ($prior['resources'] ?? null) == $snapshot['resources']) {
|
||||
$snapshot['qa_extension']['functional_decision'] = $prior['qa_extension']['functional_decision'];
|
||||
}
|
||||
}
|
||||
$snapshot['hash'] = hash('sha256', json_encode($snapshot, JSON_THROW_ON_ERROR));
|
||||
|
||||
return $snapshot;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string,mixed> $p
|
||||
* @param array<string,mixed> $resources
|
||||
* @param array<string,string> $errors
|
||||
*/
|
||||
private function categoryRules(array $p, Opportunity $record, array $resources, array &$errors): void
|
||||
{
|
||||
$category = $p['opportunity_category'];
|
||||
app(OpportunityModularProfiles::class)->validate($p, $resources, $errors);
|
||||
foreach (['real_estate', 'land_rights', 'business_transaction'] as $module) {
|
||||
$applicable = match ($module) {
|
||||
'real_estate' => ['real_estate'], 'land_rights' => ['land_rights'], default => ['business_sale', 'business_partnership', 'franchise']
|
||||
};
|
||||
if (isset($p[$module]) && ! in_array($category, $applicable, true)) {
|
||||
$errors['canonical.'.$module] = 'Módulo incompatível com a categoria. Preserve-o noutra versão antes de mudar de categoria.';
|
||||
}
|
||||
}
|
||||
if ($category === 'investment_project') {
|
||||
$total = $p['total_investment'];
|
||||
$sum = array_sum(array_column($p['investment_breakdown'], 'amount'));
|
||||
$secured = array_sum(array_column($p['secured_financing'], 'amount'));
|
||||
if (abs($sum - $total) > 0.010001 || $secured > $total || abs($p['funding_sought'] - ($total - $secured)) > 0.010001) {
|
||||
$errors['canonical.investment_breakdown'] = 'Rubricas e financiamento devem reconciliar com o total (tolerância normativa 0,01).';
|
||||
}
|
||||
if (! in_array($p['maturity_stage'], array_keys(OpportunityMaturity::STAGES), true)) {
|
||||
$errors['canonical.maturity_stage'] = 'Use um código explícito do catálogo de oito etapas; não reinterpretar a escala histórica.';
|
||||
}
|
||||
foreach (['investment_breakdown', 'secured_financing'] as $field) {
|
||||
foreach ($p[$field] as $i => $amount) {
|
||||
if ($amount['currency'] !== $p['currency']) {
|
||||
$errors["canonical.$field.$i.currency"] = 'Moedas distintas requerem cenário/câmbio explícito; não somar valores de moedas diferentes.';
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach ($p['markets'] as $i => $market) {
|
||||
if (isset($market['country_code']) && Validator::make(['country' => $market['country_code']], ['country' => app(CountryCatalogue::class)->rule()])->fails()) {
|
||||
$errors["canonical.markets.$i.country_code"] = 'Use país do catálogo ISO existente.';
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($category === 'real_estate') {
|
||||
$re = $p['real_estate'];
|
||||
if ($re['transaction_type'] === 'sale' && ($re['price'] ?? 0) <= 0) {
|
||||
$errors['canonical.real_estate.price'] = 'Venda exige preço positivo.';
|
||||
}
|
||||
if ($re['transaction_type'] === 'lease') {
|
||||
if (($re['rent'] ?? 0) <= 0) {
|
||||
$errors['canonical.real_estate.rent'] = 'Arrendamento exige renda positiva.';
|
||||
}
|
||||
if (empty($re['rent_periodicity'])) {
|
||||
$errors['canonical.real_estate.rent_periodicity'] = 'Indique a periodicidade da renda.';
|
||||
}
|
||||
}
|
||||
if (in_array($re['construction_status'], ['completed', 'occupied', 'renovation'], true) && empty($re['property_condition'])) {
|
||||
$errors['canonical.real_estate.property_condition'] = 'Imóvel existente exige condição identificada.';
|
||||
}
|
||||
if (in_array($re['construction_status'], ['planned', 'under_construction'], true) && empty($re['planning_permit_document_id'])) {
|
||||
$errors['canonical.real_estate.planning_permit_document_id'] = 'Estado construtivo exige licença de construção (§25.1).';
|
||||
}
|
||||
if (in_array($re['construction_status'], ['completed', 'occupied', 'renovation'], true) && empty($re['use_license_document_id'])) {
|
||||
$errors['canonical.real_estate.use_license_document_id'] = 'Imóvel existente exige licença de utilização aplicável (§25.1).';
|
||||
}
|
||||
foreach (['planning_permit_document_id', 'use_license_document_id'] as $field) {
|
||||
if (! empty($re[$field]) && ! isset($resources['documents'][$re[$field]])) {
|
||||
$errors['canonical.real_estate.'.$field] = 'Licença deve referir documento ativo desta oportunidade.';
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($category === 'land_rights') {
|
||||
$land = $p['land_rights'];
|
||||
if (! empty($land['issuing_authority_id']) && ! DB::table('authorities')->where('id', $land['issuing_authority_id'])->where('status', 'published')->exists()) {
|
||||
$errors['canonical.land_rights.issuing_authority_id'] = 'Entidade emissora deve usar autoridade canónica publicada.';
|
||||
}
|
||||
if (! empty($land['issue_date']) && ($land['issue_date'] > today()->toDateString() || (! empty($land['expiry_date']) && $land['expiry_date'] <= $land['issue_date']))) {
|
||||
$errors['canonical.land_rights.issue_date'] = 'Emissão não futura e validade posterior à emissão.';
|
||||
}
|
||||
foreach ($land['parcels'] as $i => $parcel) {
|
||||
if (! isset($resources['locations'][$parcel['location_id']])) {
|
||||
$errors["canonical.land_rights.parcels.$i.location_id"] = 'Parcela deve usar uma localização desta oportunidade.';
|
||||
}
|
||||
try {
|
||||
$g = DB::selectOne('SELECT ST_IsValid(g) AND NOT ST_IsEmpty(g) AND ST_GeometryType(g)=\'ST_MultiPolygon\' AND ST_XMin(Box3D(g))>=-180 AND ST_XMax(Box3D(g))<=180 AND ST_YMin(Box3D(g))>=-90 AND ST_YMax(Box3D(g))<=90 AS valid FROM (SELECT ST_SetSRID(ST_GeomFromGeoJSON(?),4326) g) s', [json_encode($parcel['geometry'])]);
|
||||
if (! $g?->valid) {
|
||||
throw new \RuntimeException;
|
||||
}
|
||||
} catch (\Throwable) {
|
||||
$errors["canonical.land_rights.parcels.$i.geometry"] = 'Parcela requer MultiPolygon válido, não vazio, EPSG:4326; limite administrativo não é parcela.';
|
||||
}
|
||||
}
|
||||
if (in_array($land['duat_status'], ['provisional', 'definitive'], true) && empty($land['duat_number'])) {
|
||||
$errors['canonical.land_rights.duat_number'] = 'DUAT provisório/definitivo exige número e entidade emissora.';
|
||||
}
|
||||
}
|
||||
if (isset($p['business_transaction'])) {
|
||||
$business = $p['business_transaction'];
|
||||
if ($business['legal_entity_id'] !== $record->organization_id || ! DB::table('organizations')->where('id', $business['legal_entity_id'])->whereNull('deleted_at')->exists()) {
|
||||
$errors['canonical.business_transaction.legal_entity_id'] = 'Entidade ativa representada obrigatória.';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** @param array<string,mixed> $snapshot */
|
||||
public function validatePublication(array $snapshot): void
|
||||
{
|
||||
$p = $snapshot['payload'];
|
||||
$errors = [];
|
||||
app(OpportunityCategoryFields::class)->publication($p, $errors);
|
||||
app(OpportunityModularProfiles::class)->publication($p, $errors);
|
||||
foreach ($snapshot['resources']['documents'] ?? [] as $id => $document) {
|
||||
if (! empty($document['payload']['valid_until']) && $document['payload']['valid_until'] < today()->toDateString()) {
|
||||
$errors['documents.'.$id] = 'Documento incluído expirou; preserve o original e reveja a versão.';
|
||||
}
|
||||
}
|
||||
if ($p['opportunity_category'] === 'land_rights') {
|
||||
foreach ($p['land_rights']['required_authorizations'] as $i => $authorization) {
|
||||
if (! in_array($authorization['status'] ?? '', ['approved', 'not_required'], true)
|
||||
|| (($authorization['status'] ?? '') === 'approved' && ! isset($snapshot['resources']['documents'][$authorization['document_id'] ?? '']))) {
|
||||
$errors['land_rights.required_authorizations.'.$i] = 'Autorização externa pendente ou sem documento. Aprovação interna não substitui esse ato.';
|
||||
}
|
||||
}
|
||||
foreach ($p['land_rights']['overlaps_conflicts'] as $i => $conflict) {
|
||||
if (($conflict['type'] ?? '') !== 'none' && ($conflict['status'] ?? '') !== 'resolved') {
|
||||
$errors['land_rights.overlaps_conflicts.'.$i] = 'Conflito impeditivo deve ser resolvido com evidência antes de publicar.';
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($p['visibility'] === 'public') {
|
||||
$images = $snapshot['resources']['images'] ?? [];
|
||||
if (count(array_filter($images, fn ($image) => $image['payload']['is_cover'] ?? false)) !== 1) {
|
||||
$errors['images'] = 'Publicação pública exige uma capa explícita.';
|
||||
}
|
||||
foreach ($images as $id => $image) {
|
||||
$meta = $image['payload'];
|
||||
if (empty($meta['alt_text']) || empty($meta['caption']) || empty($meta['rights_status']) || empty($meta['derivatives'])
|
||||
|| (! empty($meta['rights_valid_until']) && $meta['rights_valid_until'] < today()->toDateString())) {
|
||||
$errors['images.'.$id] = 'Legenda, texto alternativo, direitos válidos e derivadas verificadas obrigatórios.';
|
||||
}
|
||||
foreach ($meta['derivatives'] ?? [] as $derived) {
|
||||
$file = DB::table('documents')->where('id', $derived['document_id'])->whereNull('deleted_at')->where('status', 'active')->where('malware_scan_status', 'clean')->whereColumn('sha256', 'malware_scanned_sha256')->first();
|
||||
if (! $file) {
|
||||
$errors['images.'.$id] = 'Scan de uma derivada ainda não demonstrado.';
|
||||
} else {
|
||||
app(VerifiedDocumentBinary::class)->respond($file);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($errors) {
|
||||
throw ValidationException::withMessages($errors);
|
||||
}
|
||||
}
|
||||
|
||||
/** @return list<string> */
|
||||
public function gates(Opportunity $record): array
|
||||
{
|
||||
return match ($record->opportunity_category) {
|
||||
'investment_project' => ['technical_review', 'legal_territorial_review'],
|
||||
'real_estate' => ['property_review', 'registry_urban_review', 'building_compliance_review'],
|
||||
'land_rights' => ['cadastral_screening', 'land_legal_review', 'community_environment_review', 'competent_authority_clearance'],
|
||||
'business_sale' => ['corporate_screening', 'financial_review', 'legal_tax_due_diligence', 'confidentiality_clearance'],
|
||||
'business_partnership' => ['corporate_screening', 'financial_review', 'partnership_governance_review', 'legal_tax_due_diligence'],
|
||||
'franchise' => ['brand_license_review', 'financial_review', 'franchise_legal_review', 'confidentiality_clearance'],
|
||||
default => app(OpportunityModularProfiles::class)->gates($record),
|
||||
};
|
||||
}
|
||||
|
||||
/** Same exact projection for preview and publication; never expose private business analysis.
|
||||
* @param array<string,mixed> $payload
|
||||
* @return array{title:string,summary:string,description:string} */
|
||||
public function publicProjection(array $payload): array
|
||||
{
|
||||
$business = isset($payload['business_transaction']) && ($payload['visibility'] ?? '') === 'public';
|
||||
|
||||
$label = match ($payload['module_details']['mode'] ?? '') {
|
||||
'intention_call' => 'Intenção/chamada em preparação — não é direito atribuído. ',
|
||||
'awarded_right' => 'Concessão com ato competente documentado. ',
|
||||
'seeking_funding' => 'Procura de financiamento. ', 'funding_offer' => 'Oferta de financiamento — sujeita a análise do beneficiário. ',
|
||||
'purchase_request' => 'Pedido de compra. ', 'supply_offer' => 'Oferta de fornecimento. ', default => '',
|
||||
};
|
||||
if (($payload['module_details']['conditions_status'] ?? '') === 'proposed') {
|
||||
$label .= 'Valores e condições propostos, sem compromisso assumido. ';
|
||||
}
|
||||
|
||||
return ['title' => (string) ($payload['official_title'] ?? ''), 'summary' => Str::limit($label.(string) ($business ? ($payload['business_transaction']['teaser'] ?? '') : ($payload['executive_summary'] ?? '')), 499, '…'),
|
||||
'description' => (string) ($business ? ($payload['business_transaction']['teaser'] ?? '') : ($payload['demand_statement'] ?? ''))];
|
||||
}
|
||||
|
||||
/** @return array<string,mixed> */
|
||||
public function options(User $actor, ?Opportunity $record): array
|
||||
{
|
||||
$orgs = array_values(array_unique(array_column(app(PortalProfileAccess::class)->navigation($actor)['contexts'] ?? [], 'organization_id')));
|
||||
if ($record?->organization_id) {
|
||||
$orgs = [$record->organization_id];
|
||||
}
|
||||
$contacts = DB::table('contacts')->whereNull('contacts.deleted_at')->where(function ($q) use ($orgs, $actor) {
|
||||
$q->where(fn ($own) => $own->where('source_system', 'portal-user-contact')->where('external_id', 'user:'.$actor->id))
|
||||
->orWhereExists(fn ($i) => $i->selectRaw('1')->from('investor_contacts as ic')->join('investors as inv', 'inv.id', '=', 'ic.investor_id')->whereColumn('ic.contact_id', 'contacts.id')->whereIn('inv.organization_id', $orgs)->whereNull('inv.deleted_at'));
|
||||
})->get(['id', 'full_name']);
|
||||
|
||||
return ['version' => self::VERSION, 'modularProfiles' => app(OpportunityModularProfiles::class)->enabled() ? OpportunityModularProfiles::PROFILES : [],
|
||||
'historyVersion' => app(OpportunityModularProfiles::class)->enabled() ? OpportunityModularProfiles::HISTORY_VERSION : null,
|
||||
'schema' => $this->schema(true)['$defs']['opportunityCreate'],
|
||||
'definitions' => $this->schema(true)['$defs'],
|
||||
'activities' => DB::table('economic_activities')->where('status', 'published')->get(['id', 'parent_id', 'sector_id', 'label_pt_mz', 'catalog_version_id']),
|
||||
'contacts' => $contacts, 'countries' => app(CountryCatalogue::class)->all(),
|
||||
'authorities' => DB::table('authorities')->where('status', 'published')->get(['id', 'label_pt_mz']),
|
||||
'gates' => $record ? $this->gates($record) : [], 'resources' => $record ? array_combine(['locations', 'documents', 'images'], array_map(fn ($k) => array_values(array_filter(app(OpportunityResources::class)->listing($record->id, $k), fn ($row) => empty($row->deleted_at))), ['locations', 'documents', 'images'])) : []];
|
||||
}
|
||||
}
|
||||
+148
@@ -0,0 +1,148 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
use App\Models\Opportunity;
|
||||
use App\Models\User;
|
||||
use Illuminate\Support\Facades\Crypt;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface;
|
||||
|
||||
/** Read adapter only: preserve persisted identifiers and make unresolved metadata explicit. */
|
||||
class OpportunityCanonicalResponse
|
||||
{
|
||||
public const VERSION = 'opportunity-response-existing-ids-20261011-4';
|
||||
|
||||
/** @return array<string,mixed> */
|
||||
public function read(User $actor, Opportunity $record): array
|
||||
{
|
||||
$access = app(PortalProfileAccess::class);
|
||||
$access->authorize($actor, 'view', $record);
|
||||
$payload = app(OpportunityManagement::class)->values($record)['canonical'] ?? [];
|
||||
$context = $record->workflow_context ?? [];
|
||||
$data = [...app(OpportunityCanonicalMetadata::class)->project($payload, $context['canonical_items'] ?? []), 'id' => $record->id, 'opportunity_code' => $record->reference,
|
||||
'opportunity_category' => $record->opportunity_category, 'status' => $access->state($record),
|
||||
'version' => (int) $record->management_version, 'is_deleted' => $record->trashed(),
|
||||
'deleted_at' => $record->deleted_at?->toIso8601String(), ...$this->rootMetadata($record)];
|
||||
foreach (['submitted' => 'submission', 'approved' => 'approval', 'published' => 'publication', 'archived' => 'archive'] as $prefix => $key) {
|
||||
$data[$prefix.'_by'] = $context[$key]['actor_id'] ?? null;
|
||||
$data[$prefix.'_at'] = $context[$key]['at'] ?? null;
|
||||
}
|
||||
$completion = app(OpportunityCompleteness::class)->calculate($payload);
|
||||
$data['completion_percentage'] = $completion['percentage'];
|
||||
$errors = [];
|
||||
try {
|
||||
app(OpportunityCanonicalContract::class)->validateSubmission($record);
|
||||
} catch (ValidationException $failure) {
|
||||
$errors = $failure->errors();
|
||||
} catch (HttpExceptionInterface $failure) {
|
||||
$errors = ['canonical.resources' => ['Recurso indisponível para validação; estado HTTP '.$failure->getStatusCode().'. Preserve o original e resolva a operação afetada.']];
|
||||
}
|
||||
$data['validation_result'] = ['errors' => $errors, 'warnings' => [], 'rule' => OpportunityCanonicalContract::VERSION,
|
||||
'evaluated_at' => now()->toIso8601String(), 'persisted_submission_hash' => $context['submission']['hash'] ?? null,
|
||||
'external_decision' => 'not_inferred'];
|
||||
$mutations = [];
|
||||
foreach (DB::table('audit_events')->where('source_system', 'opportunity-resources')->where('after_data->opportunity_id', $record->id)->orderBy('occurred_at')->orderBy('id')->get(['actor_user_id', 'action', 'occurred_at', 'after_data']) as $event) {
|
||||
$detail = json_decode($event->after_data, true, 512, JSON_THROW_ON_ERROR);
|
||||
$mutations[$detail['resource_id']][] = ['actor' => $event->actor_user_id, 'action' => $event->action, 'at' => $event->occurred_at, 'reason' => $detail['reason'] ?? null];
|
||||
}
|
||||
$references = [];
|
||||
foreach (OpportunityResources::KINDS as $kind) {
|
||||
$references[$kind] = $payload[$kind] ?? [];
|
||||
$rows = [];
|
||||
if (app(OpportunityResources::class)->installed()) {
|
||||
foreach (app(OpportunityResources::class)->listing($record->id, $kind) as $row) {
|
||||
$rows[$row->id] = $row;
|
||||
}
|
||||
}
|
||||
$data[$kind] = array_map(function (string $id) use ($rows, $kind, $mutations): array {
|
||||
$row = $rows[$id] ?? null;
|
||||
if ($row === null) {
|
||||
return ['id' => $id, 'availability' => 'unavailable'];
|
||||
}
|
||||
$value = [...$row->payload, 'id' => $row->id, 'version' => (int) $row->version,
|
||||
'is_deleted' => $row->deleted_at !== null, 'deleted_at' => $row->deleted_at,
|
||||
'created_by' => $row->created_by, 'created_at' => $row->created_at, 'updated_at' => $row->updated_at];
|
||||
$events = $mutations[$id] ?? [];
|
||||
$last = $events ? $events[array_key_last($events)] : null;
|
||||
$deletion = $row->deleted_at && ($last['action'] ?? '') === 'delete' ? $last : null;
|
||||
$value['updated_by'] = $last['actor'] ?? ((int) $row->version === 1 ? $row->created_by : null);
|
||||
$value['deleted_by'] = $deletion['actor'] ?? null;
|
||||
$value['delete_reason'] = $deletion && $deletion['reason'] ? Crypt::decryptString($deletion['reason']) : null;
|
||||
$value['mutation_metadata_source'] = $last ? 'existing_audit_events' : 'creation_record_only';
|
||||
if ($kind !== 'locations') {
|
||||
$value['original_name'] = $row->file?->file_name;
|
||||
$value['mime_type'] = $row->file?->media_type;
|
||||
$value['sha256'] = $row->file?->sha256;
|
||||
$value['scan_recorded_status'] = $row->file?->malware_scan_status;
|
||||
}
|
||||
|
||||
return $value;
|
||||
}, $references[$kind]);
|
||||
}
|
||||
|
||||
return ['adapter_version' => self::VERSION,
|
||||
'source_schema_sha256' => hash_file('sha256', resource_path('data/investmoz-opportunity-modular.schema.json')),
|
||||
'data' => $data, 'resource_references' => $references,
|
||||
'completion' => $completion, 'materiality' => $context['materiality'] ?? null,
|
||||
'review_conditions' => array_values($context['conditions'] ?? []),
|
||||
'deleted_inline_items' => array_values($context['canonical_items']['deleted'] ?? []),
|
||||
'validation_result' => ['scope' => 'current_payload_validation_and_recorded_submission_metadata', 'submission_hash' => $context['submission']['hash'] ?? null,
|
||||
'submitted_content_revision' => $context['submission']['content_revision'] ?? null,
|
||||
'current_content_revision' => $context['content_revision'] ?? 1,
|
||||
'revalidated_on_read' => true, 'external_decision' => 'not_inferred'],
|
||||
'publication' => $record->publicationPresentation(),
|
||||
'compatibility' => ['normative_response_complete' => false, 'opportunity_actor_sector_ids' => 'existing bigint, not converted to UUID',
|
||||
'modular_decision' => 'Functional approval of four modular contracts and SLA remains pending; legacy integration did not approve them. Historical snapshot annotations are preserved, not current approvals.',
|
||||
'opportunity_code' => 'existing reference preserved; no INV-MZ code invented',
|
||||
'states' => 'existing workflow values preserved; no implicit stage equivalence',
|
||||
'inline_modules' => 'management_draft canonical JSON with audited revisions; no parallel specialized tables',
|
||||
'state_correspondence' => ['draft' => 'draft', 'needs_information' => 'returned', 'submitted' => 'submitted', 'approved' => 'approved', 'published' => 'published', 'suspended' => 'suspended', 'archived' => 'archived', 'rejected' => 'rejected'],
|
||||
'unmapped_review_states' => 'in_review/information_pending preserve parallel gates; no single normative stage inferred',
|
||||
'metadata_gaps' => ['Legacy inline creation metadata can be unknown; first observation is not creation. Ambiguous changed collection rows get new identities with previous identities retained as deleted.', 'Existing bigint IDs remain explicit compatibility differences; no renumbering.']]];
|
||||
}
|
||||
|
||||
/**
|
||||
* Recover actors from existing audited versions; an imported creator must never be inferred.
|
||||
*
|
||||
* @return array<string,mixed>
|
||||
*/
|
||||
private function rootMetadata(Opportunity $record): array
|
||||
{
|
||||
$events = [];
|
||||
foreach (DB::table('audit_events')->whereIn('source_system', ['opportunity-management', 'portal-profiles-v1'])
|
||||
->where('after_data->record_id', $record->id)->get(['source_system', 'actor_user_id', 'action', 'after_data']) as $event) {
|
||||
$detail = json_decode($event->after_data, true, 512, JSON_THROW_ON_ERROR);
|
||||
$version = $detail['version'] ?? $detail['after']['version'] ?? null;
|
||||
if (! is_int($version)) {
|
||||
continue;
|
||||
}
|
||||
$events[$version] = ['actor' => $event->actor_user_id, 'action' => $event->action,
|
||||
'reason' => $detail['reason'] ?? null, 'encrypted_reason' => $event->source_system === 'opportunity-management'];
|
||||
}
|
||||
ksort($events);
|
||||
$creation = null;
|
||||
$deletion = null;
|
||||
foreach ($events as $event) {
|
||||
if ($event['action'] === 'draft_created') {
|
||||
$creation = $event;
|
||||
}
|
||||
if ($event['action'] === 'delete') {
|
||||
$deletion = $event;
|
||||
}
|
||||
}
|
||||
$latest = $events[(int) $record->management_version] ?? null;
|
||||
$deletion = $record->trashed() ? $deletion : null;
|
||||
|
||||
return ['created_by' => $creation['actor'] ?? null, 'created_at' => $record->created_at?->toIso8601String(),
|
||||
'updated_by' => $latest['actor'] ?? null, 'updated_at' => $record->updated_at?->toIso8601String(),
|
||||
'deleted_by' => $deletion['actor'] ?? null,
|
||||
'delete_reason' => $deletion && $deletion['reason'] ? ($deletion['encrypted_reason'] ? Crypt::decryptString($deletion['reason']) : $deletion['reason']) : null,
|
||||
'mutation_metadata_source' => 'existing_audit_events_and_record_timestamps',
|
||||
'mutation_metadata_gaps' => array_values(array_filter([
|
||||
$creation === null ? 'No recorded creation actor; imported ownership does not establish creation.' : null,
|
||||
$latest === null ? 'No audit actor matching the current management version; no updater inferred.' : null,
|
||||
]))];
|
||||
}
|
||||
}
|
||||
+508
@@ -0,0 +1,508 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
use App\Models\Opportunity;
|
||||
use App\Models\User;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
|
||||
class OpportunityProfileWorkflow
|
||||
{
|
||||
public function __construct(private PortalProfileAccess $access, private OpportunityManagement $management,
|
||||
private OpportunityCanonicalContract $contract, private OpportunityWorkflowTasks $tasks) {}
|
||||
|
||||
/** @return list<string> */
|
||||
public function actions(User $actor, Opportunity $record): array
|
||||
{
|
||||
if ($record->owner_user_id === null || ! $this->access->canView($actor, $record)) {
|
||||
return [];
|
||||
}
|
||||
$actions = [];
|
||||
$state = $this->access->state($record);
|
||||
if ($this->access->scoped($actor, 'promoter', $record->organization_id, $record->opportunity_category)
|
||||
&& ($record->organization_id !== null || (int) $record->owner_user_id === $actor->id)
|
||||
&& $this->access->operational($actor, 'edit', $record->id)) {
|
||||
if (in_array($state, ['draft', 'needs_information'], true)) {
|
||||
$actions[] = 'submit';
|
||||
}
|
||||
if (in_array($state, ['approved', 'published', 'suspended'], true)) {
|
||||
$actions[] = 'request_revision';
|
||||
}
|
||||
if (! in_array($state, ['archived', 'rejected'], true)) {
|
||||
$actions[] = 'request_archive';
|
||||
}
|
||||
if ($state === 'rejected' && empty($record->workflow_context['appeal']['pending'])) {
|
||||
$actions[] = 'appeal';
|
||||
}
|
||||
}
|
||||
if ($this->access->mfa($actor) && ! $this->access->conflict($actor, $record)) {
|
||||
if ($this->access->scoped($actor, 'validator', $record->organization_id, $record->opportunity_category) && $this->access->operational($actor, 'validate', $record->id)) {
|
||||
if ($state === 'approved' && count(array_filter($record->workflow_context['conditions'] ?? [], fn ($condition) => $condition['status'] === 'open' && $condition['blocking_action'] === 'publish')) > 0) {
|
||||
$actions[] = 'review_gate';
|
||||
}
|
||||
if ($state === 'submitted') {
|
||||
$actions[] = 'start_review';
|
||||
}
|
||||
if (in_array($state, ['submitted', 'in_review', 'information_pending'], true)) {
|
||||
array_push($actions, 'request_correction', 'pending_opinion', 'reject', 'review_gate', 'approve');
|
||||
if ($this->responsibility($actor, $record, 'validation_coordinator')) {
|
||||
$actions[] = 'assign_review';
|
||||
}
|
||||
}
|
||||
if ($state === 'rejected' && ($record->workflow_context['appeal']['pending'] ?? false)
|
||||
&& $this->responsibility($actor, $record, 'appeal_reviewer')
|
||||
&& (int) ($record->workflow_context['rejection']['actor_id'] ?? 0) !== $actor->id) {
|
||||
array_push($actions, 'appeal_uphold', 'appeal_reopen');
|
||||
}
|
||||
if (count(array_filter($record->workflow_context['opinions'] ?? [], fn ($opinion) => ($opinion['recipient_id'] ?? 0) === $actor->id && ($opinion['status'] ?? '') === 'pending')) > 0) {
|
||||
$actions[] = 'respond_opinion';
|
||||
}
|
||||
}
|
||||
if ($this->access->scoped($actor, 'publisher', $record->organization_id, $record->opportunity_category)) {
|
||||
if ($state === 'approved' && $this->access->operational($actor, 'publish', $record->id)
|
||||
&& (int) ($record->workflow_context['approval']['actor_id'] ?? 0) !== $actor->id) {
|
||||
$actions[] = 'publish';
|
||||
if ($this->responsibility($actor, $record, 'publication_coordinator')) {
|
||||
$actions[] = 'assign_publication';
|
||||
}
|
||||
}
|
||||
if ($this->access->operational($actor, 'archive', $record->id)) {
|
||||
if ($record->status === 'published') {
|
||||
$actions[] = 'suspend';
|
||||
}
|
||||
if ($state !== 'archived') {
|
||||
$actions[] = 'archive';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($record->workflow_context['assignment']['assignee_user_id']) && (int) $record->workflow_context['assignment']['assignee_user_id'] !== $actor->id) {
|
||||
$actions = array_values(array_diff($actions, ['start_review', 'request_correction', 'pending_opinion', 'reject', 'review_gate', 'approve']));
|
||||
}
|
||||
if (isset($record->workflow_context['publication_assignment']['assignee_user_id']) && (int) $record->workflow_context['publication_assignment']['assignee_user_id'] !== $actor->id) {
|
||||
$actions = array_values(array_diff($actions, ['publish']));
|
||||
}
|
||||
|
||||
return $actions;
|
||||
}
|
||||
|
||||
/** Scoped names/IDs only; no secrets or implicit assignees.
|
||||
* @return array<string,mixed> */
|
||||
public function participants(User $actor, Opportunity $record): array
|
||||
{
|
||||
$this->access->authorize($actor, 'view', $record);
|
||||
if (! $this->access->has($actor, 'validator') && ! $this->access->has($actor, 'publisher')) {
|
||||
return ['validators' => [], 'publishers' => [], 'condition_responsibles' => []];
|
||||
}
|
||||
$result = ['validators' => [], 'publishers' => [], 'condition_responsibles' => []];
|
||||
foreach (User::whereNotNull('email_verified_at')->whereNotNull('two_factor_confirmed_at')->get() as $candidate) {
|
||||
if ($this->access->canView($candidate, $record) && (($this->access->scoped($candidate, 'promoter', $record->organization_id, $record->opportunity_category) && $this->access->operational($candidate, 'edit', $record->id))
|
||||
|| ($this->access->scoped($candidate, 'validator', $record->organization_id, $record->opportunity_category) && $this->access->operational($candidate, 'validate', $record->id)))) {
|
||||
$result['condition_responsibles'][] = ['id' => $candidate->id, 'name' => $candidate->name];
|
||||
}
|
||||
if ($this->access->conflict($candidate, $record)) {
|
||||
continue;
|
||||
}
|
||||
foreach (['validator' => 'validators', 'publisher' => 'publishers'] as $role => $list) {
|
||||
if ($this->access->scoped($candidate, $role, $record->organization_id, $record->opportunity_category) && $this->access->operational($candidate, $role === 'validator' ? 'validate' : 'publish', $record->id)) {
|
||||
if ($role === 'publisher' && (int) ($record->workflow_context['approval']['actor_id'] ?? 0) === $candidate->id) {
|
||||
continue;
|
||||
}
|
||||
$result[$list][] = ['id' => $candidate->id, 'name' => $candidate->name, 'technical' => $this->responsibility($candidate, $record, 'technical_reviewer'), 'legal' => $this->responsibility($candidate, $record, 'legal_reviewer')];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/** @return list<string> */
|
||||
public function submissionGaps(Opportunity $record): array
|
||||
{
|
||||
try {
|
||||
$this->contract->validateSubmission($record);
|
||||
|
||||
return [];
|
||||
} catch (ValidationException $error) {
|
||||
return array_keys($error->errors());
|
||||
}
|
||||
}
|
||||
|
||||
/** @param array<string,mixed> $input */
|
||||
public function transition(User $actor, int $id, array $input): Opportunity
|
||||
{
|
||||
$record = Opportunity::withTrashed()->findOrFail($id);
|
||||
$this->access->authorize($actor, 'view', $record);
|
||||
abort_unless($record->owner_user_id !== null && ! $record->trashed(), 409, 'Workflow apenas para registos explicitamente sujeitos à política.');
|
||||
$data = Validator::make($input, ['etag' => 'required|string|size:64',
|
||||
'action' => 'required|in:submit,start_review,request_correction,pending_opinion,respond_opinion,reject,approve,publish,suspend,archive,request_archive,appeal,request_revision,review_gate,assign_review,assign_publication,appeal_uphold,appeal_reopen',
|
||||
'reason' => 'required|string|min:20|max:1000', 'correction_items' => 'sometimes|array', 'correction_items.*' => 'required|string|max:250',
|
||||
'gate' => 'sometimes|string|max:80', 'gate_decision' => 'sometimes|in:approved,rejected', 'assignee_user_id' => 'sometimes|integer|min:1',
|
||||
'opinion_id' => 'sometimes|uuid', 'recipient_user_id' => 'sometimes|integer|min:1',
|
||||
'evidence_document_ids' => 'sometimes|array', 'evidence_document_ids.*' => 'uuid', 'due_at' => 'prohibited',
|
||||
'confirm_publication' => 'sometimes|boolean', 'preview_hash' => 'sometimes|string|size:64',
|
||||
'condition' => 'sometimes|array:description,responsible_user_id,due_on,blocking_action',
|
||||
'condition.description' => 'required_with:condition|string|min:10|max:1000',
|
||||
'condition.responsible_user_id' => 'required_with:condition|integer|min:1',
|
||||
'condition.due_on' => 'sometimes|nullable|date_format:Y-m-d',
|
||||
'condition.blocking_action' => 'required_with:condition|in:approve,publish',
|
||||
'resolve_condition_ids' => 'sometimes|array', 'resolve_condition_ids.*' => 'uuid|distinct',
|
||||
])->validate();
|
||||
$action = $data['action'];
|
||||
if ($action !== 'review_gate' && (isset($data['condition']) || ! empty($data['resolve_condition_ids']))) {
|
||||
throw ValidationException::withMessages(['condition' => 'Condições só podem ser verificadas numa revisão especializada autorizada.']);
|
||||
}
|
||||
$this->authorizeAction($actor, $record, $action);
|
||||
|
||||
return DB::transaction(function () use ($actor, $id, $data, $action) {
|
||||
$record = Opportunity::whereKey($id)->lockForUpdate()->firstOrFail();
|
||||
abort_unless(hash_equals($this->management->etag($record), $data['etag']), 409, 'Versão alterada.');
|
||||
$this->authorizeAction($actor, $record, $action);
|
||||
$context = $record->workflow_context ?? [];
|
||||
$state = $this->access->state($record);
|
||||
$before = ['status' => $state, 'publication_status' => $record->status, 'version' => $record->management_version];
|
||||
$from = match ($action) {
|
||||
'submit' => ['draft', 'needs_information'], 'start_review' => ['submitted'],
|
||||
'request_correction', 'pending_opinion', 'respond_opinion', 'reject', 'approve', 'assign_review' => ['submitted', 'in_review', 'information_pending'],
|
||||
'review_gate' => ['submitted', 'in_review', 'information_pending', 'approved'],
|
||||
'publish' => ['approved'], 'suspend' => [$state],
|
||||
'assign_publication' => ['approved'],
|
||||
'request_revision' => ['approved', 'published', 'suspended'],
|
||||
'archive' => ['draft', 'submitted', 'in_review', 'information_pending', 'needs_information', 'approved', 'rejected', 'published', 'suspended'],
|
||||
'request_archive' => ['draft', 'submitted', 'in_review', 'information_pending', 'needs_information', 'approved', 'published', 'suspended'],
|
||||
'appeal', 'appeal_uphold', 'appeal_reopen' => ['rejected'],
|
||||
default => [],
|
||||
};
|
||||
abort_unless(in_array($state, $from, true), 409, 'Transição incompatível com o estado atual.');
|
||||
$decision = ['actor_id' => $actor->id, 'action' => $action, 'reason' => $data['reason'], 'at' => now()->toIso8601String(),
|
||||
'content_revision' => $context['content_revision'] ?? 1];
|
||||
if (isset($context['review_cycle'])) {
|
||||
$decision['review_cycle'] = $context['review_cycle'];
|
||||
}
|
||||
$next = $state;
|
||||
$snapshot = [];
|
||||
if ($action === 'submit' && $record->opportunity_category === 'land_rights') {
|
||||
// Serialize the existing JSON-backed §27 uniqueness check across records.
|
||||
DB::select('SELECT pg_advisory_xact_lock(111026,270000)');
|
||||
}
|
||||
if (in_array($action, ['submit', 'review_gate', 'pending_opinion', 'respond_opinion', 'approve', 'publish'], true)) {
|
||||
$blockers = $this->contract->deliveryBlockers($this->management->values($record)['canonical'] ?? []);
|
||||
try {
|
||||
$snapshot = $this->contract->validateSubmission($record);
|
||||
} catch (ValidationException $error) {
|
||||
$errors = $error->errors();
|
||||
foreach ($blockers as $field => $message) {
|
||||
$errors[$field][] = $message;
|
||||
}
|
||||
throw ValidationException::withMessages($errors);
|
||||
}
|
||||
if ($blockers !== []) {
|
||||
throw ValidationException::withMessages($blockers);
|
||||
}
|
||||
if ($action !== 'submit') {
|
||||
abort_unless(hash_equals($context['submission']['hash'] ?? '', $snapshot['hash']), 409, 'Conteúdo ou recursos mudaram desde a submissão. Exige nova submissão/revisão.');
|
||||
}
|
||||
}
|
||||
if ($action === 'submit') {
|
||||
// New review attempt, even when the canonical content is unchanged.
|
||||
// Historical decisions/tasks and the content revision keep their IDs.
|
||||
$context['review_cycle'] = max((int) ($context['review_cycle'] ?? 0), $this->submissionCount($context)) + 1;
|
||||
$decision['review_cycle'] = $context['review_cycle'];
|
||||
foreach ($context['opinions'] ?? [] as $opinionId => $opinion) {
|
||||
if (($opinion['status'] ?? '') === 'pending') {
|
||||
$context['opinions'][$opinionId]['status'] = 'superseded';
|
||||
$this->tasks->complete($opinion['task_id'] ?? null, 'Nova versão submetida; parecer anterior preservado.');
|
||||
}
|
||||
}
|
||||
$baseline = $context['review_baseline'] ?? $context['submission'] ?? [];
|
||||
$materiality = app(OpportunityReviewMateriality::class)->reconcile($baseline, $snapshot, $context['reviews'] ?? [], $this->contract->gates($record), ! empty($context['force_review']));
|
||||
$context['materiality'] = array_diff_key($materiality, ['reviews' => true]);
|
||||
$context['reviews'] = $materiality['reviews'];
|
||||
app(OpportunityReviewConditions::class)->reconcile($context, $snapshot, $materiality['reopened']);
|
||||
$context['submission'] = [...$snapshot, ...$decision];
|
||||
$context['sla'] = ['policy_version' => null, 'due_at' => null, 'status' => 'unconfigured'];
|
||||
unset($context['approval'], $context['assignment'], $context['publication_assignment'], $context['review_baseline'], $context['force_review']);
|
||||
$record->first_submitted_at ??= now()->toIso8601String();
|
||||
$record->management_closed_once = true;
|
||||
$record->workflow_context = $context;
|
||||
$context['review_task_id'] = $this->tasks->ensure($record, 'opportunity_review', 'Validação da oportunidade '.$record->reference);
|
||||
$this->tasks->complete($context['correction_task_id'] ?? null, $data['reason']);
|
||||
$next = 'submitted';
|
||||
} elseif ($action === 'start_review' || $action === 'assign_review') {
|
||||
$subject = $action === 'start_review' ? $actor : User::whereKey($data['assignee_user_id'] ?? 0)->firstOrFail();
|
||||
abort_unless($this->access->scoped($subject, 'validator', $record->organization_id, $record->opportunity_category)
|
||||
&& $this->access->operational($subject, 'validate', $record->id) && ! $this->access->conflict($subject, $record)
|
||||
&& $subject->two_factor_confirmed_at !== null, 403, 'Responsável requer papel válido, MFA configurado e independência.');
|
||||
if ($this->tasks->closedReviewBinding($record, $context['review_task_id'] ?? null)) {
|
||||
// Recover only a completed task of this opportunity in an
|
||||
// already submitted legacy attempt. Never reopen/delete it.
|
||||
$oldTask = $context['review_task_id'];
|
||||
$context['review_cycle'] = max(1, (int) ($context['review_cycle'] ?? 0), $this->submissionCount($context));
|
||||
$record->workflow_context = $context;
|
||||
$context['review_task_id'] = $this->tasks->ensure($record, 'opportunity_review', 'Validação da oportunidade '.$record->reference);
|
||||
$context['review_task_binding_history'][] = ['previous_task_id' => $oldTask, 'task_id' => $context['review_task_id'],
|
||||
'review_cycle' => $context['review_cycle'], 'at' => now()->toIso8601String(), 'reason' => 'Completed legacy review binding replaced for the current submission; original preserved.'];
|
||||
$decision['review_cycle'] = $context['review_cycle'];
|
||||
}
|
||||
$context['review_task_id'] ??= $this->tasks->ensure($record, 'opportunity_review', 'Validação da oportunidade '.$record->reference);
|
||||
$this->tasks->assign($record, $context['review_task_id'], $subject);
|
||||
$context['assignment'] = [...$decision, 'assignee_user_id' => $subject->id];
|
||||
$next = 'in_review';
|
||||
} elseif ($action === 'review_gate') {
|
||||
if ($state === 'approved') {
|
||||
throw_unless(! empty($data['resolve_condition_ids']) && empty($data['condition']) && ($data['gate_decision'] ?? '') === 'approved', ValidationException::withMessages(['resolve_condition_ids' => 'Após aprovação, só verificar condições de publicação existentes; alterações exigem nova revisão.']));
|
||||
}
|
||||
$gate = $data['gate'] ?? '';
|
||||
abort_unless(in_array($gate, $this->contract->gates($record), true), 422, 'Gate não aplicável.');
|
||||
$legal = preg_match('/legal|registry|authority|confidentiality|license/', $gate) === 1;
|
||||
abort_unless($this->responsibility($actor, $record, $legal ? 'legal_reviewer' : 'technical_reviewer'), 403, 'Responsabilidade de revisão necessária.');
|
||||
$documents = $data['evidence_document_ids'] ?? [];
|
||||
abort_unless($documents !== [] && array_diff($documents, array_keys($snapshot['resources']['documents'] ?? [])) === [], 422, 'Selecione evidência documental desta versão.');
|
||||
abort_unless(isset($data['gate_decision']), 422, 'Indique decisão fundamentada do gate.');
|
||||
app(OpportunityReviewConditions::class)->review($record, $actor, $data, $snapshot, $context);
|
||||
$context['reviews'][$gate] = [...$decision, 'decision' => $data['gate_decision'], 'hash' => $snapshot['hash'], 'evidence_document_ids' => $documents];
|
||||
$context['reviews'][$gate]['scope_hash'] = app(OpportunityReviewMateriality::class)->hash($snapshot, $gate, $context['reviews'][$gate]);
|
||||
$context['reviews'][$gate]['scope_rule'] = OpportunityReviewMateriality::VERSION;
|
||||
$next = 'in_review';
|
||||
} elseif ($action === 'approve') {
|
||||
app(OpportunityReviewConditions::class)->authorize($context, $snapshot, 'approve');
|
||||
abort_if(count(array_filter($context['opinions'] ?? [], fn ($o) => ($o['hash'] ?? '') === $snapshot['hash'] && ($o['status'] ?? '') === 'pending')) > 0, 422, 'Parecer da versão atual ainda pendente.');
|
||||
abort_if(count(array_filter($context['opinions'] ?? [], fn ($o) => ($o['hash'] ?? '') === $snapshot['hash'] && ($o['response']['decision'] ?? '') === 'rejected')) > 0, 422, 'Parecer desfavorável exige correção e nova versão.');
|
||||
foreach ($this->contract->gates($record) as $gate) {
|
||||
$review = $context['reviews'][$gate] ?? [];
|
||||
abort_unless(($review['decision'] ?? null) === 'approved' && (($review['hash'] ?? '') === $snapshot['hash'] || ($review['accepted_submission_hash'] ?? '') === $snapshot['hash']), 422, 'Gate '.$gate.' pendente, rejeitado ou de outra versão.');
|
||||
abort_unless(app(OpportunityReviewMateriality::class)->matches($snapshot, $gate, $review), 409, 'Âmbito da revisão alterado.');
|
||||
$reviewer = User::whereKey($review['actor_id'])->firstOrFail();
|
||||
abort_unless($this->access->scoped($reviewer, 'validator', $record->organization_id, $record->opportunity_category)
|
||||
&& ! $this->access->conflict($reviewer, $record) && $this->access->operational($reviewer, 'validate', $record->id)
|
||||
&& $this->responsibility($reviewer, $record, preg_match('/legal|registry|authority|confidentiality|license/', $gate) === 1 ? 'legal_reviewer' : 'technical_reviewer'), 403, 'Revisor revogado, sem responsabilidade ou com conflito.');
|
||||
}
|
||||
$context['approval'] = [...$decision, 'hash' => $snapshot['hash'], 'gates' => $context['reviews'] ?? []];
|
||||
$this->tasks->complete($context['review_task_id'] ?? null, $data['reason']);
|
||||
$record->workflow_context = $context;
|
||||
$context['publication_task_id'] = $this->tasks->ensure($record, 'opportunity_publication', 'Preparação editorial '.$record->reference);
|
||||
$next = 'approved';
|
||||
} elseif ($action === 'assign_publication') {
|
||||
$subject = User::whereKey($data['assignee_user_id'] ?? 0)->firstOrFail();
|
||||
abort_unless($this->access->scoped($subject, 'publisher', $record->organization_id, $record->opportunity_category) && $this->access->operational($subject, 'publish', $record->id) && ! $this->access->conflict($subject, $record) && $subject->two_factor_confirmed_at !== null && (int) ($context['approval']['actor_id'] ?? 0) !== $subject->id, 403, 'Publicador exige MFA, âmbito e independência da aprovação.');
|
||||
$context['publication_task_id'] ??= $this->tasks->ensure($record, 'opportunity_publication', 'Preparação editorial '.$record->reference);
|
||||
$this->tasks->assign($record, $context['publication_task_id'], $subject);
|
||||
$context['publication_assignment'] = [...$decision, 'assignee_user_id' => $subject->id];
|
||||
} elseif ($action === 'publish') {
|
||||
app(OpportunityReviewConditions::class)->authorize($context, $snapshot, 'publish');
|
||||
Validator::make($data, ['confirm_publication' => 'required|accepted', 'preview_hash' => 'required|string|size:64'])->validate();
|
||||
$this->contract->validatePublication($snapshot);
|
||||
abort_unless(hash_equals($snapshot['hash'], $data['preview_hash']), 409, 'Pré-visualização diferente da versão aprovada.');
|
||||
abort_unless(($context['approval']['hash'] ?? '') === $snapshot['hash'], 409, 'Aprovação não corresponde ao conteúdo atual.');
|
||||
foreach ($this->contract->gates($record) as $gate) {
|
||||
$review = $context['approval']['gates'][$gate] ?? [];
|
||||
abort_unless(($review['decision'] ?? null) === 'approved' && (($review['hash'] ?? '') === $snapshot['hash'] || ($review['accepted_submission_hash'] ?? '') === $snapshot['hash']), 422, 'Revisão aprovada desta versão necessária.');
|
||||
$reviewer = User::whereKey($review['actor_id'])->firstOrFail();
|
||||
abort_unless($this->access->scoped($reviewer, 'validator', $record->organization_id, $record->opportunity_category)
|
||||
&& ! $this->access->conflict($reviewer, $record) && $this->access->operational($reviewer, 'validate', $record->id)
|
||||
&& $this->responsibility($reviewer, $record, preg_match('/legal|registry|authority|confidentiality|license/', $gate) === 1 ? 'legal_reviewer' : 'technical_reviewer'), 403, 'Revisor revogado, sem responsabilidade ou com conflito na publicação.');
|
||||
}
|
||||
$approver = User::whereKey($context['approval']['actor_id'] ?? 0)->firstOrFail();
|
||||
abort_unless($this->access->scoped($approver, 'validator', $record->organization_id, $record->opportunity_category)
|
||||
&& ! $this->access->conflict($approver, $record) && $this->access->operational($approver, 'validate', $record->id), 403, 'Aprovador revogado ou com conflito.');
|
||||
$p = $snapshot['payload'];
|
||||
if (! empty($p['review_due_date'])) {
|
||||
abort_unless($p['review_due_date'] > today()->toDateString(), 422, 'Data de revisão deve ser futura.');
|
||||
}
|
||||
if (isset($p['business_transaction'])) {
|
||||
abort_unless(in_array($p['business_transaction']['due_diligence_status'], ['data_room_ready', 'in_progress', 'completed', 'exceptions'], true), 422, 'Data room mínimo não preparado.');
|
||||
}
|
||||
if (isset($context['publication'])) {
|
||||
$context['publication_history'][] = $context['publication'];
|
||||
}
|
||||
$context['publication'] = [...$decision, 'hash' => $snapshot['hash'], 'visibility' => $p['visibility'],
|
||||
'public_fields' => ['title', 'summary', 'description', 'sector_id', 'province', 'district']];
|
||||
// Minimal public projection; contacts, valuations, evidence and originals remain private.
|
||||
$projection = $this->contract->publicProjection($p);
|
||||
$record->title = $projection['title'];
|
||||
$record->summary = $projection['summary'];
|
||||
$record->description = $projection['description'];
|
||||
$record->sector_id = $p['sector_id'];
|
||||
$locations = array_values(array_filter($snapshot['resources']['locations'], fn ($location) => $location['payload']['is_primary'] ?? false));
|
||||
$location = $locations[0]; // The contract requires exactly one primary location.
|
||||
$path = app(InvestmentGeography::class)->selection($location['payload'], true);
|
||||
$last = array_key_last($path);
|
||||
abort_unless($last !== null, 422, 'Localização principal sem hierarquia.');
|
||||
$record->primary_territory_id = $path[$last]->id;
|
||||
$record->province = $path[0]->name;
|
||||
$record->district = $path[1]->name;
|
||||
$record->geography_scope = $p['geographic_scope'] === 'national' ? 'national' : 'specific';
|
||||
$record->published_at = now();
|
||||
$record->status = 'published';
|
||||
$next = 'published';
|
||||
$this->tasks->complete($context['publication_task_id'] ?? null, $data['reason']);
|
||||
} elseif ($action === 'pending_opinion') {
|
||||
$gate = $data['gate'] ?? '';
|
||||
abort_unless(in_array($gate, $this->contract->gates($record), true), 422, 'Indique a revisão aplicável ao parecer.');
|
||||
$subject = User::whereKey($data['recipient_user_id'] ?? 0)->firstOrFail();
|
||||
abort_unless($this->access->scoped($subject, 'validator', $record->organization_id, $record->opportunity_category)
|
||||
&& $this->access->operational($subject, 'validate', $record->id) && ! $this->access->conflict($subject, $record) && $subject->two_factor_confirmed_at !== null
|
||||
&& $this->responsibility($subject, $record, preg_match('/legal|registry|authority|confidentiality|license/', $gate) === 1 ? 'legal_reviewer' : 'technical_reviewer'), 403, 'Destinatário exige responsabilidade, MFA e independência.');
|
||||
abort_if($subject->id === $actor->id, 422, 'O parecer deve ser solicitado a outro revisor.');
|
||||
$opinionId = (string) Str::uuid();
|
||||
$taskId = $this->tasks->ensure($record, 'opportunity_opinion:'.$opinionId, 'Parecer da oportunidade '.$record->reference);
|
||||
$this->tasks->assign($record, $taskId, $subject);
|
||||
$context['opinions'][$opinionId] = [...$decision, 'id' => $opinionId, 'recipient_id' => $subject->id, 'gate' => $gate, 'status' => 'pending', 'hash' => $snapshot['hash'], 'task_id' => $taskId];
|
||||
$next = 'information_pending';
|
||||
} elseif ($action === 'respond_opinion') {
|
||||
$opinionId = $data['opinion_id'] ?? '';
|
||||
$opinion = $context['opinions'][$opinionId] ?? [];
|
||||
abort_unless(($opinion['recipient_id'] ?? 0) === $actor->id, 403, 'Parecer atribuído a outro revisor.');
|
||||
abort_unless($this->responsibility($actor, $record, preg_match('/legal|registry|authority|confidentiality|license/', $opinion['gate'] ?? '') === 1 ? 'legal_reviewer' : 'technical_reviewer'), 403, 'Responsabilidade do parecer revogada.');
|
||||
abort_unless(($opinion['status'] ?? '') === 'pending' && ($opinion['hash'] ?? '') === $snapshot['hash'], 409, 'Parecer encerrado ou de outra versão.');
|
||||
$documents = $data['evidence_document_ids'] ?? [];
|
||||
abort_unless(isset($data['gate_decision']) && $documents !== [] && array_diff($documents, array_keys($snapshot['resources']['documents'] ?? [])) === [], 422, 'Resposta exige decisão e documentos desta versão.');
|
||||
$context['opinions'][$opinionId]['status'] = 'answered';
|
||||
$context['opinions'][$opinionId]['response'] = [...$decision, 'decision' => $data['gate_decision'], 'evidence_document_ids' => $documents];
|
||||
$this->tasks->complete($opinion['task_id'], $data['reason']);
|
||||
$next = count(array_filter($context['opinions'], fn ($o) => ($o['hash'] ?? '') === $snapshot['hash'] && ($o['status'] ?? '') === 'pending')) > 0 ? 'information_pending' : 'in_review';
|
||||
} elseif ($action === 'request_correction') {
|
||||
abort_unless($data['correction_items'] ?? [], 422, 'Indique campos e documentos a corrigir.');
|
||||
$this->tasks->complete($context['review_task_id'] ?? null, $data['reason']);
|
||||
$context['correction_items'] = $data['correction_items'];
|
||||
$context['correction_cycles'] = ($context['correction_cycles'] ?? 0) + 1;
|
||||
$record->workflow_context = $context;
|
||||
$context['correction_task_id'] = $this->tasks->ensure($record, 'opportunity_correction', 'Correções da oportunidade '.$record->reference);
|
||||
$next = 'needs_information';
|
||||
} elseif ($action === 'request_revision' || $action === 'appeal_reopen') {
|
||||
$this->tasks->complete($context['review_task_id'] ?? null, $data['reason']);
|
||||
$this->tasks->complete($context['publication_task_id'] ?? null, $data['reason']);
|
||||
$context['decision_history'][] = ['approval' => $context['approval'] ?? null, 'reviews' => $context['reviews'] ?? null, 'submission' => $context['submission'] ?? null];
|
||||
$context['review_baseline'] = $context['submission'] ?? [];
|
||||
$context['force_review'] = $action === 'appeal_reopen' || $state === 'suspended';
|
||||
unset($context['approval']);
|
||||
$next = 'needs_information';
|
||||
} elseif ($action === 'request_archive') {
|
||||
$context['request_archive'] = $decision;
|
||||
} elseif ($action === 'appeal') {
|
||||
abort_if($context['appeal']['pending'] ?? false, 409, 'Recurso já pendente.');
|
||||
$context['appeal'] = [...$decision, 'pending' => true];
|
||||
$context['appeal_task_id'] = $this->tasks->ensure($record, 'opportunity_appeal', 'Recurso da oportunidade '.$record->reference);
|
||||
} elseif ($action === 'appeal_uphold') {
|
||||
$next = 'rejected';
|
||||
} else {
|
||||
$next = match ($action) {
|
||||
'reject' => 'rejected', 'suspend' => 'suspended', 'archive' => 'archived'
|
||||
};
|
||||
if ($action === 'reject') {
|
||||
$context['rejection'] = $decision;
|
||||
$this->tasks->complete($context['review_task_id'] ?? null, $data['reason']);
|
||||
}
|
||||
if ($action === 'archive') {
|
||||
$context['archive'] = $decision;
|
||||
}
|
||||
if (in_array($action, ['suspend', 'archive'], true)) {
|
||||
$record->status = $next;
|
||||
foreach (['review_task_id', 'correction_task_id', 'publication_task_id', 'appeal_task_id'] as $task) {
|
||||
$this->tasks->complete($context[$task] ?? null, $data['reason']);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (in_array($action, ['appeal_uphold', 'appeal_reopen'], true)) {
|
||||
$context['appeal']['pending'] = false;
|
||||
$context['appeal']['decision'] = $decision;
|
||||
$this->tasks->complete($context['appeal_task_id'] ?? null, $data['reason']);
|
||||
}
|
||||
if (in_array($action, ['request_correction', 'reject'], true)) {
|
||||
if ($action === 'reject') {
|
||||
$context['force_review'] = true;
|
||||
}
|
||||
unset($context['approval']);
|
||||
}
|
||||
if (in_array($action, ['request_correction', 'reject', 'suspend', 'archive', 'request_revision', 'appeal_reopen'], true)) {
|
||||
foreach ($context['opinions'] ?? [] as $opinionId => $opinion) {
|
||||
if (($opinion['status'] ?? '') === 'pending') {
|
||||
$context['opinions'][$opinionId]['status'] = 'superseded';
|
||||
$this->tasks->complete($opinion['task_id'] ?? null, $data['reason']);
|
||||
}
|
||||
}
|
||||
}
|
||||
$context['working_state'] = $next;
|
||||
$context['last_decision'] = $decision;
|
||||
$context['events'][] = [...$decision, 'from' => $state, 'to' => $next];
|
||||
if ($record->status !== 'published' || in_array($action, ['suspend', 'archive'], true)) {
|
||||
$record->status = $next;
|
||||
}
|
||||
$record->management_version++;
|
||||
$record->workflow_context = $context;
|
||||
$record->save();
|
||||
$this->access->audit($actor, 'workflow_'.$action, ['record_id' => $record->id, 'before' => $before,
|
||||
'after' => ['status' => $next, 'publication_status' => $record->status, 'version' => $record->management_version], 'reason' => $data['reason']]);
|
||||
|
||||
return $record;
|
||||
});
|
||||
}
|
||||
|
||||
/** @param array<array-key, mixed> $context */
|
||||
private function submissionCount(array $context): int
|
||||
{
|
||||
$events = $context['events'] ?? [];
|
||||
abort_unless(is_array($events), 409, 'Histórico de submissões inconsistente; preservar e recuperar antes de continuar.');
|
||||
$count = 0;
|
||||
foreach ($events as $event) {
|
||||
if (is_array($event) && ($event['action'] ?? null) === 'submit') {
|
||||
$count++;
|
||||
}
|
||||
}
|
||||
|
||||
return $count;
|
||||
}
|
||||
|
||||
private function responsibility(User $actor, Opportunity $record, string $name): bool
|
||||
{
|
||||
foreach ($this->access->grants($actor, $name === 'publication_coordinator' ? 'publisher' : 'validator') as $grant) {
|
||||
if (($grant->organization_id === null || $grant->organization_id === $record->organization_id)
|
||||
&& in_array($record->opportunity_category, json_decode($grant->opportunity_types, true), true)
|
||||
&& in_array($name, json_decode($grant->responsibilities, true), true)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private function authorizeAction(User $actor, Opportunity $record, string $action): void
|
||||
{
|
||||
$this->access->authorize($actor, 'view', $record);
|
||||
$promoter = $this->access->scoped($actor, 'promoter', $record->organization_id, $record->opportunity_category)
|
||||
&& ($record->organization_id !== null || (int) $record->owner_user_id === $actor->id);
|
||||
if (in_array($action, ['submit', 'request_archive', 'appeal', 'request_revision'], true)) {
|
||||
abort_unless($promoter && $this->access->operational($actor, 'edit', $record->id), 403);
|
||||
} else {
|
||||
$role = in_array($action, ['publish', 'assign_publication', 'suspend', 'archive'], true) ? 'publisher' : 'validator';
|
||||
$operation = $role === 'publisher' ? (in_array($action, ['publish', 'assign_publication'], true) ? 'publish' : 'archive') : 'validate';
|
||||
abort_unless($this->access->scoped($actor, $role, $record->organization_id, $record->opportunity_category)
|
||||
&& $this->access->mfa($actor) && $this->access->operational($actor, $operation, $record->id) && ! $this->access->conflict($actor, $record), 403, 'Papel, MFA e independência necessários.');
|
||||
if ($action === 'publish') {
|
||||
abort_if((int) ($record->workflow_context['approval']['actor_id'] ?? 0) === $actor->id, 403, 'O aprovador não publica a mesma versão.');
|
||||
abort_if(isset($record->workflow_context['publication_assignment']['assignee_user_id']) && (int) $record->workflow_context['publication_assignment']['assignee_user_id'] !== $actor->id, 403, 'Publicação atribuída a outro Publicador; requer reatribuição explícita.');
|
||||
}
|
||||
if ($action === 'assign_publication') {
|
||||
abort_unless($this->responsibility($actor, $record, 'publication_coordinator'), 403);
|
||||
}
|
||||
if ($action === 'assign_review') {
|
||||
abort_unless($this->responsibility($actor, $record, 'validation_coordinator'), 403);
|
||||
}
|
||||
if (in_array($action, ['start_review', 'review_gate', 'request_correction', 'pending_opinion', 'reject', 'approve'], true)
|
||||
&& isset($record->workflow_context['assignment']['assignee_user_id'])) {
|
||||
abort_unless((int) $record->workflow_context['assignment']['assignee_user_id'] === $actor->id, 403, 'Tarefa atribuída a outro Validador; o coordenador deve registar a reatribuição.');
|
||||
}
|
||||
if (in_array($action, ['appeal_uphold', 'appeal_reopen'], true)) {
|
||||
abort_unless($this->responsibility($actor, $record, 'appeal_reviewer') && ($record->workflow_context['appeal']['pending'] ?? false)
|
||||
&& (int) ($record->workflow_context['rejection']['actor_id'] ?? 0) !== $actor->id, 403, 'Recurso exige instância independente da rejeição.');
|
||||
}
|
||||
if ($action === 'suspend') {
|
||||
abort_unless($record->status === 'published', 409);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+90
@@ -0,0 +1,90 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
use App\Models\Opportunity;
|
||||
use App\Models\User;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
|
||||
/** Explicit internal review conditions in the existing workflow JSON and audit. */
|
||||
class OpportunityReviewConditions
|
||||
{
|
||||
/** @param array<string,mixed> $data
|
||||
* @param array<string,mixed> $snapshot
|
||||
* @param array<string,mixed> $context */
|
||||
public function review(Opportunity $record, User $actor, array $data, array $snapshot, array &$context): void
|
||||
{
|
||||
$gate = $data['gate'];
|
||||
foreach ($data['resolve_condition_ids'] ?? [] as $id) {
|
||||
$condition = $context['conditions'][$id] ?? null;
|
||||
$this->require($condition !== null && $condition['gate'] === $gate && $condition['status'] === 'open', 'resolve_condition_ids', 'Selecione uma condição aberta desta revisão.');
|
||||
$this->require(($data['gate_decision'] ?? '') === 'approved', 'gate_decision', 'A resolução exige verificação interna aprovada com evidência.');
|
||||
$documents = [];
|
||||
foreach ($data['evidence_document_ids'] ?? [] as $documentId) {
|
||||
$documents[$documentId] = $snapshot['resources']['documents'][$documentId]['sha256'];
|
||||
}
|
||||
$this->require($documents !== [], 'evidence_document_ids', 'A resolução exige documento ativo e analisado desta oportunidade.');
|
||||
$context['conditions'][$id]['status'] = 'resolved';
|
||||
$context['conditions'][$id]['resolution'] = ['actor_id' => $actor->id, 'at' => now()->toIso8601String(), 'reason' => $data['reason'], 'document_hashes' => $documents, 'content_revision' => $context['content_revision'] ?? 1, 'scope' => 'internal_verification_not_external_decision'];
|
||||
}
|
||||
if (! empty($data['condition'])) {
|
||||
$input = $data['condition'];
|
||||
$subject = User::query()->whereKey($input['responsible_user_id'])->first();
|
||||
$access = app(PortalProfileAccess::class);
|
||||
$this->require($subject !== null && $access->canView($subject, $record)
|
||||
&& (($access->scoped($subject, 'promoter', $record->organization_id, $record->opportunity_category) && $access->operational($subject, 'edit', $record->id))
|
||||
|| ($access->scoped($subject, 'validator', $record->organization_id, $record->opportunity_category) && $access->operational($subject, 'validate', $record->id))),
|
||||
'condition.responsible_user_id', 'Selecione um responsável autorizado neste âmbito; não atribua responsabilidade externa.');
|
||||
$id = (string) Str::uuid();
|
||||
$context['conditions'][$id] = ['id' => $id, 'gate' => $gate, 'description' => $input['description'], 'responsible_user_id' => $subject->id,
|
||||
'responsible_name' => $subject->name, 'due_on' => $input['due_on'] ?? null, 'blocking_action' => $input['blocking_action'],
|
||||
'status' => 'open', 'created_by' => $actor->id, 'created_at' => now()->toIso8601String(), 'scope' => 'internal_review_condition', 'resolution_history' => []];
|
||||
}
|
||||
}
|
||||
|
||||
/** @param array<string,mixed> $context
|
||||
* @param array<string,mixed> $snapshot
|
||||
* @param list<string> $reopened */
|
||||
public function reconcile(array &$context, array $snapshot, array $reopened): void
|
||||
{
|
||||
foreach ($context['conditions'] ?? [] as $id => $condition) {
|
||||
if ($condition['status'] !== 'resolved') {
|
||||
continue;
|
||||
}
|
||||
$matches = ! in_array($condition['gate'], $reopened, true);
|
||||
foreach ($condition['resolution']['document_hashes'] ?? [] as $documentId => $sha) {
|
||||
$matches = $matches && ($snapshot['resources']['documents'][$documentId]['sha256'] ?? null) === $sha;
|
||||
}
|
||||
if (! $matches) {
|
||||
$context['conditions'][$id]['resolution_history'][] = $condition['resolution'];
|
||||
unset($context['conditions'][$id]['resolution']);
|
||||
$context['conditions'][$id]['status'] = 'open';
|
||||
$context['conditions'][$id]['reopened_at'] = now()->toIso8601String();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** @param array<string,mixed> $context
|
||||
* @param array<string,mixed> $snapshot */
|
||||
public function authorize(array $context, array $snapshot, string $action): void
|
||||
{
|
||||
foreach ($context['conditions'] ?? [] as $condition) {
|
||||
if ($action === 'approve' && $condition['blocking_action'] !== 'approve') {
|
||||
continue;
|
||||
}
|
||||
$resolved = $condition['status'] === 'resolved';
|
||||
foreach ($condition['resolution']['document_hashes'] ?? [] as $id => $sha) {
|
||||
$resolved = $resolved && ($snapshot['resources']['documents'][$id]['sha256'] ?? null) === $sha;
|
||||
}
|
||||
$this->require($resolved, 'conditions.'.$condition['id'], 'Condição pendente: '.$condition['description'].'. Responsável: '.$condition['responsible_name'].'. Prazo: '.($condition['due_on'] ?? 'não definido').'.');
|
||||
}
|
||||
}
|
||||
|
||||
private function require(bool $ok, string $field, string $message): void
|
||||
{
|
||||
if (! $ok) {
|
||||
throw ValidationException::withMessages([$field => $message]);
|
||||
}
|
||||
}
|
||||
}
|
||||
+166
@@ -0,0 +1,166 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
use Illuminate\Support\Arr;
|
||||
|
||||
/** §28.1: preserve signed decisions; only changed review scopes need new decisions. */
|
||||
class OpportunityReviewMateriality
|
||||
{
|
||||
public const VERSION = 'review-scopes-20261011-v3';
|
||||
|
||||
public const PREVIOUS_VERSION = 'review-scopes-20261011-v2';
|
||||
|
||||
/** @param array<string,mixed> $snapshot
|
||||
* @return array<string,mixed> */
|
||||
private function scope(array $snapshot, string $gate, bool $extended = true): array
|
||||
{
|
||||
$p = $snapshot['payload'] ?? [];
|
||||
$common = ['opportunity_category', 'promoter_id', 'promoter_type', 'sector_id', 'subsector_id', 'economic_activity_id', 'demand_statement', 'executive_summary'];
|
||||
$fields = match ($gate) {
|
||||
'property_review' => ['real_estate.property_type', 'real_estate.land_area', 'real_estate.built_area', 'real_estate.area_unit', 'real_estate.units', 'real_estate.occupancy_status', 'real_estate.price', 'real_estate.rent', 'real_estate.rent_periodicity', 'real_estate.valuation', 'real_estate.utilities'],
|
||||
'registry_urban_review' => ['real_estate.transaction_type', 'real_estate.title_type', 'real_estate.registration_number', 'real_estate.encumbrances', 'real_estate.land_area', 'real_estate.area_unit'],
|
||||
'building_compliance_review' => ['real_estate.construction_status', 'real_estate.property_condition', 'real_estate.built_area', 'real_estate.floors', 'real_estate.planning_permit_document_id', 'real_estate.use_license_document_id'],
|
||||
'cadastral_screening' => ['land_rights.parcels', 'land_rights.overlaps_conflicts'],
|
||||
'land_legal_review' => ['land_rights.operation_type', 'land_rights.duat_status', 'land_rights.duat_number', 'land_rights.holder_id', 'land_rights.holder_name', 'land_rights.issuing_authority_id', 'land_rights.issue_date', 'land_rights.expiry_date', 'land_rights.authorized_purpose', 'land_rights.improvements', 'land_rights.consideration'],
|
||||
'community_environment_review' => ['land_rights.communities', 'land_rights.community_consultation', 'environmental_social'],
|
||||
'competent_authority_clearance' => ['land_rights.required_authorizations', 'land_rights.exploitation_plan_document_id', 'land_rights.authorized_purpose'],
|
||||
'corporate_screening' => ['business_transaction.legal_entity_id', 'business_transaction.legal_form', 'business_transaction.beneficial_owners', 'business_transaction.percentage_offered'],
|
||||
'financial_review' => ['business_transaction.asking_price', 'business_transaction.valuation', 'business_transaction.financial_periods', 'business_transaction.assets_liabilities', 'business_transaction.employees', 'business_transaction.partner_contribution'],
|
||||
'legal_tax_due_diligence' => ['business_transaction.transaction_type', 'business_transaction.percentage_offered', 'business_transaction.contracts_licenses', 'business_transaction.litigation_contingencies', 'business_transaction.governance_rights', 'business_transaction.franchise_terms', 'business_transaction.tax_labor_compliance'],
|
||||
'partnership_governance_review' => ['business_transaction.percentage_offered', 'business_transaction.partner_contribution', 'business_transaction.governance_rights'],
|
||||
'brand_license_review' => ['business_transaction.franchise_terms', 'business_transaction.contracts_licenses'],
|
||||
'franchise_legal_review' => ['business_transaction.franchise_terms', 'business_transaction.contracts_licenses', 'business_transaction.litigation_contingencies'],
|
||||
'confidentiality_clearance' => ['visibility', 'publish_contact', 'public_contact_id', 'business_transaction.confidentiality_level', 'business_transaction.teaser', 'business_transaction.nda_document_id', 'business_transaction.data_room_index_document_id'],
|
||||
'technical_review' => ['demand_statement', 'opportunity_type', 'maturity_stage', 'investment_modalities', 'investor_profiles', 'products', 'assets', 'inputs', 'markets', 'competitive_advantage', 'employment', 'impact_indicators', 'total_investment', 'currency', 'investment_breakdown', 'secured_financing', 'funding_sought', 'financial_indicators', 'milestones', 'risks'],
|
||||
'legal_territorial_review' => ['licenses', 'environmental_social', 'relations', 'truth_declaration'],
|
||||
// Experimental modules have no approved scope contract: never carry their decisions.
|
||||
default => array_keys($p),
|
||||
};
|
||||
if ($extended) {
|
||||
$fields = [...$fields, ...match ($gate) {
|
||||
'land_legal_review' => ['land_rights.holder_document_id', 'land_rights.area_unit'],
|
||||
'community_environment_review' => ['land_rights.communities_affected'],
|
||||
'competent_authority_clearance' => ['land_rights.exploitation_plan_required'],
|
||||
'corporate_screening' => ['business_transaction.entity_registration'],
|
||||
'financial_review' => ['business_transaction.available_financial_years', 'business_transaction.history_status', 'business_transaction.history_declaration', 'business_transaction.history_declaration_document_id', 'business_transaction.projections'],
|
||||
'franchise_legal_review' => ['business_transaction.legal_entity_id', 'business_transaction.legal_form', 'business_transaction.beneficial_owners', 'business_transaction.entity_registration', 'business_transaction.governance_rights', 'business_transaction.tax_labor_compliance'],
|
||||
'confidentiality_clearance' => ['internal_contact_id'],
|
||||
default => [],
|
||||
}];
|
||||
}
|
||||
$data = [];
|
||||
foreach ([...$common, ...$fields] as $field) {
|
||||
if (! is_string($field)) {
|
||||
throw new \UnexpectedValueException('Canonical review fields must be named fields.');
|
||||
}
|
||||
$data[$field] = Arr::get($p, $field);
|
||||
}
|
||||
// Explicitly unclassified specialised fields conservatively reopen reviews.
|
||||
// They cannot silently become immaterial when a schema gains a new field.
|
||||
$classified = match ($p['opportunity_category'] ?? '') {
|
||||
'real_estate' => ['transaction_type', 'property_type', 'construction_status', 'property_condition', 'land_area', 'built_area', 'area_unit', 'units', 'rooms', 'floors', 'amenities', 'utilities', 'occupancy_status', 'title_type', 'registration_number', 'encumbrances', 'price', 'rent', 'rent_periodicity', 'deposit', 'valuation', 'viewing', 'planning_permit_document_id', 'use_license_document_id', 'title_document_id', 'title_holder_name', 'issuing_authority_id', 'expected_completion_date', 'occupancy_details', 'occupancy_document_id', 'amenities_other', 'urban_limit_document_id', 'max_built_area'],
|
||||
default => [],
|
||||
};
|
||||
if ($classified !== []) {
|
||||
$data['unclassified_module_fields'] = array_diff_key($p['real_estate'] ?? [], array_flip($classified));
|
||||
}
|
||||
if ($gate === 'property_review') {
|
||||
foreach (['rooms', 'amenities', 'deposit', 'occupancy_details', 'occupancy_document_id', 'amenities_other'] as $key) {
|
||||
$data['real_estate.'.$key] = Arr::get($p, 'real_estate.'.$key);
|
||||
}
|
||||
}
|
||||
if ($gate === 'registry_urban_review') {
|
||||
foreach (['title_document_id', 'title_holder_name', 'issuing_authority_id', 'urban_limit_document_id', 'max_built_area'] as $key) {
|
||||
$data['real_estate.'.$key] = Arr::get($p, 'real_estate.'.$key);
|
||||
}
|
||||
}
|
||||
if ($gate === 'building_compliance_review') {
|
||||
$data['real_estate.expected_completion_date'] = Arr::get($p, 'real_estate.expected_completion_date');
|
||||
}
|
||||
|
||||
// A changed evidence file always invalidates a decision relying on it.
|
||||
// Unrelated documents/images and editorial timestamps are not review evidence.
|
||||
return $data;
|
||||
}
|
||||
|
||||
/** @param array<string,mixed> $snapshot
|
||||
* @param array<string,mixed> $review */
|
||||
public function hash(array $snapshot, string $gate, array $review = [], bool $legacy = false, ?string $rule = null): string
|
||||
{
|
||||
$extended = ! $legacy && ($rule ?? self::VERSION) !== self::PREVIOUS_VERSION;
|
||||
$data = $this->scope($snapshot, $gate, $extended);
|
||||
$locationGates = ['registry_urban_review', 'cadastral_screening', 'legal_territorial_review', 'property_review'];
|
||||
if (! $legacy) {
|
||||
$locationGates = [...$locationGates, 'land_legal_review', 'community_environment_review', 'competent_authority_clearance'];
|
||||
}
|
||||
if (in_array($gate, $locationGates, true)) {
|
||||
$data['locations'] = array_map(fn ($r) => $r['payload'], $snapshot['resources']['locations'] ?? []);
|
||||
}
|
||||
foreach ($review['evidence_document_ids'] ?? [] as $id) {
|
||||
$r = $snapshot['resources']['documents'][$id] ?? null;
|
||||
$data['evidence'][$id] = $r ? ['sha256' => $r['sha256'] ?? null, 'payload' => $r['payload'] ?? [], 'deleted_at' => $r['deleted_at'] ?? null] : null;
|
||||
}
|
||||
|
||||
if ($extended) {
|
||||
// Nested references are part of the decision even when the reviewer
|
||||
// selected a different supporting file. Preserve the original bytes.
|
||||
$referenced = function (array $node) use (&$referenced, &$data, $snapshot): void {
|
||||
foreach ($node as $key => $value) {
|
||||
if (is_array($value)) {
|
||||
$referenced($value);
|
||||
} elseif (is_string($key) && is_string($value) && $value !== '' && (str_ends_with($key, 'document_id') || $key === 'image_id')) {
|
||||
$kind = $key === 'image_id' ? 'images' : 'documents';
|
||||
$resource = $snapshot['resources'][$kind][$value] ?? null;
|
||||
$data['referenced_resources'][$kind][$value] = $resource ? ['sha256' => $resource['sha256'] ?? null, 'payload' => $resource['payload'] ?? [], 'deleted_at' => $resource['deleted_at'] ?? null] : null;
|
||||
}
|
||||
}
|
||||
};
|
||||
$referenced($data);
|
||||
}
|
||||
|
||||
return $legacy ? hash('sha256', json_encode(Arr::sortRecursive($data), JSON_THROW_ON_ERROR)) : OpportunityCanonicalValue::hash($data);
|
||||
}
|
||||
|
||||
/** @param array<string,mixed> $snapshot
|
||||
* @param array<string,mixed> $review */
|
||||
public function matches(array $snapshot, string $gate, array $review): bool
|
||||
{
|
||||
if (! isset($review['scope_hash'])) {
|
||||
return true; // Caller must independently verify the original signed submission hash.
|
||||
}
|
||||
$rule = $review['scope_rule'] ?? '';
|
||||
$legacy = ! in_array($rule, [self::VERSION, self::PREVIOUS_VERSION], true);
|
||||
$expected = $this->hash($snapshot, $gate, $review, $legacy, $rule);
|
||||
|
||||
return hash_equals($review['scope_hash'], $expected);
|
||||
}
|
||||
|
||||
/** @param array<string,mixed> $before
|
||||
* @param array<string,mixed> $after
|
||||
* @param array<string,mixed> $reviews
|
||||
* @param list<string> $gates
|
||||
* @return array<string,mixed> */
|
||||
public function reconcile(array $before, array $after, array $reviews, array $gates, bool $force = false): array
|
||||
{
|
||||
$kept = [];
|
||||
$reopened = [];
|
||||
foreach ($gates as $gate) {
|
||||
$review = $reviews[$gate] ?? [];
|
||||
// Compare the signed baseline and new content with the new scope;
|
||||
// separately validate old scope signatures under their original rule.
|
||||
$priorHash = $this->hash($before, $gate, $review);
|
||||
$currentHash = $this->hash($after, $gate, $review);
|
||||
if (! $force && $before !== [] && ($review['decision'] ?? '') === 'approved' && $this->matches($before, $gate, $review) && hash_equals($priorHash, $currentHash)) {
|
||||
$kept[$gate] = [...$review, 'scope_hash' => $priorHash, 'scope_rule' => self::VERSION, 'accepted_submission_hash' => $after['hash'],
|
||||
'carried_forward' => ['rule' => self::VERSION, 'from_scope_hash' => $review['scope_hash'] ?? null, 'from_scope_rule' => $review['scope_rule'] ?? 'legacy_unspecified', 'from_submission_hash' => $before['hash'] ?? null, 'at' => now()->toIso8601String()]];
|
||||
} else {
|
||||
$reopened[] = $gate;
|
||||
}
|
||||
}
|
||||
|
||||
return ['rule' => self::VERSION, 'reviews' => $kept, 'reopened' => $reopened, 'retained' => array_keys($kept),
|
||||
'reason' => $force ? 'Suspensão, rejeição ou recurso exige nova decisão; motivo anterior preservado.' : 'Comparação dos campos e evidências aplicáveis a cada revisão (§28.1).',
|
||||
'final_approval' => 'Nova assinatura independente da versão; nenhum parecer ou decisão externa inventado.'];
|
||||
}
|
||||
}
|
||||
+274
@@ -0,0 +1,274 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
use App\Models\Opportunity;
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class PortalProfileAccess
|
||||
{
|
||||
public const VERSION = 'profiles-v1-20261010';
|
||||
|
||||
/** @return list<string> */
|
||||
public static function fingerprintFiles(): array
|
||||
{
|
||||
return [__FILE__, app_path('Models/User.php'), app_path('Models/Opportunity.php'), config_path('portal.php'), base_path('routes/web.php'),
|
||||
app_path('Http/Middleware/HandleInertiaRequests.php'), app_path('Services/OpportunityManagement.php'),
|
||||
app_path('Services/OpportunityResources.php'), app_path('Services/OpportunityImageProcessor.php'), app_path('Services/VerifiedDocumentBinary.php'),
|
||||
app_path('Services/PortalProfileAdministration.php'), app_path('Services/PortalSuperusers.php'),
|
||||
app_path('Services/OpportunityProfileWorkflow.php'), app_path('Http/Controllers/PortalProfileController.php'), app_path('Http/Controllers/DashboardController.php'),
|
||||
app_path('Http/Controllers/OpportunityManagementController.php'),
|
||||
app_path('Services/OpportunityCanonicalContract.php'), app_path('Services/OpportunityCanonicalResponse.php'), app_path('Services/OpportunityCategoryFields.php'), app_path('Services/OpportunityModularProfiles.php'), app_path('Services/OpportunityWorkflowTasks.php'), base_path('composer.json'), base_path('composer.lock'),
|
||||
app_path('Services/OpportunityReviewMateriality.php'), app_path('Services/OpportunityReviewConditions.php'), app_path('Services/OpportunityCanonicalMetadata.php'), app_path('Services/OpportunityCompleteness.php'), app_path('Services/OpportunityCanonicalValue.php'),
|
||||
resource_path('data/investmoz-opportunity-modular.schema.json'), resource_path('js/components/opportunity-canonical-fields.tsx'), resource_path('js/components/opportunity-parcel-geometry.tsx'),
|
||||
app_path('Http/Controllers/OpportunityResourceController.php'),
|
||||
app_path('Http/Controllers/InvestmentTerritoryController.php'),
|
||||
app_path('Http/Middleware/PortalProfileSession.php'), app_path('Http/Middleware/ProtectProfileOpportunity.php'),
|
||||
app_path('Http/Middleware/ProtectPrivilegedIdentity.php'), app_path('Http/Middleware/EnsurePortalProfiles.php'),
|
||||
app_path('Http/Middleware/AuditProfileDecision.php'), app_path('Providers/AppServiceProvider.php'),
|
||||
database_path('migrations/2026_10_10_040000_create_portal_profile_authorization.php'), base_path('bootstrap/app.php'),
|
||||
resource_path('js/pages/profiles/request.tsx'), resource_path('js/pages/profiles/administration.tsx'), resource_path('js/pages/profiles/audit.tsx'),
|
||||
resource_path('js/components/profile-navigation.tsx'), resource_path('js/components/opportunity-profile-actions.tsx'),
|
||||
resource_path('js/components/portal-grouped-menu.tsx'), resource_path('js/components/user-menu-content.tsx'),
|
||||
resource_path('js/pages/management/opportunities.tsx'), resource_path('js/pages/management/opportunity-draft.tsx'),
|
||||
resource_path('js/types/profile-access.ts'), resource_path('js/lib/profile-json.ts'), resource_path('js/pages/management/shared.tsx'),
|
||||
resource_path('js/pages/dashboard.tsx'), resource_path('js/pages/PortalInvestidor.tsx'),
|
||||
resource_path('js/layouts/portal-navigation.tsx'), resource_path('js/components/interactive-investment-map.tsx'),
|
||||
resource_path('js/components/simulation-form.tsx'), resource_path('js/lib/simulation-form.ts'), app_path('Services/LegacyContent.php'),
|
||||
resource_path('js/components/ui/sidebar.tsx'), resource_path('js/components/simulation-financial-tools.tsx'), resource_path('js/components/simulation-cashflow-planner.tsx'), resource_path('js/pages/investor-path/show.tsx'), resource_path('views/app.blade.php'),
|
||||
resource_path('js/pages/management/opportunity-resources.tsx'),
|
||||
app_path('Services/PortalProfileInstallation.php'), app_path('Http/Controllers/PortalProfileInstallationController.php'), config_path('portal_profiles.php'), resource_path('js/pages/profiles/installation.tsx')];
|
||||
}
|
||||
|
||||
public function available(): bool
|
||||
{
|
||||
return config('portal.profile_access_enabled') && Schema::hasTable('portal_role_assignments')
|
||||
&& Schema::hasTable('portal_superuser_pair') && Schema::hasTable('portal_profile_requests')
|
||||
&& Schema::hasTable('portal_security_approvals') && Schema::hasColumn('users', 'portal_access_revision')
|
||||
&& Schema::hasColumn('opportunities', 'workflow_context') && Schema::hasColumn('opportunities', 'owner_user_id')
|
||||
&& Schema::hasColumn('opportunities', 'organization_id');
|
||||
}
|
||||
|
||||
/** @return list<\stdClass> */
|
||||
public function grants(User $actor, ?string $role = null): array
|
||||
{
|
||||
if (! $this->available() || ! $actor->hasVerifiedEmail()) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return array_values(DB::table('portal_role_assignments')->where('user_id', $actor->id)->whereNull('revoked_at')->where('starts_at', '<=', now())
|
||||
->where(fn ($q) => $q->whereNull('expires_at')->orWhere('expires_at', '>', now()))->when($role, fn ($q) => $q->where('role', $role))->get()->all());
|
||||
}
|
||||
|
||||
public function has(User $actor, string $role): bool
|
||||
{
|
||||
return $role === 'superuser' ? $this->superuser($actor) : $this->grants($actor, $role) !== [];
|
||||
}
|
||||
|
||||
public function superuser(User $actor): bool
|
||||
{
|
||||
return $this->available() && $actor->hasVerifiedEmail() && DB::table('portal_superuser_pair')->where('id', 1)
|
||||
->where(fn ($q) => $q->where('first_user_id', $actor->id)->orWhere('second_user_id', $actor->id))->exists();
|
||||
}
|
||||
|
||||
public function represents(User $actor, ?string $organization): bool
|
||||
{
|
||||
return $organization === null || DB::table('memberships as m')->join('organizations as o', 'o.id', '=', 'm.organization_id')
|
||||
->where('m.user_id', $actor->id)->where('m.organization_id', $organization)
|
||||
->whereNull('m.deleted_at')->whereNull('o.deleted_at')->whereIn('m.role', ['admin', 'manager', 'officer'])->exists();
|
||||
}
|
||||
|
||||
public function mfa(User $actor): bool
|
||||
{
|
||||
// Enrollment alone is insufficient: Fortify must have completed MFA in this session.
|
||||
return $actor->two_factor_confirmed_at !== null && $actor->two_factor_secret !== null
|
||||
&& session('login.id') === null && session('portal.mfa_actor') === $actor->id
|
||||
&& (int) session('portal.mfa_at', 0) >= time() - 900;
|
||||
}
|
||||
|
||||
public function scoped(User $actor, string $role, ?string $organization, string $type): bool
|
||||
{
|
||||
foreach ($this->grants($actor, $role) as $grant) {
|
||||
if (($grant->organization_id === $organization || ($role !== 'promoter' && $grant->organization_id === null))
|
||||
&& in_array($type, json_decode($grant->opportunity_types, true, 512, JSON_THROW_ON_ERROR), true)) {
|
||||
return $role !== 'promoter' || $this->represents($actor, $organization);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public function operational(User $actor, string $action, ?int $recordId = null): bool
|
||||
{
|
||||
if ($this->has($actor, 'auditor')) {
|
||||
return false;
|
||||
}
|
||||
if (! $this->superuser($actor)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return DB::table('portal_security_approvals')->where('kind', 'elevation')->where('subject_user_id', $actor->id)
|
||||
->whereNotNull('approved_by')->whereNull('consumed_at')->where('expires_at', '>', now())
|
||||
->whereExists(fn ($q) => $q->selectRaw('1')->from('portal_superuser_pair')
|
||||
->where(fn ($holders) => $holders->whereColumn('first_user_id', 'portal_security_approvals.approved_by')->orWhereColumn('second_user_id', 'portal_security_approvals.approved_by')))
|
||||
->where('scope->action', $action)->where('scope->record_id', $recordId)->exists();
|
||||
}
|
||||
|
||||
public function canCreate(User $actor, ?string $organization, string $type): bool
|
||||
{
|
||||
$included = in_array($type, OpportunityCanonicalContract::BASE_CATEGORIES, true) || app(OpportunityModularProfiles::class)->enabled();
|
||||
|
||||
return $included && $this->available() && $this->scoped($actor, 'promoter', $organization, $type) && $this->operational($actor, 'create');
|
||||
}
|
||||
|
||||
public function legacyWriteAllowed(User $actor): bool
|
||||
{
|
||||
// A deliberate v1 assignment cannot use the old allowlist to bypass its scope.
|
||||
if (! $actor->can('manage-portal')) {
|
||||
return false;
|
||||
}
|
||||
if (! Schema::hasTable('portal_role_assignments')) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Revocation/expiry must not silently restore an older, wider privilege.
|
||||
return ! DB::table('portal_role_assignments')->where('user_id', $actor->id)->exists()
|
||||
&& ! DB::table('portal_superuser_pair')->where(fn ($q) => $q->where('first_user_id', $actor->id)->orWhere('second_user_id', $actor->id))->exists()
|
||||
&& ! DB::table('portal_security_approvals')->where('kind', 'replacement')->whereNotNull('consumed_at')->where('scope->old_user_id', $actor->id)->exists();
|
||||
}
|
||||
|
||||
public function canView(User $actor, Opportunity $record): bool
|
||||
{
|
||||
if ($record->owner_user_id === null) {
|
||||
return $actor->can('manage-portal');
|
||||
}
|
||||
if (! $this->available() || ! $actor->hasVerifiedEmail()) {
|
||||
return false;
|
||||
}
|
||||
if ($this->has($actor, 'auditor') || $this->superuser($actor)) {
|
||||
return true;
|
||||
}
|
||||
$personal = $record->organization_id !== null || (int) $record->owner_user_id === $actor->id;
|
||||
|
||||
return ($personal && $this->scoped($actor, 'promoter', $record->organization_id, $record->opportunity_category))
|
||||
|| $this->scoped($actor, 'validator', $record->organization_id, $record->opportunity_category)
|
||||
|| $this->scoped($actor, 'publisher', $record->organization_id, $record->opportunity_category);
|
||||
}
|
||||
|
||||
public function canEdit(User $actor, Opportunity $record, ?string $newType = null): bool
|
||||
{
|
||||
if ($record->owner_user_id === null) {
|
||||
return $this->legacyWriteAllowed($actor);
|
||||
}
|
||||
|
||||
return $this->canView($actor, $record) && ! $record->trashed()
|
||||
&& in_array($this->state($record), ['draft', 'needs_information'], true)
|
||||
&& $this->scoped($actor, 'promoter', $record->organization_id, $newType ?? $record->opportunity_category)
|
||||
&& $this->operational($actor, 'edit', $record->id);
|
||||
}
|
||||
|
||||
public function conflict(User $actor, Opportunity $record): bool
|
||||
{
|
||||
$context = $record->workflow_context ?? [];
|
||||
|
||||
return (int) $record->owner_user_id === $actor->id || in_array($actor->id, $context['contributors'] ?? [], true)
|
||||
|| ($record->organization_id !== null && DB::table('memberships')->where('user_id', $actor->id)
|
||||
->where('organization_id', $record->organization_id)->whereNull('deleted_at')->exists());
|
||||
}
|
||||
|
||||
public function state(Opportunity $record): string
|
||||
{
|
||||
return $record->workflow_context['working_state'] ?? $record->status;
|
||||
}
|
||||
|
||||
public function authorize(User $actor, string $action, Opportunity $record): void
|
||||
{
|
||||
$allowed = $action === 'view' ? $this->canView($actor, $record) : $this->canEdit($actor, $record);
|
||||
if (! $allowed) {
|
||||
$this->audit($actor, 'access_denied', ['record_id' => $record->id, 'action' => $action]);
|
||||
}
|
||||
abort_unless($allowed, 403, 'O perfil, representação, tipo ou estado não autoriza esta operação.');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Builder<Opportunity> $query
|
||||
* @return Builder<Opportunity>
|
||||
*/
|
||||
public function scope(Builder $query, User $actor): Builder
|
||||
{
|
||||
if ($this->has($actor, 'auditor') || $this->superuser($actor)) {
|
||||
return $query;
|
||||
}
|
||||
|
||||
return $query->where(function ($scope) use ($actor) {
|
||||
$scope->whereRaw('1=0');
|
||||
if ($actor->can('manage-portal')) {
|
||||
$scope->orWhereNull('owner_user_id');
|
||||
}
|
||||
foreach ($this->grants($actor) as $grant) {
|
||||
if ($grant->role === 'promoter' && ! $this->represents($actor, $grant->organization_id)) {
|
||||
continue;
|
||||
}
|
||||
$scope->orWhere(function ($allowed) use ($actor, $grant) {
|
||||
$allowed->whereNotNull('owner_user_id')->whereIn('opportunity_category', json_decode($grant->opportunity_types, true, 512, JSON_THROW_ON_ERROR));
|
||||
if ($grant->organization_id !== null) {
|
||||
$allowed->where('organization_id', $grant->organization_id);
|
||||
} elseif ($grant->role === 'promoter') {
|
||||
$allowed->whereNull('organization_id')->where('owner_user_id', $actor->id);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/** @return array<string,mixed>|null */
|
||||
public function navigation(?User $actor): ?array
|
||||
{
|
||||
if (! $actor || ! $this->available() || ! $actor->hasVerifiedEmail()) {
|
||||
return null;
|
||||
}
|
||||
$contexts = [];
|
||||
$seen = [];
|
||||
foreach ($this->grants($actor, 'promoter') as $grant) {
|
||||
if (! $this->represents($actor, $grant->organization_id)) {
|
||||
continue;
|
||||
}
|
||||
foreach (json_decode($grant->opportunity_types, true, 512, JSON_THROW_ON_ERROR) as $type) {
|
||||
$key = ($grant->organization_id ?? 'individual').'|'.$type;
|
||||
if (! isset($seen[$key]) && $this->canCreate($actor, $grant->organization_id, $type)) {
|
||||
$contexts[] = ['organization_id' => $grant->organization_id, 'type' => $type];
|
||||
$seen[$key] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ['contexts' => $contexts, 'mine' => $contexts ? '/minhas-oportunidades' : null, 'create' => $contexts ? '/minhas-oportunidades/create' : null,
|
||||
'request' => '/perfil/promotor', 'review' => $this->has($actor, 'validator') || $this->has($actor, 'publisher') || $this->has($actor, 'auditor') || $this->superuser($actor) ? '/minhas-oportunidades' : null,
|
||||
'audit' => $this->has($actor, 'auditor') || $this->superuser($actor) ? '/perfis/auditoria' : null, 'administration' => $this->superuser($actor) ? '/perfis/gestao' : null];
|
||||
}
|
||||
|
||||
/** @param array<string,mixed> $data */
|
||||
public function audit(User $actor, string $action, array $data): void
|
||||
{
|
||||
DB::table('audit_events')->insert(['source_system' => 'portal-profiles-v1', 'entity_type' => 'authorization', 'actor_user_id' => $actor->id,
|
||||
'action' => $action, 'data_classification' => 'restricted', 'correlation_id' => (string) Str::uuid(),
|
||||
'after_data' => json_encode([...$data, 'policy_version' => self::VERSION, 'origin_ip' => request()->ip()], JSON_THROW_ON_ERROR)]);
|
||||
}
|
||||
|
||||
public function revokeSessions(User $subject): void
|
||||
{
|
||||
DB::table('users')->where('id', $subject->id)->increment('portal_access_revision');
|
||||
// Invalidate remember-me as well; no password or MFA changes.
|
||||
DB::table('users')->where('id', $subject->id)->update(['remember_token' => null]);
|
||||
if (Schema::hasTable('sessions')) {
|
||||
DB::table('sessions')->where('user_id', $subject->id)->delete();
|
||||
}
|
||||
if (Schema::hasTable('personal_access_tokens')) {
|
||||
DB::table('personal_access_tokens')->where('tokenable_type', User::class)->where('tokenable_id', $subject->id)->delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
+79
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
use Illuminate\Contracts\Encryption\DecryptException;
|
||||
use Illuminate\Http\Response;
|
||||
use Illuminate\Support\Facades\Crypt;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Symfony\Component\HttpFoundation\BinaryFileResponse;
|
||||
use Symfony\Component\HttpFoundation\HeaderUtils;
|
||||
|
||||
/** Authorization/publication stays with the consumer; originals share integrity and cipher handling. */
|
||||
class VerifiedDocumentBinary
|
||||
{
|
||||
public function respond(\stdClass $document, bool $inline = false): Response|BinaryFileResponse
|
||||
{
|
||||
$this->authorizeOpportunityAttachment($document);
|
||||
abort_unless($document->status === 'active' && $document->malware_scan_status === 'clean'
|
||||
&& ($document->deleted_at ?? null) === null && hash_equals(trim($document->sha256), trim((string) $document->malware_scanned_sha256)), 404);
|
||||
$disk = Storage::disk('local');
|
||||
$root = realpath($disk->path(''));
|
||||
$path = realpath($disk->path($document->storage_key));
|
||||
abort_unless($root && $path && str_starts_with(strtolower($path), strtolower($root.DIRECTORY_SEPARATOR)) && is_file($path), 404);
|
||||
$headers = ['X-Content-Type-Options' => 'nosniff', 'Cache-Control' => 'private, no-store'];
|
||||
if ($inline) {
|
||||
$headers['Content-Type'] = $document->media_type;
|
||||
$headers['Content-Security-Policy'] = "sandbox; default-src 'none'; style-src 'unsafe-inline'";
|
||||
}
|
||||
if (($document->storage_encryption ?? null) === 'laravel') {
|
||||
try {
|
||||
$bytes = Crypt::decryptString($disk->get($document->storage_key));
|
||||
} catch (DecryptException) {
|
||||
abort(404);
|
||||
}
|
||||
abort_unless(hash_equals(trim($document->sha256), hash('sha256', $bytes)), 404);
|
||||
$headers['Content-Type'] = $document->media_type;
|
||||
$headers['Content-Disposition'] = HeaderUtils::makeDisposition($inline ? 'inline' : 'attachment', basename($document->file_name), 'document');
|
||||
|
||||
return response($bytes, 200, $headers);
|
||||
}
|
||||
abort_unless(($document->storage_encryption ?? null) === null, 404);
|
||||
$checksum = hash_file('sha256', $path);
|
||||
abort_unless(is_string($checksum) && hash_equals(trim($document->sha256), $checksum), 404);
|
||||
|
||||
return $inline ? response()->file($path, $headers)->setContentDisposition('inline', basename($document->file_name)) : response()->download($path, basename($document->file_name), $headers);
|
||||
}
|
||||
|
||||
/** The general document route must not bypass the opportunity's current authorization. */
|
||||
private function authorizeOpportunityAttachment(\stdClass $document): void
|
||||
{
|
||||
$links = collect();
|
||||
foreach (['opportunity_documents', 'opportunity_images'] as $table) {
|
||||
if (! Schema::hasTable($table)) {
|
||||
continue;
|
||||
}
|
||||
$query = DB::table($table)->where('document_id', $document->id);
|
||||
if ($table === 'opportunity_images') {
|
||||
$query->orWhereRaw("payload->'derivatives' @> ?::jsonb", [json_encode([['document_id' => $document->id]], JSON_THROW_ON_ERROR)]);
|
||||
}
|
||||
$links = $links->concat($query->get(['opportunity_id', 'deleted_at']));
|
||||
}
|
||||
$privateOrigin = in_array($document->source_system ?? null, ['opportunity-resources', 'opportunity-image-derivatives'], true);
|
||||
if ($links->isEmpty() && ! $privateOrigin) {
|
||||
return; // Other consumers retain their own publication/authorization rules.
|
||||
}
|
||||
$actor = request()->user();
|
||||
abort_unless($actor instanceof \App\Models\User, 403, 'Anexo privado: é necessário acesso autorizado à oportunidade.');
|
||||
foreach ($links as $link) {
|
||||
$opportunity = \App\Models\Opportunity::find($link->opportunity_id);
|
||||
if ($link->deleted_at === null && $opportunity && $opportunity->status !== 'archived'
|
||||
&& app(PortalProfileAccess::class)->canView($actor, $opportunity)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
abort(403, 'O perfil atual não autoriza consultar este anexo da oportunidade.');
|
||||
}
|
||||
}
|
||||
+13
File diff suppressed because one or more lines are too long
+1
File diff suppressed because one or more lines are too long
+1
File diff suppressed because one or more lines are too long
+1
File diff suppressed because one or more lines are too long
+42
File diff suppressed because one or more lines are too long
+2
File diff suppressed because one or more lines are too long
+1
@@ -0,0 +1 @@
|
||||
import{n as e}from"./dist-BRfsww6z.js";import{t}from"./jsx-runtime-BpzPEenQ.js";import{t as n}from"./compiler-runtime-sKsOXjDo.js";import{t as r}from"./utils-CCDJ05Ll.js";import{t as i}from"./createLucideIcon-oMeAlXbs.js";import{C as a,n as o,r as s}from"./app-CdqBMdkz.js";var c=i(`Monitor`,[[`rect`,{width:`20`,height:`14`,x:`2`,y:`3`,rx:`2`,key:`48i651`}],[`line`,{x1:`8`,x2:`16`,y1:`21`,y2:`21`,key:`1svkeh`}],[`line`,{x1:`12`,x2:`12`,y1:`17`,y2:`21`,key:`vw1qmm`}]]),l=i(`Moon`,[[`path`,{d:`M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z`,key:`a7tn18`}]]),u=i(`Sun`,[[`circle`,{cx:`12`,cy:`12`,r:`4`,key:`4exip2`}],[`path`,{d:`M12 2v2`,key:`tus03m`}],[`path`,{d:`M12 20v2`,key:`1lh1kg`}],[`path`,{d:`m4.93 4.93 1.41 1.41`,key:`149t6j`}],[`path`,{d:`m17.66 17.66 1.41 1.41`,key:`ptbguv`}],[`path`,{d:`M2 12h2`,key:`1t8f8n`}],[`path`,{d:`M20 12h2`,key:`1q8mjw`}],[`path`,{d:`m6.34 17.66-1.41 1.41`,key:`1m8zz5`}],[`path`,{d:`m19.07 4.93-1.41 1.41`,key:`1shlcs`}]]),d=n(),f=t();function p({className:e=``,...t}){let{appearance:n,updateAppearance:i}=a(),o=[{value:`light`,icon:u,label:`Light`},{value:`dark`,icon:l,label:`Dark`},{value:`system`,icon:c,label:`System`}];return(0,f.jsx)(`div`,{className:r(`inline-flex gap-1 rounded-lg bg-neutral-100 p-1 dark:bg-neutral-800`,e),...t,children:o.map(({value:e,icon:t,label:a})=>(0,f.jsxs)(`button`,{onClick:()=>i(e),className:r(`flex items-center rounded-md px-3.5 py-1.5 transition-colors`,n===e?`bg-white shadow-xs dark:bg-neutral-700 dark:text-neutral-100`:`text-neutral-500 hover:bg-neutral-200/60 hover:text-black dark:text-neutral-400 dark:hover:bg-neutral-700/60`),children:[(0,f.jsx)(t,{className:`-ml-1 h-4 w-4`}),(0,f.jsx)(`span`,{className:`ml-1.5 text-sm`,children:a})]},e))})}function m(){let t=(0,d.c)(3),n,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,f.jsx)(e,{title:`Appearance settings`}),r=(0,f.jsx)(`h1`,{className:`sr-only`,children:`Appearance settings`}),t[0]=n,t[1]=r):(n=t[0],r=t[1]);let i;return t[2]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,f.jsxs)(f.Fragment,{children:[n,r,(0,f.jsxs)(`div`,{className:`space-y-6`,children:[(0,f.jsx)(s,{variant:`small`,title:`Appearance settings`,description:`Update the appearance settings for your account`}),(0,f.jsx)(p,{})]})]}),t[2]=i):i=t[2],i}m.layout={breadcrumbs:[{title:`Appearance settings`,href:o()}]};export{m as default};
|
||||
+1
@@ -0,0 +1 @@
|
||||
import{n as e,o as t}from"./dist-BRfsww6z.js";import{t as n}from"./jsx-runtime-BpzPEenQ.js";import{t as r}from"./compiler-runtime-sKsOXjDo.js";import{u as i}from"./app-CdqBMdkz.js";import{a,i as o,r as s}from"./shared-D-va8joy.js";var c=r(),l=n();function u(n){let r=(0,c.c)(41),{records:u,filters:m}=n,h=m.actor_id??``,g=m.action??``,_=m.record_id??``,v=m.from??``,y=m.until??``,b;r[0]!==h||r[1]!==g||r[2]!==_||r[3]!==v||r[4]!==y?(b={actor_id:h,action:g,record_id:_,from:v,until:y},r[0]=h,r[1]=g,r[2]=_,r[3]=v,r[4]=y,r[5]=b):b=r[5];let x=t(b),S;r[6]===x.data?S=r[7]:(S=new URLSearchParams(Object.entries(x.data).filter(p)),S.set(`format`,`json`),r[6]=x.data,r[7]=S);let C,w,T,E;r[8]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,l.jsx)(e,{title:`Auditoria de acessos`}),T=(0,l.jsx)(i,{}),E=(0,l.jsx)(`h1`,{className:`text-2xl font-semibold`,children:`Auditoria de acessos e decisões`}),C=(0,l.jsx)(`p`,{children:`Consulta somente de leitura. A exportação contém metadados; não inclui credenciais, documentos nem snapshots privados decifrados. Cada exportação apresenta o limite aplicado.`}),r[8]=C,r[9]=w,r[10]=T,r[11]=E):(C=r[8],w=r[9],T=r[10],E=r[11]);let D;r[12]===x?D=r[13]:(D=e=>{e.preventDefault(),x.get(`/perfis/auditoria`)},r[12]=x,r[13]=D);let O;r[14]===Symbol.for(`react.memo_cache_sentinel`)?(O=[`actor_id`,`action`,`record_id`,`from`,`until`],r[14]=O):O=r[14];let k;r[15]===x?k=r[16]:(k=O.map(e=>(0,l.jsxs)(`label`,{children:[e,(0,l.jsx)(`input`,{className:a,type:e===`from`||e===`until`?`datetime-local`:`text`,value:x.data[e],onChange:t=>x.setData(e,t.target.value)})]},e)),r[15]=x,r[16]=k);let A;r[17]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,l.jsx)(`button`,{className:o,children:`Filtrar`}),r[17]=A):A=r[17];let j;r[18]!==D||r[19]!==k?(j=(0,l.jsxs)(`form`,{className:`grid gap-3 sm:grid-cols-3`,onSubmit:D,children:[k,A]}),r[18]=D,r[19]=k,r[20]=j):j=r[20];let M;r[21]===x.errors?M=r[22]:(M=Object.values(x.errors).map(f),r[21]=x.errors,r[22]=M);let N=`/perfis/auditoria?${S}`,P;r[23]===N?P=r[24]:(P=(0,l.jsx)(`a`,{className:`underline`,href:N,children:`Exportar metadados JSON, até 1.000 eventos`}),r[23]=N,r[24]=P);let F;r[25]===Symbol.for(`react.memo_cache_sentinel`)?(F=(0,l.jsx)(`thead`,{children:(0,l.jsxs)(`tr`,{children:[(0,l.jsx)(`th`,{children:`Data UTC`}),(0,l.jsx)(`th`,{children:`Conta`}),(0,l.jsx)(`th`,{children:`Ação`}),(0,l.jsx)(`th`,{children:`Recurso`}),(0,l.jsx)(`th`,{children:`Origem`})]})}),r[25]=F):F=r[25];let I;r[26]===u.data?I=r[27]:(I=u.data.map(d),r[26]=u.data,r[27]=I);let L;r[28]===I?L=r[29]:(L=(0,l.jsx)(`div`,{className:`overflow-auto`,children:(0,l.jsxs)(`table`,{className:`w-full`,children:[F,(0,l.jsx)(`tbody`,{children:I})]})}),r[28]=I,r[29]=L);let R;r[30]===u.data.length?R=r[31]:(R=!u.data.length&&(0,l.jsx)(`p`,{children:`Nenhum evento corresponde aos filtros.`}),r[30]=u.data.length,r[31]=R);let z;r[32]===u?z=r[33]:(z=(0,l.jsx)(s,{page:u}),r[32]=u,r[33]=z);let B;return r[34]!==j||r[35]!==M||r[36]!==P||r[37]!==L||r[38]!==R||r[39]!==z?(B=(0,l.jsxs)(`main`,{className:`space-y-6 p-6`,children:[w,T,E,C,j,M,P,L,R,z]}),r[34]=j,r[35]=M,r[36]=P,r[37]=L,r[38]=R,r[39]=z,r[40]=B):B=r[40],B}function d(e){return(0,l.jsxs)(`tr`,{children:[(0,l.jsx)(`td`,{children:e.occurred_at}),(0,l.jsx)(`td`,{children:e.actor_user_id}),(0,l.jsx)(`td`,{children:e.action}),(0,l.jsx)(`td`,{children:e.entity_type}),(0,l.jsx)(`td`,{children:e.source_system})]},e.id)}function f(e){return(0,l.jsx)(`p`,{role:`alert`,children:e},e)}function p(e){let[,t]=e;return t!==``}export{u as default};
|
||||
+1
File diff suppressed because one or more lines are too long
+1
File diff suppressed because one or more lines are too long
+1
File diff suppressed because one or more lines are too long
+1
@@ -0,0 +1 @@
|
||||
import{i as e}from"./rolldown-runtime-Dd_uD5pT.js";import{r as t,u as n}from"./dist-BRfsww6z.js";import{n as r,t as i}from"./jsx-runtime-BpzPEenQ.js";import{a,i as o,n as s,s as c}from"./shared-DDFDWkxk.js";import{r as l}from"./investment-territory-CggzoPQh.js";import{t as u}from"./business-types-SGCXhH6X.js";var d=e(r(),1),f=i();function p({results:e,filters:r,territorySelection:i=[]}){let[p,m]=(0,d.useState)(r.q??``),[h,g]=(0,d.useState)(r.modality??``),[_,v]=(0,d.useState)({province_id:r.province_id??``,district_id:r.district_id??``,admin_post_id:r.admin_post_id??``,locality_id:r.locality_id??``}),y=new URLSearchParams({...p?{q:p}:{},...h?{modality:h}:{},..._}).toString(),b=e.meta?.links??(Array.isArray(e.links)?e.links:[]);return(0,f.jsxs)(s,{title:`Oportunidades de negócio`,children:[(0,f.jsx)(`p`,{children:`Explore oportunidades aprovadas para publicação. A informação está sujeita a diligência independente.`}),(0,f.jsxs)(`form`,{className:`flex flex-wrap gap-3`,onSubmit:e=>{e.preventDefault(),n.get(`/negocios`,{q:p||void 0,modality:h||void 0,..._},{preserveState:!0,preserveScroll:!0})},children:[(0,f.jsx)(`label`,{className:`sr-only`,htmlFor:`business-search`,children:`Pesquisar negócios`}),(0,f.jsx)(`input`,{id:`business-search`,className:c,value:p,maxLength:120,onChange:e=>m(e.target.value)}),(0,f.jsxs)(`label`,{className:`grid gap-1`,children:[(0,f.jsx)(`span`,{children:`Tipo de oportunidade`}),(0,f.jsxs)(`select`,{className:c,value:h,onChange:e=>g(e.target.value),children:[(0,f.jsx)(`option`,{value:``,children:`Todos os tipos`}),Object.entries(u).map(([e,t])=>(0,f.jsx)(`option`,{value:e,children:t},e))]})]}),(0,f.jsx)(l,{initial:i,onChange:e=>v({province_id:e[0]?.id??``,district_id:e[1]?.id??``,admin_post_id:e[2]?.id??``,locality_id:e[3]?.id??``})}),(0,f.jsx)(`button`,{className:o,children:`Pesquisar`})]}),(0,f.jsxs)(`p`,{role:`status`,children:[e.meta?.total??e.data.length,` anúncios de negócios publicados`]}),!e.data.length&&(0,f.jsx)(`p`,{role:`status`,children:`Não existem oportunidades publicadas com estes critérios.`}),(0,f.jsx)(`ul`,{className:`grid gap-4 md:grid-cols-2`,children:e.data.map(e=>(0,f.jsxs)(`li`,{className:a,children:[(0,f.jsx)(`p`,{children:u[e.modality]??e.modality}),(0,f.jsx)(`h2`,{className:`text-xl font-bold`,children:(0,f.jsx)(t,{className:`underline`,href:`/negocios/${e.slug}${y?`?${y}`:``}`,children:e.title})}),(0,f.jsx)(`p`,{children:[e.sector?.name,e.province,e.stage].filter(Boolean).join(` · `)}),(e.amount_min||e.amount_max)&&(0,f.jsxs)(`p`,{children:[e.amount_min??`—`,` –`,` `,e.amount_max??`—`,` `,e.currency]}),e.objective&&(0,f.jsx)(`p`,{className:`mt-3 line-clamp-3`,children:e.objective})]},e.id))}),(0,f.jsx)(`nav`,{"aria-label":`Paginação das oportunidades`,className:`flex flex-wrap gap-3`,children:b.map(e=>e.url?(0,f.jsx)(t,{href:e.url,className:e.active?`font-bold underline`:`underline`,dangerouslySetInnerHTML:{__html:e.label}},e.label):null)})]})}export{p as default};
|
||||
+1
File diff suppressed because one or more lines are too long
+1
@@ -0,0 +1 @@
|
||||
import{r as e}from"./dist-BRfsww6z.js";import{t}from"./jsx-runtime-BpzPEenQ.js";import{a as n,i as r,n as i}from"./shared-DDFDWkxk.js";import{t as a}from"./business-types-SGCXhH6X.js";import{t as o}from"./partnership-source-links-VfrXk2FZ.js";var s=t();function c({record:t,returnUrl:c=`/negocios`,interestUrl:l=`/negocios/${t.slug}/manifestar-interesse`}){return(0,s.jsxs)(i,{title:t.title,children:[(0,s.jsx)(o,{type:`business`,id:t.id}),(0,s.jsx)(e,{href:c,className:`underline`,children:`Voltar às oportunidades`}),(0,s.jsxs)(`section`,{className:`${n} space-y-4`,children:[(0,s.jsx)(`p`,{children:a[t.modality]??t.modality}),(0,s.jsx)(`p`,{children:[t.sector?.name,t.stage,t.activity_code].filter(Boolean).join(` · `)}),(t.province||t.district||t.locality)&&(0,s.jsx)(`p`,{children:[t.locality,t.district,t.province].filter(Boolean).join(`, `)}),(t.amount_min||t.amount_max)&&(0,s.jsxs)(`p`,{children:[`Montante indicativo: `,t.amount_min??`—`,` –`,` `,t.amount_max??`—`,` `,t.currency]}),t.available_percentage&&(0,s.jsxs)(`p`,{children:[`Participação indicada: `,t.available_percentage,`%`]}),t.objective&&(0,s.jsxs)(`div`,{children:[(0,s.jsx)(`h2`,{className:`font-bold`,children:`Objectivo`}),(0,s.jsx)(`p`,{className:`whitespace-pre-wrap`,children:t.objective})]}),(0,s.jsx)(`p`,{className:`text-sm`,children:`A publicação não constitui garantia de titularidade, avaliação, transmissibilidade ou retorno.`}),(0,s.jsx)(e,{className:r,href:l,children:`Manifestar interesse`})]})]})}export{c as default};
|
||||
+1
@@ -0,0 +1 @@
|
||||
var e={draft:`Rascunho`,submitted:`Submetido`,in_review:`Em revisão`,needs_information:`Pendente de informação`,withdrawn:`Retirado`,triage:`Triagem`,information_pending:`Informação pendente`,review:`Em revisão`,approval_l1:`Aprovação nível 1`,approval_l2:`Aprovação nível 2`,approved:`Aprovado`,published:`Publicado`,suspended:`Suspenso`,rejected:`Rejeitado`,cancelled:`Cancelado`,archived:`Arquivado`},t={company_sale:`Venda da empresa`,company_purchase:`Compra ou aquisição de empresa`,participation_sale:`Venda de participação`,capital_increase:`Aumento de capital`,financial_investor:`Investidor financeiro`,strategic_partner:`Sócio estratégico`,buyer_search:`Procura de comprador`,position_assignment:`Cessão de posição`,franchise:`Franchising`,asset_sale:`Venda de activos`,asset_lease:`Arrendamento de activos`,business_unit_transfer:`Transferência de unidade de negócio`,joint_venture:`Joint venture`,succession:`Sucessão empresarial`,recovery:`Recuperação`,expansion:`Expansão`,internationalization:`Internacionalização`,real_estate:`Imobiliário`,agricultural_investment:`Investimento agrícola`,land_right:`Direito fundiário`,mining_license:`Licença mineira`,forestry_license:`Licença florestal`,investment_project:`Projecto de investimento`,business_partnership:`Parceria empresarial`,financing_request:`Procura de financiamento`,concession_opportunity:`Concessão`,supply_opportunity:`Oportunidade de fornecimento`};export{e as n,t};
|
||||
+1
@@ -0,0 +1 @@
|
||||
import{i as e}from"./rolldown-runtime-Dd_uD5pT.js";import{u as t}from"./dist-BRfsww6z.js";import{n,t as r}from"./jsx-runtime-BpzPEenQ.js";import{a as i,r as a,t as o}from"./shared-DDFDWkxk.js";var s=e(n(),1),c=r(),l={identity:`Identidade`,representation:`Representação`,declared_ownership:`Titularidade declarada`,documentary_ownership:`Titularidade documental`,document_received:`Documento recebido`,document_validated:`Documento validado`,independent_valuation:`Avaliação independente`,land_right_documented:`Direito fundiário documentado`,license_confirmed:`Licença confirmada`,validity:`Validade`,legal_transfer:`Transmissibilidade jurídica`,prior_authorization:`Autorização prévia`,confirmed:`Confirmado pelo revisor`,rejected:`Não confirmado`,inconclusive:`Inconclusivo`,revoked:`Revogado`,stale:`Rever após alteração dos dados`,expired:`Expirado`};function u({id:e,version:n,editable:r,checks:u,findings:d,objects:f}){let[p,m]=(0,s.useState)(!1),[h,g]=(0,s.useState)(``),[_,v]=(0,s.useState)(`inconclusive`);return(0,c.jsxs)(`section`,{className:`${i} space-y-4`,children:[(0,c.jsx)(`h2`,{className:`text-xl font-bold`,children:`Verificações e evidências`}),(0,c.jsx)(`p`,{children:`Cada conclusão corresponde apenas ao aspecto e à versão analisados. Não constitui certificação global, autorização de publicação ou garantia de transmissão. Alterações aos dados exigem nova revisão.`}),d.length===0&&(0,c.jsx)(`p`,{children:`Ainda não existem verificações registadas.`}),(0,c.jsx)(`ul`,{className:`space-y-4`,children:d.map(e=>(0,c.jsxs)(`li`,{className:`break-words`,children:[(0,c.jsxs)(`strong`,{children:[l[e.check],` ·`,` `,l[e.effective_outcome]]}),(0,c.jsxs)(`p`,{children:[f.find(t=>t.id===e.object_id)?.payload.label??`Negócio`,` `,`· versão `,e.version_no]}),(0,c.jsxs)(`p`,{children:[`Evidência: `,e.evidence_reference]}),(0,c.jsx)(`p`,{children:e.note}),e.valid_until&&(0,c.jsxs)(`p`,{children:[`Válido até `,e.valid_until]})]},e.version_no))}),r&&(0,c.jsxs)(`form`,{className:`space-y-4`,onSubmit:async r=>{r.preventDefault();let i=Object.fromEntries(new FormData(r.currentTarget));m(!0),g(``);try{await a(`/api/v1/existing-business/listings/${e}/verifications`,{...i,version_no:n}),t.reload()}catch(e){g(e instanceof Error?e.message:`Não foi possível registar a verificação.`)}finally{m(!1)}},children:[(0,c.jsxs)(`fieldset`,{disabled:p,className:`space-y-4`,children:[(0,c.jsx)(o,{label:`Elemento analisado`,children:(0,c.jsxs)(`select`,{className:`w-full rounded-lg border border-slate-300 bg-white px-3 py-2 text-slate-900 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-emerald-700`,name:`object_id`,children:[(0,c.jsx)(`option`,{value:``,children:`Negócio`}),f.map(e=>(0,c.jsx)(`option`,{value:e.id,children:e.payload.label},e.id))]})}),(0,c.jsx)(o,{label:`Aspecto verificado`,children:(0,c.jsx)(`select`,{className:`w-full rounded-lg border border-slate-300 bg-white px-3 py-2 text-slate-900 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-emerald-700`,name:`check`,children:u.map(e=>(0,c.jsx)(`option`,{value:e,children:l[e]},e))})}),(0,c.jsx)(o,{label:`Conclusão`,children:(0,c.jsx)(`select`,{className:`w-full rounded-lg border border-slate-300 bg-white px-3 py-2 text-slate-900 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-emerald-700`,name:`outcome`,value:_,onChange:e=>v(e.target.value),children:[`inconclusive`,`confirmed`,`rejected`,`revoked`].map(e=>(0,c.jsx)(`option`,{value:e,children:l[e]},e))})}),(0,c.jsx)(o,{label:`Referência da evidência consultada`,children:(0,c.jsx)(`textarea`,{className:`w-full rounded-lg border border-slate-300 bg-white px-3 py-2 text-slate-900 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-emerald-700`,name:`evidence_reference`,required:!0,minLength:10,maxLength:2e3})}),(0,c.jsx)(o,{label:`Fundamentação e limites da conclusão`,children:(0,c.jsx)(`textarea`,{className:`w-full rounded-lg border border-slate-300 bg-white px-3 py-2 text-slate-900 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-emerald-700`,name:`note`,required:!0,minLength:10,maxLength:2e3})}),(0,c.jsx)(o,{label:`Validade da conclusão`,children:(0,c.jsx)(`input`,{className:`w-full rounded-lg border border-slate-300 bg-white px-3 py-2 text-slate-900 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-emerald-700`,type:`date`,name:`valid_until`,required:_===`confirmed`})}),(0,c.jsx)(`button`,{className:`inline-flex items-center justify-center rounded-lg bg-emerald-800 px-4 py-2 font-semibold text-white disabled:opacity-50 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-emerald-700`,disabled:p,children:`Registar verificação`})]}),h&&(0,c.jsx)(`p`,{role:`alert`,children:h})]})]})}export{u as default};
|
||||
+1
File diff suppressed because one or more lines are too long
+1
@@ -0,0 +1 @@
|
||||
import{i as e}from"./rolldown-runtime-Dd_uD5pT.js";import{r as t,u as n}from"./dist-BRfsww6z.js";import{n as r,t as i}from"./jsx-runtime-BpzPEenQ.js";import{a,i as o,n as s,r as c,s as l,t as u}from"./shared-DDFDWkxk.js";import{t as d}from"./country-select-C3BLoPPG.js";import{n as f,t as p}from"./business-types-SGCXhH6X.js";var m=e(r(),1),h=i();function g({records:e,management:r,modalities:i,filters:g,countries:_}){let[v,y]=(0,m.useState)(``),[b,x]=(0,m.useState)(i[0]),[S,C]=(0,m.useState)(``),[w,T]=(0,m.useState)(!1),[E,D]=(0,m.useState)(g.country??``),[O,k]=(0,m.useState)(g.origin??``);return(0,h.jsxs)(s,{title:r?`Revisão de negócios`:`Os meus negócios`,children:[(0,h.jsx)(`p`,{children:`Área privada de preparação e revisão. A submissão não confirma titularidade, validade ou transmissibilidade do negócio, activo ou direito.`}),(0,h.jsxs)(`form`,{className:`${a} flex flex-wrap gap-3`,onSubmit:e=>{e.preventDefault(),n.get(r?`/management/negocios`:`/investidor/negocios`,{country:E,origin:O})},children:[(0,h.jsx)(d,{countries:_,value:E,onChange:D,label:`Filtrar país do proponente`}),(0,h.jsxs)(`label`,{children:[`Origem declarada`,(0,h.jsxs)(`select`,{"aria-label":`Filtrar origem declarada`,className:l,value:O,onChange:e=>k(e.target.value),children:[(0,h.jsx)(`option`,{value:``,children:`Todas`}),(0,h.jsx)(`option`,{value:`unknown`,children:`Não informada`}),_.map(e=>(0,h.jsxs)(`option`,{value:e.code,children:[e.name,` (`,e.code,`)`]},e.code))]})]}),(0,h.jsx)(`button`,{className:o,children:`Filtrar negócios`})]}),!r&&(0,h.jsxs)(`form`,{className:`rounded-xl border border-slate-200 bg-white p-5 shadow-sm space-y-4`,onSubmit:async e=>{e.preventDefault(),T(!0),C(``);try{let e=await c(`/api/v1/existing-business/listings`,{modality:b,classification:`confidential`,reason:`Criação de rascunho pelo proprietário`,payload:{title:v,wizard_version:`1`,wizard_step:`1`}});n.visit(`/investidor/negocios/${e.id}`)}catch(e){C(e instanceof Error?e.message:`Não foi possível criar o rascunho.`)}finally{T(!1)}},children:[(0,h.jsx)(`h2`,{className:`text-xl font-bold`,children:`Preparar negócio`}),(0,h.jsx)(u,{label:`Título privado`,children:(0,h.jsx)(`input`,{className:`w-full rounded-lg border border-slate-300 bg-white px-3 py-2 text-slate-900 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-emerald-700`,value:v,onChange:e=>y(e.target.value),required:!0,maxLength:200})}),(0,h.jsx)(u,{label:`Modalidade`,children:(0,h.jsx)(`select`,{className:`w-full rounded-lg border border-slate-300 bg-white px-3 py-2 text-slate-900 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-emerald-700`,value:b,onChange:e=>x(e.target.value),children:i.map(e=>(0,h.jsx)(`option`,{value:e,children:p[e]??e},e))})}),S&&(0,h.jsx)(`p`,{role:`alert`,children:S}),(0,h.jsx)(`button`,{className:`inline-flex items-center justify-center rounded-lg bg-emerald-800 px-4 py-2 font-semibold text-white disabled:opacity-50 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-emerald-700`,disabled:w,children:w?`A criar…`:`Criar rascunho privado`})]}),!e.data.length&&(0,h.jsx)(`p`,{role:`status`,children:`Não existem negócios nesta lista.`}),e.data.map(e=>(0,h.jsxs)(`article`,{className:a,children:[(0,h.jsx)(t,{className:`font-bold underline`,href:`/investidor/negocios/${e.id}`,children:e.payload.title}),(0,h.jsxs)(`p`,{children:[p[e.modality],` ·`,` `,f[e.status],` · versão `,e.version_no]})]},e.id)),(0,h.jsxs)(`nav`,{"aria-label":`Paginação dos negócios`,className:`flex gap-4`,children:[e.prev_page_url&&(0,h.jsx)(t,{href:e.prev_page_url,children:`Anterior`}),e.next_page_url&&(0,h.jsx)(t,{href:e.next_page_url,children:`Seguinte`})]})]})}export{g as default};
|
||||
+1
@@ -0,0 +1 @@
|
||||
import{i as e}from"./rolldown-runtime-Dd_uD5pT.js";import{n as t,t as n}from"./jsx-runtime-BpzPEenQ.js";import{r,t as i}from"./utils-CCDJ05Ll.js";var a=e(t(),1),o=Object.defineProperty,s=(e,t)=>o(e,`name`,{value:t,configurable:!0});function c(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}s(c,`setRef`);function l(...e){return t=>{let n=!1,r=e.map(e=>{let r=c(e,t);return!n&&typeof r==`function`&&(n=!0),r});if(n)return()=>{for(let t=0;t<r.length;t++){let n=r[t];typeof n==`function`?n():c(e[t],null)}}}}s(l,`composeRefs`);function u(...e){return a.useCallback(l(...e),e)}s(u,`useComposedRefs`);var d=Object.defineProperty,f=(e,t)=>d(e,`name`,{value:t,configurable:!0});function p(e){let t=a.forwardRef((t,n)=>{let{children:r,...i}=t,o=null,s=!1,c=[];S(r)&&typeof E==`function`&&(r=E(r._payload)),a.Children.forEach(r,e=>{if(b(e)){s=!0;let t=e,n=`child`in t.props?t.props.child:t.props.children;S(n)&&typeof E==`function`&&(n=E(n._payload)),o=_(t,n),c.push(o?.props?.children)}else c.push(e)}),o?o=a.cloneElement(o,void 0,c):!s&&a.Children.count(r)===1&&a.isValidElement(r)&&(o=r);let l=o?y(o):void 0,d=u(n,l);if(!o){if(r||r===0)throw Error(s?T(e):w(e));return r}let f=v(i,o.props??{});return o.type!==a.Fragment&&(f.ref=n?d:l),a.cloneElement(o,f)});return t.displayName=`${e}.Slot`,t}f(p,`createSlot`);var m=p(`Slot`),h=Symbol.for(`radix.slottable`);function g(e){let t=f(e=>`child`in e?e.children(e.child):e.children,`Slottable`);return t.displayName=`${e}.Slottable`,t.__radixId=h,t}f(g,`createSlottable`);var _=f((e,t)=>{if(`child`in e.props){let t=e.props.child;return a.isValidElement(t)?a.cloneElement(t,void 0,e.props.children(t.props.children)):null}return a.isValidElement(t)?t:null},`getSlottableElementFromSlottable`);function v(e,t){let n={...t};for(let r in t){let i=e[r],a=t[r];/^on[A-Z]/.test(r)?i&&a?n[r]=(...e)=>{let t=a(...e);return i(...e),t}:i&&(n[r]=i):r===`style`?n[r]={...i,...a}:r===`className`&&(n[r]=[i,a].filter(Boolean).join(` `))}return{...e,...n}}f(v,`mergeProps`);function y(e){let t=Object.getOwnPropertyDescriptor(e.props,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}f(y,`getElementRef`);function b(e){return a.isValidElement(e)&&typeof e.type==`function`&&`__radixId`in e.type&&e.type.__radixId===h}f(b,`isSlottable`);var x=Symbol.for(`react.lazy`);function S(e){return typeof e==`object`&&!!e&&`$$typeof`in e&&e.$$typeof===x&&`_payload`in e&&C(e._payload)}f(S,`isLazyComponent`);function C(e){return typeof e==`object`&&!!e&&`then`in e}f(C,`isPromiseLike`);var w=f(e=>`${e} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`,`createSlotError`),T=f(e=>`${e} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`,`createSlottableError`),E=a.use,D=e=>typeof e==`boolean`?`${e}`:e===0?`0`:e,O=r,k=(e,t)=>n=>{if(t?.variants==null)return O(e,n?.class,n?.className);let{variants:r,defaultVariants:i}=t,a=Object.keys(r).map(e=>{let t=n?.[e],a=i?.[e];if(t===null)return null;let o=D(t)||D(a);return r[e][o]}),o=n&&Object.entries(n).reduce((e,t)=>{let[n,r]=t;return r===void 0||(e[n]=r),e},{});return O(e,a,t?.compoundVariants?.reduce((e,t)=>{let{class:n,className:r,...a}=t;return Object.entries(a).every(e=>{let[t,n]=e;return Array.isArray(n)?n.includes({...i,...o}[t]):{...i,...o}[t]===n})?[...e,n,r]:e},[]),n?.class,n?.className)},A=n(),j=k(`inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-[color,box-shadow] disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive`,{variants:{variant:{default:`bg-primary text-primary-foreground shadow-xs hover:bg-primary/90`,destructive:`bg-destructive text-white shadow-xs hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40`,outline:`border border-input bg-background shadow-xs hover:bg-accent hover:text-accent-foreground`,secondary:`bg-secondary text-secondary-foreground shadow-xs hover:bg-secondary/80`,ghost:`hover:bg-accent hover:text-accent-foreground`,link:`text-primary underline-offset-4 hover:underline`},size:{default:`h-9 px-4 py-2 has-[>svg]:px-3`,sm:`h-8 rounded-md px-3 has-[>svg]:px-2.5`,lg:`h-10 rounded-md px-6 has-[>svg]:px-4`,icon:`size-9`}},defaultVariants:{variant:`default`,size:`default`}});function M({className:e,variant:t,size:n,asChild:r=!1,...a}){return(0,A.jsx)(r?m:`button`,{"data-slot":`button`,className:i(j({variant:t,size:n,className:e})),...a})}export{g as a,p as i,k as n,u as o,m as r,M as t};
|
||||
+1
File diff suppressed because one or more lines are too long
+1
File diff suppressed because one or more lines are too long
+1
@@ -0,0 +1 @@
|
||||
import{o as e,r as t}from"./dist-BRfsww6z.js";import{t as n}from"./jsx-runtime-BpzPEenQ.js";import{a as r,i,n as a,r as o,s}from"./shared-D-va8joy.js";var c=n();function l({resource:n,records:l,filters:u,sectors:d,geographyReviewCount:f=0}){let p=e({q:u.q??``,status:u.status??``,sector_id:String(u.sector_id??``),geography_scope:u.geography_scope??``});return(0,c.jsxs)(a,{title:n===`sectors`?`Sectores`:`Oportunidades`,children:[(0,c.jsxs)(t,{className:i,href:`/management/${n}/create`,children:[`Criar `,n===`sectors`?`sector`:`oportunidade`]}),n===`opportunities`&&(0,c.jsxs)(`p`,{role:`status`,className:`my-3`,children:[f,` oportunidade(s) aguardam confirmação do âmbito geográfico. A lista não altera localizações; confirme apenas com fontes existentes.`]}),(0,c.jsxs)(`form`,{className:`flex flex-wrap gap-3`,onSubmit:e=>{e.preventDefault(),p.get(`/management/${n}`,{preserveState:!1})},children:[(0,c.jsx)(`input`,{"aria-label":`Pesquisar catálogo`,placeholder:`Nome, título, referência ou slug`,className:`${r} max-w-sm`,value:p.data.q,onChange:e=>p.setData(`q`,e.target.value),maxLength:150}),(0,c.jsxs)(`select`,{"aria-label":`Estado`,className:`${r} max-w-xs`,value:p.data.status,onChange:e=>p.setData(`status`,e.target.value),children:[(0,c.jsx)(`option`,{value:``,children:`Todos os estados`}),(n===`sectors`?[`active`,`inactive`]:[`draft`,`published`,`archived`]).map(e=>(0,c.jsx)(`option`,{value:e,children:e===`active`?`Activo`:e===`inactive`?`Inactivo`:s[e]},e))]}),n===`opportunities`&&(0,c.jsxs)(c.Fragment,{children:[(0,c.jsxs)(`select`,{"aria-label":`Sector`,className:`w-full rounded-md border border-input bg-background p-2 text-foreground max-w-xs`,value:p.data.sector_id,onChange:e=>p.setData(`sector_id`,e.target.value),children:[(0,c.jsx)(`option`,{value:``,children:`Todos os sectores`}),d.map(e=>(0,c.jsx)(`option`,{value:e.id,children:e.name},e.id))]}),(0,c.jsxs)(`select`,{"aria-label":`Âmbito geográfico`,className:`w-full rounded-md border border-input bg-background p-2 text-foreground max-w-xs`,value:p.data.geography_scope,onChange:e=>p.setData(`geography_scope`,e.target.value),children:[(0,c.jsx)(`option`,{value:``,children:`Todos os âmbitos`}),(0,c.jsx)(`option`,{value:`unspecified`,children:`Pendente de confirmação`}),(0,c.jsx)(`option`,{value:`specific`,children:`Localização específica`}),(0,c.jsx)(`option`,{value:`multiple`,children:`Várias localizações`}),(0,c.jsx)(`option`,{value:`national`,children:`Âmbito nacional`}),(0,c.jsx)(`option`,{value:`digital`,children:`Digital/sem instalação definida`})]})]}),(0,c.jsx)(`button`,{className:i,disabled:p.processing,children:`Pesquisar`}),(0,c.jsx)(t,{className:`p-2 underline`,href:`/management/${n}`,children:`Limpar filtros`}),Object.values(p.errors).map(e=>(0,c.jsx)(`p`,{role:`alert`,className:`w-full text-red-600`,children:e},e))]}),(0,c.jsx)(`div`,{className:`space-y-3`,children:l.data.map(e=>(0,c.jsxs)(`article`,{className:`flex flex-wrap items-center justify-between gap-3 rounded border p-4`,children:[(0,c.jsxs)(`div`,{children:[(0,c.jsx)(`h2`,{className:`font-semibold`,children:e.name??e.title}),(0,c.jsxs)(`p`,{className:`text-muted-foreground text-sm`,children:[e.reference??e.slug,` ·`,` `,n===`sectors`?e.is_active?`Activo`:`Inactivo`:s[e.status??`draft`]]}),n===`opportunities`&&e.geography_scope===`unspecified`&&(0,c.jsxs)(`p`,{className:`mt-1 text-sm`,children:[`Pendente de confirmação; território já registado:`,` `,e.primary_territory?.name??`nenhum`,`. Fonte do território:`,` `,e.primary_territory?.source_system??`não indicada`,e.primary_territory?.source_code?`, código ${e.primary_territory.source_code}`:``,`. A classificação não é alterada automaticamente.`]})]}),(0,c.jsx)(t,{className:`underline`,href:`/management/${n}/${e.id}/edit`,children:`Editar`})]},e.id))}),!l.data.length&&(0,c.jsx)(`p`,{children:`Nenhum registo encontrado.`}),(0,c.jsx)(o,{page:l})]})}export{l as default};
|
||||
+1
File diff suppressed because one or more lines are too long
+1
@@ -0,0 +1 @@
|
||||
import{r as e}from"./dist-BRfsww6z.js";import{t}from"./jsx-runtime-BpzPEenQ.js";import{t as n}from"./compiler-runtime-sKsOXjDo.js";import{a as r,n as i}from"./shared-DDFDWkxk.js";var a=n(),o=t();function s(t){let n=(0,a.c)(14),{installed:r,services:s,prepared:d}=t,f;n[0]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,o.jsx)(`p`,{children:`Preparação e acompanhamento internos; a decisão oficial pertence à entidade competente.`}),n[0]=f):f=n[0];let p=r?`/balcao-virtual/painel`:`/balcao-virtual`,m=r?`Abrir o painel e preparar um pedido`:`Consultar pedidos existentes`,h;n[1]!==p||n[2]!==m?(h=(0,o.jsx)(e,{href:p,className:`underline`,children:m}),n[1]=p,n[2]=m,n[3]=h):h=n[3];let g;n[4]===r?g=n[5]:(g=!r&&(0,o.jsx)(`p`,{children:`Melhorias preparadas; a instalação autenticada e a publicação explícita dos serviços continuam pendentes.`}),n[4]=r,n[5]=g);let _;n[6]!==r||n[7]!==d||n[8]!==s?(_=(r?s.map(u):Object.values(d).map(l)).map(c),n[6]=r,n[7]=d,n[8]=s,n[9]=_):_=n[9];let v;return n[10]!==h||n[11]!==g||n[12]!==_?(v=(0,o.jsxs)(i,{title:`Serviços do Balcão Virtual`,children:[f,h,g,_]}),n[10]=h,n[11]=g,n[12]=_,n[13]=v):v=n[13],v}function c(e){return(0,o.jsxs)(`article`,{className:r,children:[(0,o.jsx)(`h2`,{className:`text-xl font-bold`,children:e.title}),(0,o.jsx)(`p`,{children:e.result}),(0,o.jsx)(`p`,{children:e.version?`Versão ${e.version}`:`Preparado, ainda indisponível para novos pedidos`})]},e.title)}function l(e){return{...e,version:null}}function u(e){return{...e.definition,version:e.version}}export{s as default};
|
||||
+1
File diff suppressed because one or more lines are too long
+1
@@ -0,0 +1 @@
|
||||
import{t as e}from"./createLucideIcon-oMeAlXbs.js";var t=e(`Check`,[[`path`,{d:`M20 6 9 17l-5-5`,key:`1gmf2c`}]]);export{t};
|
||||
+1
@@ -0,0 +1 @@
|
||||
import{t as e}from"./rolldown-runtime-Dd_uD5pT.js";import{n as t}from"./jsx-runtime-BpzPEenQ.js";var n=e((e=>{var n=t().__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;e.c=function(e){return n.H.useMemoCache(e)}})),r=e(((e,t)=>{t.exports=n()}));export{r as t};
|
||||
+1
@@ -0,0 +1 @@
|
||||
import{n as e}from"./wayfinder-Dp7PqxvV.js";var t=e=>({url:t.url(e),method:`post`});t.definition={methods:[`post`],url:`/user/confirm-password`},t.url=n=>t.definition.url+e(n),t.post=e=>({url:t.url(e),method:`post`});var n=e=>({action:t.url(e),method:`post`});n.post=e=>({action:t.url(e),method:`post`}),t.form=n;var r={store:Object.assign(t,t)};export{t as n,r as t};
|
||||
+1
@@ -0,0 +1 @@
|
||||
import{n as e,t}from"./dist-BRfsww6z.js";import{t as n}from"./jsx-runtime-BpzPEenQ.js";import{t as r}from"./compiler-runtime-sKsOXjDo.js";import{t as i}from"./button-DAU4R6e9.js";import{t as a}from"./password-input-CbF7QAPJ.js";import{n as o}from"./wayfinder-Dp7PqxvV.js";import{t as s}from"./input-error-U1QKS0ED.js";import{t as c}from"./label-D-C_NQs4.js";import{t as l}from"./spinner-hD8hHC_m.js";import{n as u}from"./confirm-Culw9Q-x.js";import{t as d}from"./passkey-verify-BVjVf9Ia.js";var f=r(),p=e=>({url:p.url(e),method:`get`});p.definition={methods:[`get`,`head`],url:`/passkeys/confirm/options`},p.url=e=>p.definition.url+o(e),p.get=e=>({url:p.url(e),method:`get`}),p.head=e=>({url:p.url(e),method:`head`});var m=e=>({action:p.url(e),method:`get`});m.get=e=>({action:p.url(e),method:`get`}),m.head=e=>({action:p.url({[e?.mergeQuery?`mergeQuery`:`query`]:{_method:`HEAD`,...e?.query??e?.mergeQuery??{}}}),method:`get`}),p.form=m;var h=e=>({url:h.url(e),method:`post`});h.definition={methods:[`post`],url:`/passkeys/confirm`},h.url=e=>h.definition.url+o(e),h.post=e=>({url:h.url(e),method:`post`});var g=e=>({action:h.url(e),method:`post`});g.post=e=>({action:h.url(e),method:`post`}),h.form=g;var _=n();function v(){let n=(0,f.c)(3),r;n[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,_.jsx)(e,{title:`Confirm password`}),n[0]=r):r=n[0];let i;n[1]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,_.jsx)(d,{routes:{options:p(),submit:h()},label:`Confirm with passkey`,loadingLabel:`Confirming...`,separator:`Or confirm with password`}),n[1]=i):i=n[1];let a;return n[2]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,_.jsxs)(_.Fragment,{children:[r,i,(0,_.jsx)(t,{...u.form(),resetOnSuccess:[`password`],children:y})]}),n[2]=a):a=n[2],a}function y(e){let{processing:t,errors:n}=e;return(0,_.jsxs)(`div`,{className:`space-y-6`,children:[(0,_.jsxs)(`div`,{className:`grid gap-2`,children:[(0,_.jsx)(c,{htmlFor:`password`,children:`Password`}),(0,_.jsx)(a,{id:`password`,name:`password`,placeholder:`Password`,autoComplete:`current-password`,autoFocus:!0}),(0,_.jsx)(s,{message:n.password})]}),(0,_.jsx)(`div`,{className:`flex items-center`,children:(0,_.jsxs)(i,{className:`w-full`,disabled:t,"data-test":`confirm-password-button`,children:[t&&(0,_.jsx)(l,{}),`Confirm password`]})})]})}v.layout={title:`Confirm password`,description:`This is a secure area of the application. Please confirm your password before continuing.`};export{v as default};
|
||||
+1
File diff suppressed because one or more lines are too long
+1
@@ -0,0 +1 @@
|
||||
import{i as e}from"./rolldown-runtime-Dd_uD5pT.js";import{o as t}from"./dist-BRfsww6z.js";import{n,t as r}from"./jsx-runtime-BpzPEenQ.js";import{t as i}from"./compiler-runtime-sKsOXjDo.js";import{a,r as o,s,t as c}from"./shared-DDFDWkxk.js";import{a as l}from"./portal-api-tEuwFTsU.js";var u=i(),d=e(n(),1),f=r();function p(e){let n=(0,u.c)(26),{id:r,messages:i,submitted:p,revisions:v}=e,y;n[0]===Symbol.for(`react.memo_cache_sentinel`)?(y={client_key:l(),body:``},n[0]=y):y=n[0];let b=t(y),[x,S]=(0,d.useState)(null),[C,w]=(0,d.useState)(``),T;n[1]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,f.jsx)(`h2`,{className:`text-xl font-bold`,children:`Versões guardadas`}),n[1]=T):T=n[1];let E;n[2]===r?E=n[3]:(E=e=>{if(w(``),!e.target.value){S(null);return}o(`/api/v1/investment/submissions/${r}/revisions/${e.target.value}`).then(S).catch(()=>w(`Não foi possível consultar esta versão.`))},n[2]=r,n[3]=E);let D;n[4]===Symbol.for(`react.memo_cache_sentinel`)?(D=(0,f.jsx)(`option`,{value:``,children:`Seleccionar versão`}),n[4]=D):D=n[4];let O;n[5]===v?O=n[6]:(O=v.map(_),n[5]=v,n[6]=O);let k;n[7]!==E||n[8]!==O?(k=(0,f.jsx)(c,{label:`Consultar versão`,children:(0,f.jsxs)(`select`,{className:s,defaultValue:``,onChange:E,children:[D,O]})}),n[7]=E,n[8]=O,n[9]=k):k=n[9];let A;n[10]===C?A=n[11]:(A=C&&(0,f.jsx)(`p`,{role:`alert`,children:C}),n[10]=C,n[11]=A);let j;n[12]===x?j=n[13]:(j=x&&(0,f.jsxs)(`div`,{className:`space-y-2`,children:[(0,f.jsxs)(`h3`,{className:`font-bold`,children:[`Versão `,x.version]}),(0,f.jsxs)(`p`,{children:[`Investidor: `,x.snapshot.payload.full_name]}),(0,f.jsxs)(`p`,{children:[`Empresa:`,` `,x.snapshot.payload.organisation||`Não indicada`]}),(0,f.jsxs)(`p`,{className:`whitespace-pre-line`,children:[`Objectivo:`,` `,x.snapshot.payload.objective||`Não indicado`]}),(0,f.jsxs)(`p`,{children:[`Prazo:`,` `,x.snapshot.payload.horizon||`Não indicado`]}),(0,f.jsx)(`ul`,{children:x.snapshot.needs.map(g)}),(0,f.jsxs)(`p`,{children:[x.snapshot.attachment_ids.length,` anexos associados nessa versão.`]})]}),n[12]=x,n[13]=j);let M;n[14]!==k||n[15]!==A||n[16]!==j?(M=(0,f.jsxs)(`section`,{className:a+` space-y-4`,children:[T,k,A,j]}),n[14]=k,n[15]=A,n[16]=j,n[17]=M):M=n[17];let N;n[18]!==b||n[19]!==r||n[20]!==i||n[21]!==p?(N=p&&(0,f.jsxs)(`section`,{className:`rounded-xl border border-slate-200 bg-white p-5 shadow-sm space-y-4`,children:[(0,f.jsx)(`h2`,{className:`text-xl font-bold`,children:`Conversa com o apoio`}),(0,f.jsx)(`p`,{children:`As mensagens ficam registadas neste pedido e são visíveis ao investidor e à equipa autorizada.`}),i.map(h),!i.length&&(0,f.jsx)(`p`,{children:`Ainda não existem mensagens neste pedido.`}),(0,f.jsxs)(`form`,{className:`space-y-3`,onSubmit:e=>{e.preventDefault(),b.post(`/investidor/manifestacoes/${r}/messages`,{preserveScroll:!0,onSuccess:()=>b.setData({client_key:l(),body:``})})},children:[(0,f.jsx)(c,{label:`Mensagem para acompanhamento`,children:(0,f.jsx)(`textarea`,{className:`w-full rounded-lg border border-slate-300 bg-white px-3 py-2 text-slate-900 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-emerald-700`,rows:4,required:!0,minLength:3,maxLength:5e3,value:b.data.body,onChange:e=>b.setData(`body`,e.target.value)})}),Object.entries(b.errors).map(m),(0,f.jsx)(`button`,{className:`inline-flex items-center justify-center rounded-lg bg-emerald-800 px-4 py-2 font-semibold text-white disabled:opacity-50 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-emerald-700`,disabled:b.processing,children:`Enviar mensagem`})]})]}),n[18]=b,n[19]=r,n[20]=i,n[21]=p,n[22]=N):N=n[22];let P;return n[23]!==N||n[24]!==M?(P=(0,f.jsxs)(f.Fragment,{children:[M,N]}),n[23]=N,n[24]=M,n[25]=P):P=n[25],P}function m(e){let[t,n]=e;return(0,f.jsx)(`p`,{role:`alert`,children:n},t)}function h(e){return(0,f.jsxs)(`article`,{className:`rounded-lg border p-4`,children:[(0,f.jsxs)(`p`,{className:`font-semibold`,children:[e.sender_role===`support`?`Apoio ao Investidor`:`Investidor`,` `,`·`,` `,new Date(e.created_at).toLocaleString(`pt-MZ`)]}),(0,f.jsx)(`p`,{className:`mt-2 whitespace-pre-line`,children:e.body})]},e.id)}function g(e,t){return(0,f.jsx)(`li`,{children:e.details.description},t)}function _(e){return(0,f.jsxs)(`option`,{value:e.version,children:[`Versão `,e.version,` —`,` `,new Date(e.created_at).toLocaleString(`pt-MZ`)]},e.version)}export{p as Conversation};
|
||||
+1
File diff suppressed because one or more lines are too long
+1
@@ -0,0 +1 @@
|
||||
import{i as e}from"./rolldown-runtime-Dd_uD5pT.js";import{n as t,t as n}from"./jsx-runtime-BpzPEenQ.js";var r=e(t(),1),i=n();function a({countries:e,value:t,onChange:n,id:a,disabled:o=!1,label:s=`País`,required:c=!1,allowLegacyValue:l=!1,error:u}){let d=(0,r.useId)(),[f,p]=(0,r.useState)(``),m=e.filter(e=>e.code===t||`${e.name} ${e.name_en} ${e.code}`.normalize(`NFD`).replace(/\p{Diacritic}/gu,``).toLowerCase().includes(f.normalize(`NFD`).replace(/\p{Diacritic}/gu,``).toLowerCase()));return(0,i.jsxs)(`div`,{className:`space-y-2`,children:[(0,i.jsx)(`input`,{disabled:o,className:`w-full rounded border p-2`,"aria-label":`Pesquisar ${s.toLowerCase()}`,maxLength:100,value:f,onChange:e=>p(e.target.value),placeholder:`Pesquisar nome ou código do país`}),(0,i.jsxs)(`select`,{disabled:o,id:a??d,"aria-label":s,"aria-invalid":!!u,"aria-describedby":u?(a??d)+`-error`:void 0,required:c,className:`w-full rounded border p-2`,value:t,onChange:e=>n(e.target.value),children:[(0,i.jsx)(`option`,{value:``,children:`Não informado`}),l&&t&&!e.some(e=>e.code===t)&&(0,i.jsxs)(`option`,{value:t,children:[t,` (valor anterior conservado)`]}),m.map(e=>(0,i.jsxs)(`option`,{value:e.code,children:[e.name,` (`,e.code,`)`]},e.code))]}),u&&(0,i.jsx)(`p`,{id:(a??d)+`-error`,role:`alert`,className:`text-red-700`,children:u}),m.length===0&&(0,i.jsx)(`p`,{role:`status`,children:`Nenhum país corresponde à pesquisa.`})]})}export{a as t};
|
||||
+1
@@ -0,0 +1 @@
|
||||
import{i as e}from"./rolldown-runtime-Dd_uD5pT.js";import{n as t}from"./jsx-runtime-BpzPEenQ.js";var n=e(t(),1),r=e=>e.replace(/([a-z0-9])([A-Z])/g,`$1-$2`).toLowerCase(),i=(...e)=>e.filter((e,t,n)=>!!e&&e.trim()!==``&&n.indexOf(e)===t).join(` `).trim(),a={xmlns:`http://www.w3.org/2000/svg`,width:24,height:24,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`},o=(0,n.forwardRef)(({color:e=`currentColor`,size:t=24,strokeWidth:r=2,absoluteStrokeWidth:o,className:s=``,children:c,iconNode:l,...u},d)=>(0,n.createElement)(`svg`,{ref:d,...a,width:t,height:t,stroke:e,strokeWidth:o?Number(r)*24/Number(t):r,className:i(`lucide`,s),...u},[...l.map(([e,t])=>(0,n.createElement)(e,t)),...Array.isArray(c)?c:[c]])),s=(e,t)=>{let a=(0,n.forwardRef)(({className:a,...s},c)=>(0,n.createElement)(o,{ref:c,iconNode:t,className:i(`lucide-${r(e)}`,a),...s}));return a.displayName=`${e}`,a};export{s as t};
|
||||
+1
@@ -0,0 +1 @@
|
||||
import{r as e,u as t}from"./dist-BRfsww6z.js";import{t as n}from"./jsx-runtime-BpzPEenQ.js";import{t as r}from"./compiler-runtime-sKsOXjDo.js";import{Frame as i,button as a,labels as o}from"./shared-Cj9EC3ob.js";var s=r(),c=n();function l(t){let n=(0,s.c)(23),r,o;n[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,c.jsx)(`h2`,{className:`mb-4 text-xl font-bold`,children:`Ideias e propostas`}),o=(0,c.jsx)(e,{className:a,href:`/parcerias/criar`,children:`Preparar uma parceria`}),n[0]=r,n[1]=o):(r=n[0],o=n[1]);let l;n[2]===t.mine?l=n[3]:(l=t.mine.map(p),n[2]=t.mine,n[3]=l);let m;n[4]===l?m=n[5]:(m=(0,c.jsxs)(`section`,{children:[r,o,l]}),n[4]=l,n[5]=m);let h;n[6]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,c.jsx)(`h2`,{className:`text-xl font-bold`,children:`As minhas candidaturas`}),n[6]=h):h=n[6];let g;n[7]===t.interests?g=n[8]:(g=t.interests.map(f),n[7]=t.interests,n[8]=g);let _;n[9]===g?_=n[10]:(_=(0,c.jsxs)(`section`,{children:[h,g]}),n[9]=g,n[10]=_);let v;n[11]===t.moderation?v=n[12]:(v=t.moderation.length>0&&(0,c.jsxs)(`section`,{children:[(0,c.jsx)(`h2`,{className:`text-xl font-bold`,children:`Fila de moderação`}),t.moderation.map(d)]}),n[11]=t.moderation,n[12]=v);let y;n[13]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,c.jsx)(`h2`,{className:`text-xl font-bold`,children:`Notificações no portal`}),n[13]=y):y=n[13];let b;n[14]===t.notifications?b=n[15]:(b=t.notifications.map(u),n[14]=t.notifications,n[15]=b);let x;n[16]===b?x=n[17]:(x=(0,c.jsxs)(`section`,{children:[y,b]}),n[16]=b,n[17]=x);let S;return n[18]!==x||n[19]!==m||n[20]!==_||n[21]!==v?(S=(0,c.jsx)(i,{title:`O meu painel de parcerias`,children:(0,c.jsxs)(`div`,{className:`space-y-8`,children:[m,_,v,x]})}),n[18]=x,n[19]=m,n[20]=_,n[21]=v,n[22]=S):S=n[22],S}function u(n){return(0,c.jsxs)(`article`,{className:`my-3 rounded border p-3`,children:[(0,c.jsx)(e,{href:n.href,className:`underline`,children:n.title}),!n.read_at&&(0,c.jsx)(`button`,{className:`ml-4 underline`,onClick:()=>t.post(`/parcerias/notificacoes/`+n.id+`/ler`),children:`Marcar como lida`})]},n.id)}function d(t){return(0,c.jsx)(`p`,{children:(0,c.jsxs)(e,{className:`underline`,href:`/parcerias/`+t.id,children:[t.title,` · `,o[t.status]]})},t.id)}function f(t){return(0,c.jsxs)(`article`,{className:`my-4 rounded border p-4`,children:[(0,c.jsx)(e,{className:`underline`,href:`/parcerias/`+t.partnership_id,children:t.title}),(0,c.jsxs)(`p`,{children:[o[t.status],` · `,t.decision_reason]}),t.room_id&&(0,c.jsx)(e,{className:`inline-flex rounded bg-emerald-800 px-4 py-2 text-white disabled:opacity-50`,href:`/parcerias/salas/`+t.room_id,children:`Abrir conexão privada`})]},t.id)}function p(t){return(0,c.jsxs)(`article`,{className:`mt-4 rounded border p-4`,children:[(0,c.jsx)(e,{className:`font-semibold underline`,href:`/parcerias/`+t.id,children:t.title||`Ideia sem título`}),(0,c.jsx)(`p`,{children:o[t.status]??t.status}),(0,c.jsxs)(`p`,{children:[`Próxima ação:`,` `,[`draft`,`returned`,`rejected`].includes(t.status)?`Completar e pré-visualizar para submissão`:t.status===`published`?`Consultar candidatos e esclarecer pendências`:`Acompanhar a decisão`]})]},t.id)}export{l as default};
|
||||
+1
File diff suppressed because one or more lines are too long
+1
File diff suppressed because one or more lines are too long
+1
File diff suppressed because one or more lines are too long
+1
File diff suppressed because one or more lines are too long
+1
@@ -0,0 +1 @@
|
||||
import"./rolldown-runtime-Dd_uD5pT.js";import{n as e,t}from"./jsx-runtime-BpzPEenQ.js";import{t as n}from"./compiler-runtime-sKsOXjDo.js";import{t as r}from"./utils-CCDJ05Ll.js";import{_ as i,d as a,f as o,g as s,h as c,m as l,p as u,v as d,x as f}from"./app-CdqBMdkz.js";var p=n();e();var m=t();function h(e){let t=(0,p.c)(4),n;t[0]===e?n=t[1]:({...n}=e,t[0]=e,t[1]=n);let r;return t[2]===n?r=t[3]:(r=(0,m.jsx)(a,{"data-slot":`dialog`,...n}),t[2]=n,t[3]=r),r}function g(e){let t=(0,p.c)(4),n;t[0]===e?n=t[1]:({...n}=e,t[0]=e,t[1]=n);let r;return t[2]===n?r=t[3]:(r=(0,m.jsx)(d,{"data-slot":`dialog-trigger`,...n}),t[2]=n,t[3]=r),r}function _(e){let t=(0,p.c)(4),n;t[0]===e?n=t[1]:({...n}=e,t[0]=e,t[1]=n);let r;return t[2]===n?r=t[3]:(r=(0,m.jsx)(s,{"data-slot":`dialog-portal`,...n}),t[2]=n,t[3]=r),r}function v(e){let t=(0,p.c)(4),n;t[0]===e?n=t[1]:({...n}=e,t[0]=e,t[1]=n);let r;return t[2]===n?r=t[3]:(r=(0,m.jsx)(o,{"data-slot":`dialog-close`,...n}),t[2]=n,t[3]=r),r}function y(e){let t=(0,p.c)(8),n,i;t[0]===e?(n=t[1],i=t[2]):({className:n,...i}=e,t[0]=e,t[1]=n,t[2]=i);let a;t[3]===n?a=t[4]:(a=r(`data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/80`,n),t[3]=n,t[4]=a);let o;return t[5]!==i||t[6]!==a?(o=(0,m.jsx)(c,{"data-slot":`dialog-overlay`,className:a,...i}),t[5]=i,t[6]=a,t[7]=o):o=t[7],o}function b(e){let t=(0,p.c)(12),n,i,a;t[0]===e?(n=t[1],i=t[2],a=t[3]):({className:i,children:n,...a}=e,t[0]=e,t[1]=n,t[2]=i,t[3]=a);let s;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,m.jsx)(y,{}),t[4]=s):s=t[4];let c;t[5]===i?c=t[6]:(c=r(`bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 sm:max-w-lg`,i),t[5]=i,t[6]=c);let l;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,m.jsxs)(o,{className:`ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,children:[(0,m.jsx)(f,{}),(0,m.jsx)(`span`,{className:`sr-only`,children:`Close`})]}),t[7]=l):l=t[7];let d;return t[8]!==n||t[9]!==a||t[10]!==c?(d=(0,m.jsxs)(_,{"data-slot":`dialog-portal`,children:[s,(0,m.jsxs)(u,{"data-slot":`dialog-content`,className:c,...a,children:[n,l]})]}),t[8]=n,t[9]=a,t[10]=c,t[11]=d):d=t[11],d}function x(e){let t=(0,p.c)(8),n,i;t[0]===e?(n=t[1],i=t[2]):({className:n,...i}=e,t[0]=e,t[1]=n,t[2]=i);let a;t[3]===n?a=t[4]:(a=r(`flex flex-col gap-2 text-center sm:text-left`,n),t[3]=n,t[4]=a);let o;return t[5]!==i||t[6]!==a?(o=(0,m.jsx)(`div`,{"data-slot":`dialog-header`,className:a,...i}),t[5]=i,t[6]=a,t[7]=o):o=t[7],o}function S(e){let t=(0,p.c)(8),n,i;t[0]===e?(n=t[1],i=t[2]):({className:n,...i}=e,t[0]=e,t[1]=n,t[2]=i);let a;t[3]===n?a=t[4]:(a=r(`flex flex-col-reverse gap-2 sm:flex-row sm:justify-end`,n),t[3]=n,t[4]=a);let o;return t[5]!==i||t[6]!==a?(o=(0,m.jsx)(`div`,{"data-slot":`dialog-footer`,className:a,...i}),t[5]=i,t[6]=a,t[7]=o):o=t[7],o}function C(e){let t=(0,p.c)(8),n,a;t[0]===e?(n=t[1],a=t[2]):({className:n,...a}=e,t[0]=e,t[1]=n,t[2]=a);let o;t[3]===n?o=t[4]:(o=r(`text-lg leading-none font-semibold`,n),t[3]=n,t[4]=o);let s;return t[5]!==a||t[6]!==o?(s=(0,m.jsx)(i,{"data-slot":`dialog-title`,className:o,...a}),t[5]=a,t[6]=o,t[7]=s):s=t[7],s}function w(e){let t=(0,p.c)(8),n,i;t[0]===e?(n=t[1],i=t[2]):({className:n,...i}=e,t[0]=e,t[1]=n,t[2]=i);let a;t[3]===n?a=t[4]:(a=r(`text-muted-foreground text-sm`,n),t[3]=n,t[4]=a);let o;return t[5]!==i||t[6]!==a?(o=(0,m.jsx)(l,{"data-slot":`dialog-description`,className:a,...i}),t[5]=i,t[6]=a,t[7]=o):o=t[7],o}export{S as a,g as c,w as i,v as n,x as o,b as r,C as s,h as t};
|
||||
+1
@@ -0,0 +1 @@
|
||||
function e(e,t=``){return typeof e==`string`?e:typeof e==`number`&&Number.isFinite(e)||typeof e==`boolean`?String(e):t}export{e as t};
|
||||
+97
File diff suppressed because one or more lines are too long
+1
@@ -0,0 +1 @@
|
||||
import{i as e}from"./rolldown-runtime-Dd_uD5pT.js";import{l as t}from"./dist-BRfsww6z.js";import{n,t as r}from"./jsx-runtime-BpzPEenQ.js";import{i}from"./button-DAU4R6e9.js";var a=e(n(),1),o=e(t(),1),s=r(),c=Object.defineProperty,l=(e,t)=>c(e,`name`,{value:t,configurable:!0}),u=[`a`,`button`,`div`,`form`,`h2`,`h3`,`img`,`input`,`label`,`li`,`nav`,`ol`,`p`,`select`,`span`,`svg`,`ul`].reduce((e,t)=>{let n=i(`Primitive.${t}`),r=a.forwardRef((e,r)=>{let{asChild:i,...a}=e,o=i?n:t;return typeof window<`u`&&(window[Symbol.for(`radix-ui`)]=!0),(0,s.jsx)(o,{...a,ref:r})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function d(e,t){e&&o.flushSync(()=>e.dispatchEvent(t))}l(d,`dispatchDiscreteCustomEvent`);export{d as n,u as t};
|
||||
+1
File diff suppressed because one or more lines are too long
+1
File diff suppressed because one or more lines are too long
+1
File diff suppressed because one or more lines are too long
+1
File diff suppressed because one or more lines are too long
+1
File diff suppressed because one or more lines are too long
+1
File diff suppressed because one or more lines are too long
+2
File diff suppressed because one or more lines are too long
+61
@@ -0,0 +1,61 @@
|
||||
@font-face {
|
||||
font-family: "Instrument Sans";
|
||||
font-style: normal;
|
||||
font-weight: 400;
|
||||
font-display: swap;
|
||||
src: url("/build/assets/instrument-sans-400-normal-DRC__1Mx.woff2") format("woff2");
|
||||
unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: "Instrument Sans";
|
||||
font-style: normal;
|
||||
font-weight: 400;
|
||||
font-display: swap;
|
||||
src: url("/build/assets/instrument-sans-400-normal-D1W7dsQl.woff") format("woff");
|
||||
unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: "Instrument Sans";
|
||||
font-style: normal;
|
||||
font-weight: 500;
|
||||
font-display: swap;
|
||||
src: url("/build/assets/instrument-sans-500-normal-Dk9ku72i.woff2") format("woff2");
|
||||
unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: "Instrument Sans";
|
||||
font-style: normal;
|
||||
font-weight: 500;
|
||||
font-display: swap;
|
||||
src: url("/build/assets/instrument-sans-500-normal-Z6ESRlEs.woff") format("woff");
|
||||
unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: "Instrument Sans";
|
||||
font-style: normal;
|
||||
font-weight: 600;
|
||||
font-display: swap;
|
||||
src: url("/build/assets/instrument-sans-600-normal-B7fBEWYG.woff2") format("woff2");
|
||||
unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: "Instrument Sans";
|
||||
font-style: normal;
|
||||
font-weight: 600;
|
||||
font-display: swap;
|
||||
src: url("/build/assets/instrument-sans-600-normal-B9e8oLYv.woff") format("woff");
|
||||
unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
|
||||
}
|
||||
|
||||
:root {
|
||||
--font-instrument-sans: "Instrument Sans";
|
||||
}
|
||||
|
||||
.font-instrument-sans {
|
||||
font-family: var(--font-instrument-sans);
|
||||
}
|
||||
+1
@@ -0,0 +1 @@
|
||||
import{n as e,t}from"./dist-BRfsww6z.js";import{t as n}from"./jsx-runtime-BpzPEenQ.js";import{t as r}from"./compiler-runtime-sKsOXjDo.js";import{t as i}from"./button-DAU4R6e9.js";import{t as a}from"./loader-circle-DS8Tf4er.js";import{b as o,s}from"./app-CdqBMdkz.js";import{t as c}from"./input-error-U1QKS0ED.js";import{t as l}from"./label-D-C_NQs4.js";import{t as u}from"./text-link-BBvcP60s.js";import{t as d}from"./password-CB_NxgQN.js";var f=r(),p=n();function m(n){let r=(0,f.c)(8),{status:i}=n,a;r[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,p.jsx)(e,{title:`Forgot password`}),r[0]=a):a=r[0];let o;r[1]===i?o=r[2]:(o=i&&(0,p.jsx)(`div`,{className:`mb-4 text-center text-sm font-medium text-green-600`,children:i}),r[1]=i,r[2]=o);let c;r[3]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,p.jsx)(t,{...d.form(),children:h}),r[3]=c):c=r[3];let l;r[4]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,p.jsx)(`span`,{children:`Or, return to`}),r[4]=l):l=r[4];let m;r[5]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,p.jsxs)(`div`,{className:`space-y-6`,children:[c,(0,p.jsxs)(`div`,{className:`text-muted-foreground space-x-1 text-center text-sm`,children:[l,(0,p.jsx)(u,{href:s(),children:`log in`})]})]}),r[5]=m):m=r[5];let g;return r[6]===o?g=r[7]:(g=(0,p.jsxs)(p.Fragment,{children:[a,o,m]}),r[6]=o,r[7]=g),g}function h(e){let{processing:t,errors:n}=e;return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(`div`,{className:`grid gap-2`,children:[(0,p.jsx)(l,{htmlFor:`email`,children:`Email address`}),(0,p.jsx)(o,{id:`email`,type:`email`,name:`email`,autoComplete:`off`,autoFocus:!0,placeholder:`email@example.com`}),(0,p.jsx)(c,{message:n.email})]}),(0,p.jsx)(`div`,{className:`my-6 flex items-center justify-start`,children:(0,p.jsxs)(i,{className:`w-full`,disabled:t,"data-test":`email-password-reset-link-button`,children:[t&&(0,p.jsx)(a,{className:`h-4 w-4 animate-spin`}),`Email password reset link`]})})]})}m.layout={title:`Forgot password`,description:`Enter your email to receive a password reset link`};export{m as default};
|
||||
+1
File diff suppressed because one or more lines are too long
+1
@@ -0,0 +1 @@
|
||||
import{r as e}from"./dist-BRfsww6z.js";import{t}from"./jsx-runtime-BpzPEenQ.js";import{t as n}from"./compiler-runtime-sKsOXjDo.js";var r=n(),i=t();function a(t){let n=(0,r.c)(13),{disclaimer:a}=t,o,s,c;n[0]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,i.jsx)(`p`,{className:`text-sm font-semibold tracking-wide uppercase`,children:`InvestMoz · orientação informativa`}),s=(0,i.jsx)(`h1`,{className:`text-3xl font-bold`,children:`Terra e DUAT`}),c=(0,i.jsx)(`p`,{children:`Prepare informação sobre uma área, um pedido ou um processo que já acompanha. Pode indicar dúvidas e dados por confirmar.`}),n[0]=o,n[1]=s,n[2]=c):(o=n[0],s=n[1],c=n[2]);let l;n[3]===a?l=n[4]:(l=(0,i.jsxs)(`header`,{className:`space-y-3`,children:[o,s,c,(0,i.jsx)(`p`,{className:`rounded border border-amber-400 bg-amber-50 p-4 text-sm`,children:a})]}),n[3]=a,n[4]=l);let u;n[5]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,i.jsxs)(`article`,{className:`rounded border p-4`,children:[(0,i.jsx)(`h2`,{className:`font-semibold`,children:`Preparar informação`}),(0,i.jsx)(`p`,{children:`Identifique a finalidade, o requerente, a localização conhecida e os antecedentes que tiver.`})]}),n[5]=u):u=n[5];let d;n[6]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,i.jsxs)(`article`,{className:`rounded border p-4`,children:[(0,i.jsx)(`h2`,{className:`font-semibold`,children:`Organizar documentos`}),(0,i.jsx)(`p`,{children:`Anexos são opcionais nesta fase. A lista não substitui os requisitos confirmados pela entidade competente.`})]}),n[6]=d):d=n[6];let f,p;n[7]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,i.jsxs)(`section`,{className:`grid gap-4 md:grid-cols-3`,children:[u,d,(0,i.jsxs)(`article`,{className:`rounded border p-4`,children:[(0,i.jsx)(`h2`,{className:`font-semibold`,children:`Acompanhar`}),(0,i.jsx)(`p`,{children:`Guarde uma referência interna e registe separadamente informações comunicadas por si e diligências internas.`})]})]}),p=(0,i.jsx)(`p`,{className:`rounded bg-slate-50 p-4`,children:`Não inferimos que uma área está livre, que não existem direitos ou conflitos, nem que um registo ou mapa confirma titularidade. O InvestMoz não atribui DUAT nem substitui a autoridade pública.`}),n[7]=f,n[8]=p):(f=n[7],p=n[8]);let m;n[9]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,i.jsxs)(`nav`,{className:`flex flex-wrap gap-4`,children:[(0,i.jsx)(e,{className:`rounded bg-emerald-800 px-4 py-3 text-white`,href:`/investidor/terra-duat/novo`,children:`Preencher no portal`}),(0,i.jsx)(e,{className:`rounded border px-4 py-3`,href:`/terra-duat/formulario-em-branco`,children:`Descarregar formulário em branco (imprimir/guardar como PDF)`}),(0,i.jsx)(e,{className:`rounded border px-4 py-3`,href:`/apoio`,children:`Solicitar apoio geral`})]}),n[9]=m):m=n[9];let h;n[10]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,i.jsxs)(`details`,{className:`rounded border p-4`,children:[(0,i.jsx)(`summary`,{className:`cursor-pointer font-semibold`,children:`Estado das fontes e requisitos`}),(0,i.jsx)(`p`,{className:`mt-3`,children:`Os modelos digitalizados estão inventariados como referências reservadas. Conteúdo, actualidade e requisitos legais aguardam OCR, conferência oficial e revisão. Não use esta orientação como checklist oficial.`})]}),n[10]=h):h=n[10];let g;return n[11]===l?g=n[12]:(g=(0,i.jsxs)(`main`,{className:`mx-auto max-w-5xl space-y-8 p-6 print:p-0`,children:[l,f,p,m,h]}),n[11]=l,n[12]=g),g}export{a as default};
|
||||
+1
@@ -0,0 +1 @@
|
||||
import{t as e}from"./jsx-runtime-BpzPEenQ.js";import{t}from"./compiler-runtime-sKsOXjDo.js";import{n,r}from"./shared-D-va8joy.js";var i=t(),a=e(),o={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`},s={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 c(e){return e==null?`—`:typeof e==`boolean`?e?`Sim`:`Não`:typeof e==`object`?JSON.stringify(e):typeof e==`string`?e:typeof e==`number`?e.toString():`—`}function l(e){let t=(0,i.c)(13),{events:o}=e,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,a.jsx)(`p`,{className:`text-muted-foreground`,children:`Alterações efectuadas na gestão do portal. Os textos e contactos pessoais não são copiados para o histórico.`}),t[0]=s):s=t[0];let c;t[1]===o.data?c=t[2]:(c=o.data.map(u),t[1]=o.data,t[2]=c);let l;t[3]===c?l=t[4]:(l=(0,a.jsx)(`div`,{className:`space-y-4`,children:c}),t[3]=c,t[4]=l);let d;t[5]===o.data.length?d=t[6]:(d=!o.data.length&&(0,a.jsx)(`p`,{children:`Ainda não existem alterações registadas.`}),t[5]=o.data.length,t[6]=d);let f;t[7]===o?f=t[8]:(f=(0,a.jsx)(r,{page:o}),t[7]=o,t[8]=f);let p;return t[9]!==l||t[10]!==d||t[11]!==f?(p=(0,a.jsxs)(n,{title:`Histórico de alterações`,children:[s,l,d,f]}),t[9]=l,t[10]=d,t[11]=f,t[12]=p):p=t[12],p}function u(e){return(0,a.jsxs)(`article`,{className:`space-y-2 rounded border p-4`,children:[(0,a.jsxs)(`h2`,{className:`font-semibold break-words`,children:[o[e.entity_type]??e.entity_type,` #`,e.after_data.record_id,` ·`,` `,e.action===`created`?`Criado`:`Actualizado`]}),(0,a.jsxs)(`p`,{children:[e.actor??`Utilizador indisponível`,` ·`,` `,new Intl.DateTimeFormat(`pt-MZ`,{dateStyle:`medium`,timeStyle:`short`,timeZone:`Africa/Maputo`}).format(new Date(e.occurred_at)),` `,`(Maputo)`]}),(0,a.jsxs)(`p`,{className:`text-sm break-words`,children:[`Campos:`,` `,e.after_data.changed_fields.map(d).join(`, `)]}),Object.entries(e.after_data.values).filter(t=>{let[n,r]=t;return JSON.stringify(e.before_data.values[n])!==JSON.stringify(r)}).map(t=>{let[n,r]=t;return(0,a.jsxs)(`p`,{className:`text-sm break-words`,children:[s[n]??n,`:`,` `,c(e.before_data.values[n]??`—`),` `,`→ `,c(r)]},n)})]},e.id)}function d(e){return s[e]??e}export{l as default};
|
||||
+1
@@ -0,0 +1 @@
|
||||
import{t as e}from"./jsx-runtime-BpzPEenQ.js";import{t}from"./utils-CCDJ05Ll.js";var n=e();function r({message:e,className:r=``,...i}){return e?(0,n.jsx)(`p`,{...i,className:t(`text-sm text-red-600 dark:text-red-400`,r),children:e}):null}export{r as t};
|
||||
+1
File diff suppressed because one or more lines are too long
+1
@@ -0,0 +1 @@
|
||||
import{i as e}from"./rolldown-runtime-Dd_uD5pT.js";import{n as t,t as n}from"./jsx-runtime-BpzPEenQ.js";import{a as r,i,n as a}from"./shared-D-va8joy.js";import{t as o}from"./operation-key-Dr4VtGxa.js";import{n as s}from"./profile-json-Bb5H6-rZ.js";var c=e(t(),1),l=n();function u(e){let[t,n]=(0,c.useState)(e),[u,d]=(0,c.useState)(``),[f,p]=(0,c.useState)(!1),[m,h]=(0,c.useState)(``),[g,_]=(0,c.useState)(``),[v,y]=(0,c.useState)(!1),[b,x]=(0,c.useState)(``),[S]=(0,c.useState)(o),[C]=(0,c.useState)(o);async function w(e=!1){y(!0),x(``);try{let r=await s(`/management/profile-install`+(e?`/bootstrap`:``),{hash:t.hash,confirm:f,reason:u,idempotency_key:e?C:S,...e?{first_user_id:Number(m),second_user_id:Number(g)}:{}});x(e?`Dupla inicializada. Inicie uma nova sessão como um dos titulares designados; MFA permanece obrigatório.`:r.changed?`Schema instalado. Perfis ainda não disponibilizados; nenhuma conta ou atribuição criada.`:`Schema já instalado. Nenhuma reinstalação ou duplicação.`),e||n(await s(`/management/profile-install`,{},`GET`)),p(!1)}catch(e){x(e instanceof Error?e.message:`Resposta indisponível; consulte o estado antes de repetir.`)}finally{y(!1)}}return(0,l.jsxs)(a,{title:`Instalação dos perfis — 040000`,children:[(0,l.jsxs)(`p`,{children:[`Base `,t.target.database,`:`,t.target.port,` ·`,` `,t.installed?`Schema instalado`:`Schema por instalar`]}),(0,l.jsxs)(`p`,{children:[`Preparação:`,` `,t.ready?`Provas atuais verificadas`:`Dependências ou provas por completar`,`. Preparação não significa instalação ou disponibilização dos perfis.`]}),!t.consistent&&(0,l.jsx)(`p`,{role:`alert`,children:`Ledger e schema divergem. Recuperar a consistência antes de instalar.`}),(0,l.jsx)(`ul`,{children:Object.entries(t.dependencies).map(([e,t])=>(0,l.jsxs)(`li`,{children:[e,`: `,t?`presente`:`pendente`]},e))}),(0,l.jsx)(`ul`,{children:t.changes.map(e=>(0,l.jsx)(`li`,{children:e},e))}),(0,l.jsxs)(`p`,{children:[`Backup/restauro: `,t.backupDate??`Prova atual pendente`]}),(0,l.jsx)(`p`,{children:t.rollback}),(0,l.jsxs)(`label`,{className:`block`,children:[`Fundamento`,(0,l.jsx)(`textarea`,{className:r,value:u,minLength:20,maxLength:1e3,onChange:e=>d(e.target.value)})]}),(0,l.jsxs)(`label`,{className:`block`,children:[(0,l.jsx)(`input`,{type:`checkbox`,checked:f,onChange:e=>p(e.target.checked)}),` `,`Confirmo exclusivamente a ação indicada nesta base`]}),(0,l.jsx)(`button`,{className:i,disabled:v||!f||!t.ready||t.installed||!t.consistent||u.length<20,onClick:()=>void w(),children:`Instalar schema 040000`}),(0,l.jsxs)(`section`,{className:`space-y-3 rounded border p-4`,children:[(0,l.jsx)(`h2`,{children:`Inicialização separada dos dois superutilizadores`}),(0,l.jsx)(`p`,{children:t.bootstrap.rule}),t.bootstrap.initialized?(0,l.jsxs)(`p`,{children:[`Dupla já inicializada:`,` `,t.bootstrap.holders.join(` e `),`; versão`,` `,t.bootstrap.version,`. Use a substituição atómica autorizada; não reinicialize.`]}):(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(`label`,{className:`block`,children:[`ID da primeira conta explicitamente designada`,(0,l.jsx)(`input`,{className:r,type:`number`,min:1,value:m,onChange:e=>h(e.target.value)})]}),(0,l.jsxs)(`label`,{className:`block`,children:[`ID da segunda conta explicitamente designada`,(0,l.jsx)(`input`,{className:r,type:`number`,min:1,value:g,onChange:e=>_(e.target.value)})]}),(0,l.jsx)(`button`,{className:i,disabled:v||!f||!t.installed||!m||!g||m===g||u.length<20,onClick:()=>void w(!0),children:`Inicializar apenas estas duas contas`})]})]}),(0,l.jsx)(`p`,{role:`status`,children:b})]})}export{u as default};
|
||||
+1
@@ -0,0 +1 @@
|
||||
import{o as e,r as t}from"./dist-BRfsww6z.js";import{t as n}from"./jsx-runtime-BpzPEenQ.js";import{t as r}from"./compiler-runtime-sKsOXjDo.js";import{n as i}from"./shared-D-va8joy.js";import{Errors as a,labels as o}from"./shared-Cj9EC3ob.js";var s=r(),c=n();function l(n){let r=(0,s.c)(33),o;r[0]===n.hash?o=r[1]:(o={hash:n.hash},r[0]=n.hash,r[1]=o);let l=e(o),f=n.installed?`Instalada`:`Preparada para aplicação autenticada`,p;r[2]!==n.target.database||r[3]!==n.target.port||r[4]!==f?(p=(0,c.jsxs)(`p`,{children:[`Destino: `,n.target.database,`:`,n.target.port,`. Estado:`,` `,f,`.`]}),r[2]=n.target.database,r[3]=n.target.port,r[4]=f,r[5]=p):p=r[5];let m=n.backupVerified?`Comprovados`:`Pendentes`,h=n.qaVerified?`Comprovada`:`Pendente`,g;r[6]!==n.backupDate||r[7]!==m||r[8]!==h?(g=(0,c.jsxs)(`p`,{children:[`Backup e restauro:`,` `,m,` ·`,` `,n.backupDate,`. QA desta versão:`,` `,h,`.`]}),r[6]=n.backupDate,r[7]=m,r[8]=h,r[9]=g):g=r[9];let _;r[10]===n.changes?_=r[11]:(_=n.changes.map(d),r[10]=n.changes,r[11]=_);let v;r[12]===_?v=r[13]:(v=(0,c.jsx)(`ul`,{className:`list-disc pl-5`,children:_}),r[12]=_,r[13]=v);let y;r[14]===n.records.length?y=r[15]:(y=(0,c.jsxs)(`h2`,{className:`text-xl font-bold`,children:[`Propostas antigas a preservar: `,n.records.length]}),r[14]=n.records.length,r[15]=y);let b;r[16]===n.records?b=r[17]:(b=n.records.map(u),r[16]=n.records,r[17]=b);let x;r[18]!==l||r[19]!==n.backupVerified||r[20]!==n.installed||r[21]!==n.qaVerified?(x=!n.installed&&(0,c.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),l.post(`/management/partnerships-install`)},children:[(0,c.jsx)(a,{errors:l.errors}),(0,c.jsx)(`button`,{className:`inline-flex rounded bg-emerald-800 px-4 py-2 text-white disabled:opacity-50`,disabled:l.processing||!n.backupVerified||!n.qaVerified,children:`Aplicar módulo preservando propostas`})]}),r[18]=l,r[19]=n.backupVerified,r[20]=n.installed,r[21]=n.qaVerified,r[22]=x):x=r[22];let S;r[23]===n.installed?S=r[24]:(S=n.installed&&(0,c.jsx)(t,{href:`/parcerias/painel`,className:`underline`,children:`Abrir painel da Bolsa`}),r[23]=n.installed,r[24]=S);let C;return r[25]!==x||r[26]!==S||r[27]!==p||r[28]!==g||r[29]!==v||r[30]!==y||r[31]!==b?(C=(0,c.jsx)(i,{title:`Aplicação da Bolsa de Parcerias`,children:(0,c.jsxs)(`div`,{className:`space-y-5`,children:[p,g,v,y,b,x,S]})}),r[25]=x,r[26]=S,r[27]=p,r[28]=g,r[29]=v,r[30]=y,r[31]=b,r[32]=C):C=r[32],C}function u(e){return(0,c.jsxs)(`p`,{children:[e.id,` · `,e.title,` · Autor `,e.user_id,` ·`,` `,o[e.status]??e.status]},e.id)}function d(e){return(0,c.jsx)(`li`,{children:e},e)}export{l as default};
|
||||
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
+1
File diff suppressed because one or more lines are too long
+2
File diff suppressed because one or more lines are too long
+1
File diff suppressed because one or more lines are too long
+1
File diff suppressed because one or more lines are too long
+1
@@ -0,0 +1 @@
|
||||
import{i as e}from"./rolldown-runtime-Dd_uD5pT.js";import{n as t,t as n}from"./jsx-runtime-BpzPEenQ.js";import{t as r}from"./compiler-runtime-sKsOXjDo.js";import{t as i}from"./interactive-investment-map-Bo2viMa_.js";import{t as a}from"./territory-geometry-preview-XD0LNOrx.js";var o=r(),s=e(t(),1),c=n();function l(e){let t=(0,o.c)(21),{filters:n,territoryId:r}=e,l;t[0]===n?l=t[1]:(l=JSON.stringify(n),t[0]=n,t[1]=l);let f=l,[p,m]=(0,s.useState)(null),h;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(h=[],t[2]=h):h=t[2];let[g,_]=(0,s.useState)(h),[v,y]=(0,s.useState)(``),b;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(b=[],t[3]=b):b=t[3];let[x,S]=(0,s.useState)(b),C,w;t[4]===f?(C=t[5],w=t[6]):(C=()=>{let e=new AbortController,t=new URLSearchParams(JSON.parse(f));return m(null),S([]),fetch(`/api/v1/investment/map?${t}`,{signal:e.signal,headers:{Accept:`application/json`}}).then(d).then(t=>{e.signal.aborted||(m(t.features),S(t.areas??[]),_(t.unlocated??[]),y(t.truncated?`Cobertura limitada: refine os filtros.`:``))}).catch(t=>{e.signal.aborted||y(t.message)}),()=>e.abort()},w=[f],t[4]=f,t[5]=C,t[6]=w),(0,s.useEffect)(C,w);let T;t[7]===v?T=t[8]:(T=v&&(0,c.jsx)(`p`,{role:`alert`,children:v}),t[7]=v,t[8]=T);let E;t[9]!==x||t[10]!==p?(E=(0,c.jsx)(i,{points:p,areas:x}),t[9]=x,t[10]=p,t[11]=E):E=t[11];let D=r||String(n.locality_id||n.admin_post_id||n.district_id||n.province_id||n.geo_location_id||``),O;t[12]===D?O=t[13]:(O=(0,c.jsx)(a,{territoryId:D}),t[12]=D,t[13]=O);let k;t[14]===g?k=t[15]:(k=g.length>0&&(0,c.jsxs)(`div`,{children:[(0,c.jsxs)(`p`,{children:[g.length,` investimentos sem ponto público utilizável. Consulte as fichas para localizações documentadas sem coordenadas:`]}),(0,c.jsx)(`ul`,{children:g.map(u)})]}),t[14]=g,t[15]=k);let A;return t[16]!==k||t[17]!==T||t[18]!==E||t[19]!==O?(A=(0,c.jsxs)(`section`,{className:`space-y-3`,children:[T,E,O,k]}),t[16]=k,t[17]=T,t[18]=E,t[19]=O,t[20]=A):A=t[20],A}function u(e){return(0,c.jsx)(`li`,{children:(0,c.jsx)(`a`,{href:e.url,className:`underline`,children:e.title})},e.id)}async function d(e){if(!e.ok)throw Error(`Mapa indisponível.`);return e.json()}export{l as t};
|
||||
+1
@@ -0,0 +1 @@
|
||||
var e=[`Ideia identificada`,`Pré-estudo disponível`,`Estudo de viabilidade em curso`,`Projecto estruturado`,`Pronto para investimento`,`Em negociação ou implementação`];export{e as t};
|
||||
+1
File diff suppressed because one or more lines are too long
+1
File diff suppressed because one or more lines are too long
+1
@@ -0,0 +1 @@
|
||||
import{i as e}from"./rolldown-runtime-Dd_uD5pT.js";import{n as t,o as n,r,u as i}from"./dist-BRfsww6z.js";import{n as a,t as o}from"./jsx-runtime-BpzPEenQ.js";import{t as s}from"./compiler-runtime-sKsOXjDo.js";import{t as c}from"./operation-key-Dr4VtGxa.js";var l=s(),u=e(a(),1),d=o();function f(e){let a=(0,l.c)(46),{contexts:o,contentSource:s}=e,[c]=(0,u.useState)(m),f=s?.id,h;a[0]!==c||a[1]!==f?(h={title:``,client_key:c,reuse_consent:!1,content_resource_id:f},a[0]=c,a[1]=f,a[2]=h):h=a[2];let g=n(h),_,v;a[3]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,d.jsx)(t,{title:`Os meus investimentos`}),v=(0,d.jsx)(`h1`,{className:`text-2xl font-semibold`,children:`Os meus investimentos`}),a[3]=_,a[4]=v):(_=a[3],v=a[4]);let y;a[5]===s?y=a[6]:(y=s&&(0,d.jsxs)(`p`,{children:[`Preparar a partir de`,` `,(0,d.jsx)(r,{className:`underline`,href:s.href,children:s.title}),`. A fonte e a versão serão guardadas no dossier escolhido.`]}),a[5]=s,a[6]=y);let b;a[7]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,d.jsx)(`p`,{children:`Prepare cada investimento no seu dossier. Pode trabalhar em várias etapas em paralelo.`}),a[7]=b):b=a[7];let x;if(a[8]!==s||a[9]!==o){let e;a[11]===s?e=a[12]:(e=e=>(0,d.jsxs)(`li`,{className:`rounded-xl border p-4`,children:[(0,d.jsx)(r,{className:`font-semibold underline`,href:`/investimentos/${e.id}`,children:e.title}),(0,d.jsxs)(`p`,{className:`text-sm`,children:[`Guardado em`,` `,new Date(e.updated_at).toLocaleString(`pt-MZ`)]}),s&&(0,d.jsx)(`button`,{type:`button`,className:`mt-3 rounded border p-2`,onClick:()=>i.post(`/investimentos/${e.id}/conteudos`,{version:e.version,resource_id:s.id}),children:`Continuar neste dossier com o artigo`})]},e.id),a[11]=s,a[12]=e),x=o.map(e),a[8]=s,a[9]=o,a[10]=x}else x=a[10];let S;a[13]===x?S=a[14]:(S=(0,d.jsx)(`ul`,{className:`grid gap-4 md:grid-cols-2`,children:x}),a[13]=x,a[14]=S);let C;a[15]===o.length?C=a[16]:(C=!o.length&&(0,d.jsx)(`p`,{children:`Ainda não criou um investimento neste percurso.`}),a[15]=o.length,a[16]=C);let w;a[17]===g?w=a[18]:(w=e=>{e.preventDefault(),g.post(`/investimentos`)},a[17]=g,a[18]=w);let T;a[19]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,d.jsx)(`h2`,{className:`text-lg font-semibold`,children:`Preparar um investimento`}),a[19]=T):T=a[19];let E;a[20]===g?E=a[21]:(E=e=>g.setData(`title`,e.target.value),a[20]=g,a[21]=E);let D;a[22]!==g.data.title||a[23]!==E?(D=(0,d.jsxs)(`label`,{className:`grid gap-1`,children:[`Título`,(0,d.jsx)(`input`,{required:!0,maxLength:200,className:`rounded border p-2`,value:g.data.title,onChange:E})]}),a[22]=g.data.title,a[23]=E,a[24]=D):D=a[24];let O;a[25]===g?O=a[26]:(O=e=>g.setData(`reuse_consent`,e.target.checked),a[25]=g,a[26]=O);let k;a[27]!==g.data.reuse_consent||a[28]!==O?(k=(0,d.jsxs)(`label`,{className:`flex gap-2`,children:[(0,d.jsx)(`input`,{type:`checkbox`,checked:g.data.reuse_consent,onChange:O}),`Autorizo reutilizar o meu perfil neste dossier privado.`]}),a[27]=g.data.reuse_consent,a[28]=O,a[29]=k):k=a[29];let A;a[30]===g.errors?A=a[31]:(A=Object.values(g.errors).map(p),a[30]=g.errors,a[31]=A);let j;a[32]===g.processing?j=a[33]:(j=(0,d.jsx)(`button`,{disabled:g.processing,className:`bg-primary text-primary-foreground rounded px-4 py-2`,children:`Criar e guardar dossier`}),a[32]=g.processing,a[33]=j);let M;a[34]!==w||a[35]!==D||a[36]!==k||a[37]!==A||a[38]!==j?(M=(0,d.jsxs)(`form`,{className:`max-w-xl space-y-4 rounded-xl border p-5`,onSubmit:w,children:[T,D,k,A,j]}),a[34]=w,a[35]=D,a[36]=k,a[37]=A,a[38]=j,a[39]=M):M=a[39];let N;a[40]===Symbol.for(`react.memo_cache_sentinel`)?(N=(0,d.jsxs)(`nav`,{className:`flex flex-wrap gap-4`,"aria-label":`Ferramentas`,children:[(0,d.jsx)(r,{className:`underline`,href:`/simulador-fiscal`,children:`Simulador`}),(0,d.jsx)(r,{className:`underline`,href:`/balcao-virtual/painel`,children:`Balcão`}),(0,d.jsx)(r,{className:`underline`,href:`/investidor`,children:`Oportunidades guardadas`}),(0,d.jsx)(r,{className:`underline`,href:`/dashboard`,children:`Painel`})]}),a[40]=N):N=a[40];let P;return a[41]!==M||a[42]!==y||a[43]!==S||a[44]!==C?(P=(0,d.jsxs)(`main`,{className:`mx-auto max-w-5xl space-y-6 p-4 md:p-8`,children:[_,v,y,b,S,C,M,N]}),a[41]=M,a[42]=y,a[43]=S,a[44]=C,a[45]=P):P=a[45],P}function p(e,t){return(0,d.jsx)(`p`,{role:`alert`,children:e},t)}function m(){return c()}export{f as default};
|
||||
+1
@@ -0,0 +1 @@
|
||||
import{o as e,r as t}from"./dist-BRfsww6z.js";import{t as n}from"./jsx-runtime-BpzPEenQ.js";import{t as r}from"./compiler-runtime-sKsOXjDo.js";import{a as i,i as a,n as o,r as s}from"./shared-D-va8joy.js";var c=r(),l=n();function u(t){let n=(0,c.c)(29),{investors:r,filters:u}=t,f=u.q??``,p;n[0]===f?p=n[1]:(p={q:f},n[0]=f,n[1]=p);let m=e(p),h;n[2]===m?h=n[3]:(h=e=>{e.preventDefault(),m.get(`/management/crm/investors`,{preserveState:!1})},n[2]=m,n[3]=h);let g;n[4]===m?g=n[5]:(g=e=>m.setData(`q`,e.target.value),n[4]=m,n[5]=g);let _;n[6]!==m.data.q||n[7]!==g?(_=(0,l.jsx)(`input`,{"aria-label":`Pesquisar investidores`,className:i,value:m.data.q,onChange:g}),n[6]=m.data.q,n[7]=g,n[8]=_):_=n[8];let v;n[9]===m.processing?v=n[10]:(v=(0,l.jsx)(`button`,{className:a,disabled:m.processing,children:`Pesquisar`}),n[9]=m.processing,n[10]=v);let y;n[11]!==h||n[12]!==_||n[13]!==v?(y=(0,l.jsxs)(`form`,{className:`flex gap-3`,onSubmit:h,children:[_,v]}),n[11]=h,n[12]=_,n[13]=v,n[14]=y):y=n[14];let b;n[15]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,l.jsx)(`p`,{children:`Os novos investidores são registados ao converter um pedido em lead, com revisão do contacto e da identidade.`}),n[15]=b):b=n[15];let x;n[16]===r.data?x=n[17]:(x=r.data.map(d),n[16]=r.data,n[17]=x);let S;n[18]===x?S=n[19]:(S=(0,l.jsx)(`div`,{className:`space-y-3`,children:x}),n[18]=x,n[19]=S);let C;n[20]===r.data.length?C=n[21]:(C=!r.data.length&&(0,l.jsx)(`p`,{children:`Nenhum investidor encontrado.`}),n[20]=r.data.length,n[21]=C);let w;n[22]===r?w=n[23]:(w=(0,l.jsx)(s,{page:r}),n[22]=r,n[23]=w);let T;return n[24]!==S||n[25]!==C||n[26]!==w||n[27]!==y?(T=(0,l.jsxs)(o,{title:`CRM — Investidores`,children:[y,b,S,C,w]}),n[24]=S,n[25]=C,n[26]=w,n[27]=y,n[28]=T):T=n[28],T}function d(e){return(0,l.jsxs)(`article`,{className:`rounded border p-4`,children:[(0,l.jsx)(t,{className:`font-semibold underline`,href:`/management/crm/investors/${e.id}`,children:e.legal_name}),(0,l.jsx)(`p`,{children:{prospect:`Potencial investidor`,active:`Activo`,inactive:`Inactivo`}[e.status]??e.status})]},e.id)}export{u as default};
|
||||
+1
File diff suppressed because one or more lines are too long
+1
@@ -0,0 +1 @@
|
||||
import{i as e}from"./rolldown-runtime-Dd_uD5pT.js";import{n as t,t as n}from"./jsx-runtime-BpzPEenQ.js";import{t as r}from"./compiler-runtime-sKsOXjDo.js";import{t as i}from"./dist-DDq_DSJX.js";import{t as a}from"./utils-CCDJ05Ll.js";var o=r(),s=e(t(),1),c=n(),l=Object.defineProperty,u=s.forwardRef(((e,t)=>l(e,`name`,{value:t,configurable:!0}))(function(e,t){return(0,c.jsx)(i.label,{...e,ref:t,onMouseDown:t=>{t.target.closest(`button, input, select, textarea`)||(e.onMouseDown?.(t),!t.defaultPrevented&&t.detail>1&&t.preventDefault())}})},`Label`));function d(e){let t=(0,o.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=a(`text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50`,n),t[3]=n,t[4]=i);let s;return t[5]!==r||t[6]!==i?(s=(0,c.jsx)(u,{"data-slot":`label`,className:i,...r}),t[5]=r,t[6]=i,t[7]=s):s=t[7],s}export{d as t};
|
||||
+1
@@ -0,0 +1 @@
|
||||
var e={assistant:[`Assistente com fontes`,`Evidence assistant`],search:[`Pesquisa documental`,`Document search`],recommend:[`Correspondência de oportunidades`,`Opportunity matching`],classify:[`Triagem de pedidos`,`Interest triage`],quality:[`Qualidade dos dados`,`Data quality`],sla:[`Prazos e tarefas`,`Deadlines and tasks`],summary:[`Excertos de documentos`,`Document excerpts`]},t={classify:`interest_triage`,quality:`data_quality`,sla:`execution_monitoring`},n={pending:`Pendente`,approved:`Autorizada para consulta interna`,revoked:`Revogada`,accepted:`Aceite na revisão interna`,rejected:`Rejeitado`,official:`Oficial — natureza declarada da fonte`,historical:`Histórica`,illustrative:`Ilustrativa`};export{t as n,n as r,e as t};
|
||||
BIN
Binary file not shown.
|
After Width: | Height: | Size: 1.2 KiB |
BIN
Binary file not shown.
|
After Width: | Height: | Size: 696 B |
+1
File diff suppressed because one or more lines are too long
+1
File diff suppressed because one or more lines are too long
+1
File diff suppressed because one or more lines are too long
+11
File diff suppressed because one or more lines are too long
+1
@@ -0,0 +1 @@
|
||||
import{t as e}from"./createLucideIcon-oMeAlXbs.js";var t=e(`LoaderCircle`,[[`path`,{d:`M21 12a9 9 0 1 1-6.219-8.56`,key:`13zald`}]]);export{t};
|
||||
+1
File diff suppressed because one or more lines are too long
+1
File diff suppressed because one or more lines are too long
+1
@@ -0,0 +1 @@
|
||||
import{r as e}from"./dist-BRfsww6z.js";import{t}from"./jsx-runtime-BpzPEenQ.js";import{t as n}from"./compiler-runtime-sKsOXjDo.js";var r=n(),i=t(),a={draft:`Rascunho`,support_requested:`Apoio solicitado`,internal_review:`Análise interna`,waiting_applicant:`A aguardar requerente`,referral_prepared:`Encaminhamento preparado (não enviado)`,closed:`Encerrado`};function o(t){let n=(0,r.c)(19),{cases:a}=t,o;n[0]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,i.jsxs)(`header`,{children:[(0,i.jsx)(`h1`,{className:`text-3xl font-bold`,children:`Gestão — Terra e DUAT`}),(0,i.jsx)(`p`,{children:`Fila interna. Não representa protocolo com autoridade pública.`})]}),n[0]=o):o=n[0];let c;n[1]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,i.jsx)(`thead`,{children:(0,i.jsxs)(`tr`,{children:[(0,i.jsx)(`th`,{className:`border p-2`,children:`Referência interna`}),(0,i.jsx)(`th`,{className:`border p-2`,children:`Requerente`}),(0,i.jsx)(`th`,{className:`border p-2`,children:`Estado InvestMoz`}),(0,i.jsx)(`th`,{className:`border p-2`,children:`Versão/actualização`}),(0,i.jsx)(`th`,{className:`border p-2`,children:`Acção`})]})}),n[1]=c):c=n[1];let l;n[2]===a.data?l=n[3]:(l=a.data.map(s),n[2]=a.data,n[3]=l);let u;n[4]===l?u=n[5]:(u=(0,i.jsx)(`div`,{className:`overflow-x-auto`,children:(0,i.jsxs)(`table`,{className:`w-full border-collapse text-left`,children:[c,(0,i.jsx)(`tbody`,{children:l})]})}),n[4]=l,n[5]=u);let d;n[6]===a.data.length?d=n[7]:(d=!a.data.length&&(0,i.jsx)(`p`,{children:`Sem pedidos registados.`}),n[6]=a.data.length,n[7]=d);let f;n[8]===a.prev_page_url?f=n[9]:(f=a.prev_page_url&&(0,i.jsx)(e,{href:a.prev_page_url,children:`Anterior`}),n[8]=a.prev_page_url,n[9]=f);let p;n[10]===a.next_page_url?p=n[11]:(p=a.next_page_url&&(0,i.jsx)(e,{href:a.next_page_url,children:`Seguinte`}),n[10]=a.next_page_url,n[11]=p);let m;n[12]!==f||n[13]!==p?(m=(0,i.jsxs)(`nav`,{className:`flex gap-4`,children:[f,p]}),n[12]=f,n[13]=p,n[14]=m):m=n[14];let h;return n[15]!==u||n[16]!==d||n[17]!==m?(h=(0,i.jsxs)(`main`,{className:`mx-auto max-w-6xl space-y-6 p-6`,children:[o,u,d,m]}),n[15]=u,n[16]=d,n[17]=m,n[18]=h):h=n[18],h}function s(t){return(0,i.jsxs)(`tr`,{children:[(0,i.jsx)(`td`,{className:`border p-2`,children:t.reference}),(0,i.jsx)(`td`,{className:`border p-2`,children:t.applicant??`—`}),(0,i.jsx)(`td`,{className:`border p-2`,children:a[t.status]??t.status}),(0,i.jsxs)(`td`,{className:`border p-2`,children:[t.version,` ·`,` `,new Date(t.updated_at).toLocaleString(`pt-MZ`)]}),(0,i.jsx)(`td`,{className:`border p-2`,children:(0,i.jsx)(e,{className:`underline`,href:`/management/terra-duat/${t.id}`,children:`Abrir`})})]},t.id)}export{o as default};
|
||||
+1
@@ -0,0 +1 @@
|
||||
import{c as e,n as t,r as n}from"./dist-BRfsww6z.js";import{t as r}from"./jsx-runtime-BpzPEenQ.js";import{t as i}from"./compiler-runtime-sKsOXjDo.js";var a=i(),o=r();function s(r){let i=(0,a.c)(16),{registrationEnabled:s}=r,{auth:c}=e().props,l=c.user,u;i[0]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,o.jsx)(t,{title:`Acesso à gestão`}),i[0]=u):u=i[0];let d,f,p;i[1]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,o.jsx)(n,{href:`/`,className:`text-emerald-700 underline`,children:`Voltar ao portal`}),f=(0,o.jsx)(`h1`,{className:`text-3xl font-semibold`,children:`Acesso à gestão do portal`}),p=(0,o.jsx)(`p`,{children:`Pode configurar a sua conta quando estiver pronto. A consulta de oportunidades e o envio de manifestações de interesse continuam disponíveis no portal público.`}),i[1]=d,i[2]=f,i[3]=p):(d=i[1],f=i[2],p=i[3]);let m=l?c.canManagePortal?`Acesso disponível`:l.email_verified_at?`Autorização pendente`:`Verificar o seu email`:`Preparar a sua conta`,h;i[4]===m?h=i[5]:(h=(0,o.jsx)(`h2`,{className:`text-xl font-semibold`,children:m}),i[4]=m,i[5]=h);let g;i[6]!==c.canManagePortal||i[7]!==s||i[8]!==l?(g=l?c.canManagePortal?(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(`p`,{children:`A sua conta tem acesso à gestão de pedidos, sectores e oportunidades.`}),(0,o.jsx)(n,{className:`inline-flex rounded-lg bg-slate-900 px-5 py-3 font-medium text-white`,href:`/management/interests`,children:`Abrir gestão`})]}):l.email_verified_at?(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(`p`,{children:`A sua conta está verificada, mas ainda não tem autorização de gestão. Contacte o responsável pelo portal para confirmar o acesso.`}),(0,o.jsx)(n,{className:`inline-flex rounded-lg bg-slate-900 px-5 py-3 font-medium text-white`,href:`/settings/profile`,children:`Consultar a minha conta`})]}):(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(`p`,{children:`Confirme o endereço de email da sua conta. A confirmação do email não atribui permissões de gestão automaticamente.`}),(0,o.jsx)(n,{className:`inline-flex rounded-lg bg-slate-900 px-5 py-3 font-medium text-white`,href:`/email/verify`,children:`Verificar email`})]}):(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(`p`,{children:`Use o email autorizado pela equipa do portal. Depois de criar a conta, confirme o email através da ligação de verificação.`}),(0,o.jsxs)(`div`,{className:`flex flex-wrap gap-3`,children:[(0,o.jsx)(n,{className:`inline-flex rounded-lg bg-slate-900 px-5 py-3 font-medium text-white`,href:`/login`,children:`Entrar`}),s&&(0,o.jsx)(n,{className:`inline-flex rounded-lg bg-slate-900 px-5 py-3 font-medium text-white`,href:`/register`,children:`Criar conta`})]})]}),i[6]=c.canManagePortal,i[7]=s,i[8]=l,i[9]=g):g=i[9];let _;i[10]!==h||i[11]!==g?(_=(0,o.jsxs)(`section`,{className:`space-y-4 rounded-xl border bg-white p-6`,children:[h,g]}),i[10]=h,i[11]=g,i[12]=_):_=i[12];let v;i[13]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,o.jsx)(`p`,{children:(0,o.jsx)(n,{href:`/`,className:`text-emerald-700 underline`,children:`Configurar mais tarde e voltar ao portal`})}),i[13]=v):v=i[13];let y;return i[14]===_?y=i[15]:(y=(0,o.jsxs)(`main`,{className:`min-h-screen bg-slate-50 px-5 py-12 text-slate-900`,children:[u,(0,o.jsxs)(`div`,{className:`mx-auto max-w-2xl space-y-6`,children:[d,f,p,_,v]})]}),i[14]=_,i[15]=y),y}export{s as default};
|
||||
BIN
Binary file not shown.
|
After Width: | Height: | Size: 1.4 KiB |
+1
@@ -0,0 +1 @@
|
||||
import{r as e,u as t}from"./dist-BRfsww6z.js";import{t as n}from"./jsx-runtime-BpzPEenQ.js";import{t as r}from"./compiler-runtime-sKsOXjDo.js";import{a as i,n as a}from"./shared-DDFDWkxk.js";var o=r(),s=n();function c(n){let r=(0,o.c)(21),{unread:c,notifications:l}=n,u;r[0]===Symbol.for(`react.memo_cache_sentinel`)?(u={received:`Recebido`,in_review:`Em análise`,contacted:`Contactado`,closed:`Encerrado`},r[0]=u):u=r[0];let d=u,f;r[1]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,s.jsx)(e,{href:`/investidor/manifestacoes`,className:`underline`,children:`Área do investidor`}),r[1]=f):f=r[1];let p;r[2]===c?p=r[3]:(p=(0,s.jsxs)(`p`,{role:`status`,children:[c,` notificações por ler`]}),r[2]=c,r[3]=p);let m;if(r[4]!==l.data){let n;r[6]===Symbol.for(`react.memo_cache_sentinel`)?(n=n=>(0,s.jsxs)(`article`,{className:i+` space-y-3`,children:[(0,s.jsx)(`h2`,{className:`text-xl font-bold`,children:n.kind===`received`?`Manifestação recebida`:n.kind===`status`?`Estado actualizado`:`Nova mensagem na conversa`}),(0,s.jsx)(`p`,{children:n.payload.reference??(n.payload.status?d[n.payload.status]??n.payload.status:`Consulte o pedido para ler a mensagem.`)}),(0,s.jsx)(`p`,{className:`text-sm`,children:new Date(n.created_at).toLocaleString(`pt-MZ`)}),(0,s.jsxs)(`div`,{className:`flex flex-wrap gap-4`,children:[(0,s.jsx)(e,{href:`/investidor/manifestacoes/`+n.submission_id,className:`underline`,children:`Abrir manifestação`}),!n.read_at&&(0,s.jsx)(`button`,{className:`inline-flex items-center justify-center rounded-lg bg-emerald-800 px-4 py-2 font-semibold text-white disabled:opacity-50 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-emerald-700`,onClick:()=>t.post(`/investidor/notifications/`+n.id+`/read`,{},{preserveScroll:!0}),children:`Marcar como lida`})]})]},n.id),r[6]=n):n=r[6],m=l.data.map(n),r[4]=l.data,r[5]=m}else m=r[5];let h;r[7]===l.data.length?h=r[8]:(h=!l.data.length&&(0,s.jsx)(`p`,{children:`Ainda não existem notificações.`}),r[7]=l.data.length,r[8]=h);let g;r[9]===l.prev_page_url?g=r[10]:(g=l.prev_page_url&&(0,s.jsx)(e,{href:l.prev_page_url,children:`Anterior`}),r[9]=l.prev_page_url,r[10]=g);let _;r[11]===l.next_page_url?_=r[12]:(_=l.next_page_url&&(0,s.jsx)(e,{href:l.next_page_url,children:`Seguinte`}),r[11]=l.next_page_url,r[12]=_);let v;r[13]!==g||r[14]!==_?(v=(0,s.jsxs)(`nav`,{"aria-label":`Paginação`,className:`flex gap-4`,children:[g,_]}),r[13]=g,r[14]=_,r[15]=v):v=r[15];let y;return r[16]!==p||r[17]!==m||r[18]!==h||r[19]!==v?(y=(0,s.jsxs)(a,{title:`Notificações e acompanhamento`,children:[f,p,m,h,v]}),r[16]=p,r[17]=m,r[18]=h,r[19]=v,r[20]=y):y=r[20],y}export{c as default};
|
||||
+1
@@ -0,0 +1 @@
|
||||
function e(){let e=globalThis.crypto;if(typeof e?.randomUUID==`function`)return e.randomUUID();if(typeof e?.getRandomValues!=`function`)throw Error(`O navegador não disponibiliza geração criptográfica segura. Reabra o portal no endereço HTTPS configurado.`);let t=e.getRandomValues(new Uint8Array(16));t[6]=t[6]&15|64,t[8]=t[8]&63|128;let n=Array.from(t,e=>e.toString(16).padStart(2,`0`)).join(``);return`${n.slice(0,8)}-${n.slice(8,12)}-${n.slice(12,16)}-${n.slice(16,20)}-${n.slice(20)}`}export{e as t};
|
||||
+1
@@ -0,0 +1 @@
|
||||
import{o as e,r as t}from"./dist-BRfsww6z.js";import{t as n}from"./jsx-runtime-BpzPEenQ.js";import{a as r,i,n as a,r as o,s}from"./shared-D-va8joy.js";var c=n();function l({records:n,filters:l,counts:u,categories:d,sectors:f,geographyReviewCount:p,basePath:m=`/management/opportunities`,canCreate:h=!0}){let g=e({q:l.q??``,queue:l.queue??``,status:l.status??``,category:l.category??``,deleted:!!l.deleted,sector_id:String(l.sector_id??``),geography_scope:l.geography_scope??``});return(0,c.jsxs)(a,{title:m===`/minhas-oportunidades`?`Minhas oportunidades`:`Gestão de Oportunidades`,children:[h&&(0,c.jsx)(t,{className:`inline-flex items-center rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground disabled:opacity-50`,href:`${m}/create`,children:`Nova oportunidade`}),(0,c.jsxs)(`p`,{children:[p,` registos com âmbito por indicar; referências existentes permanecem aceites.`]}),(0,c.jsx)(`section`,{"aria-label":`Indicadores autorizados`,className:`grid gap-3 sm:grid-cols-3`,children:[`draft`,`submitted`,`needs_information`,`in_review`,`information_pending`,`returned`,`approved`,`published`,`suspended`,`rejected`,`archived`].map(e=>(0,c.jsxs)(t,{className:`rounded border p-3`,href:`${m}?status=${e}`,children:[s[e]??e,`: `,u[e]??0]},e))}),(0,c.jsxs)(`form`,{className:`flex flex-wrap gap-3`,onSubmit:e=>{e.preventDefault(),g.transform(e=>({...e,deleted:e.deleted?`1`:`0`})),g.get(m)},children:[m===`/minhas-oportunidades`&&(0,c.jsxs)(`label`,{children:[`Fila`,(0,c.jsxs)(`select`,{className:`w-full rounded-md border border-input bg-background p-2 text-foreground`,value:g.data.queue,onChange:e=>g.setData(`queue`,e.target.value),children:[(0,c.jsx)(`option`,{value:``,children:`Todas as autorizadas`}),(0,c.jsx)(`option`,{value:`assigned`,children:`Atribuídas a mim`}),(0,c.jsx)(`option`,{value:`review`,children:`Validação e pareceres`}),(0,c.jsx)(`option`,{value:`publication`,children:`Preparação editorial`}),(0,c.jsx)(`option`,{value:`appeal`,children:`Recursos pendentes`})]})]}),(0,c.jsx)(`input`,{"aria-label":`Pesquisa global`,placeholder:`Título ou referência`,className:r,value:g.data.q,onChange:e=>g.setData(`q`,e.target.value)}),(0,c.jsxs)(`select`,{"aria-label":`Estado`,className:r,value:g.data.status,onChange:e=>g.setData(`status`,e.target.value),children:[(0,c.jsx)(`option`,{value:``,children:`Todos os estados`}),Object.keys(u).map(e=>(0,c.jsx)(`option`,{value:e,children:s[e]??e},e))]}),(0,c.jsxs)(`select`,{"aria-label":`Categoria`,className:r,value:g.data.category,onChange:e=>g.setData(`category`,e.target.value),children:[(0,c.jsx)(`option`,{value:``,children:`Todas as categorias`}),d.map(e=>(0,c.jsx)(`option`,{children:e},e))]}),(0,c.jsxs)(`label`,{children:[(0,c.jsx)(`input`,{type:`checkbox`,checked:g.data.deleted,onChange:e=>g.setData(`deleted`,e.target.checked)}),` `,`Rascunhos eliminados logicamente`]}),(0,c.jsxs)(`select`,{"aria-label":`Sector`,className:r,value:g.data.sector_id,onChange:e=>g.setData(`sector_id`,e.target.value),children:[(0,c.jsx)(`option`,{value:``,children:`Todos os sectores`}),f.map(e=>(0,c.jsx)(`option`,{value:e.id,children:e.name},e.id))]}),(0,c.jsxs)(`select`,{"aria-label":`Âmbito geográfico`,className:r,value:g.data.geography_scope,onChange:e=>g.setData(`geography_scope`,e.target.value),children:[(0,c.jsx)(`option`,{value:``,children:`Todos os âmbitos`}),[`unspecified`,`specific`,`multiple`,`national`,`digital`].map(e=>(0,c.jsx)(`option`,{children:e},e))]}),(0,c.jsx)(`button`,{className:i,disabled:g.processing,children:`Pesquisar`})]}),(0,c.jsx)(`div`,{className:`space-y-3`,children:n.data.map(e=>(0,c.jsxs)(`article`,{className:`rounded border p-4`,children:[(0,c.jsx)(`h2`,{className:`font-semibold`,children:e.draft_title??e.title??`Rascunho sem título`}),(0,c.jsxs)(`p`,{children:[`ID `,e.id,` · `,e.reference,` ·`,` `,e.opportunity_category??`Categoria por indicar`,` `,`·`,` `,e.deleted_at?`Eliminado logicamente`:(e.working_status??e.status)===`published`?`Versão disponibilizada`:s[e.working_status??e.status]??e.working_status??e.status]}),e.publication&&(0,c.jsx)(`p`,{children:e.publication.label}),(0,c.jsxs)(`p`,{children:[`Atualizado: `,e.updated_at]}),(0,c.jsxs)(`div`,{className:`flex flex-wrap gap-4`,children:[(0,c.jsx)(t,{href:`${m}/${e.id}/view`,children:`Ver`}),e.can_edit!==!1&&(0,c.jsx)(t,{href:`${m}/${e.id}/edit`,children:e.deleted_at||e.status===`archived`?`Restaurar`:e.status===`draft`?`Continuar preenchimento`:`Editar nova versão`})]})]},e.id))}),!n.data.length&&(0,c.jsx)(`p`,{children:`Nenhum registo encontrado.`}),(0,c.jsx)(o,{page:n})]})}export{l as default};
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user