Admin panel updated with shadcn-vue components

This commit is contained in:
Simon Pocrnjič
2026-01-05 18:27:35 +01:00
parent 70a5d015e0
commit c4d9ecb39e
37 changed files with 5407 additions and 3740 deletions
@@ -25,7 +25,7 @@ public function index(Request $request): Response
{
$packages = Package::query()
->latest('id')
->paginate(20);
->paginate(25);
// Minimal lookups for create form (active only)
$profiles = \App\Models\SmsProfile::query()
->where('active', true)
Binary file not shown.
@@ -657,6 +657,7 @@ public function applyToImport(Request $request, ImportTemplate $template, Import
$import->update([
'import_template_id' => $template->id,
'reactivate' => $template->reactivate,
'meta' => $merged,
]);
});
+1
View File
@@ -29,6 +29,7 @@ class Contract extends Model
'end_date',
'client_case_id',
'type_id',
'active',
'description',
'meta',
];
@@ -46,76 +46,35 @@ public function resolve(array $mapped, array $context = []): mixed
public function process(Import $import, array $mapped, array $raw, array $context = []): array
{
// PHASE 4: Check for existing Contract early to prevent duplicate creation
$reference = $mapped['reference'] ?? null;
if ($reference) {
$existingContract = $this->resolutionService->getExistingContract(
$import->client_id,
$reference
);
if ($existingContract) {
Log::info('ContractHandler: Found existing Contract by reference', [
'contract_id' => $existingContract->id,
'reference' => $reference,
]);
$mode = $this->getOption('update_mode', 'update');
if ($mode === 'skip') {
return [
'action' => 'skipped',
'entity' => $existingContract,
'message' => 'Contract already exists (skip mode)',
];
}
// Update existing contract
$payload = $this->buildPayload($mapped, $existingContract);
$payload = $this->mergeJsonFields($payload, $existingContract);
$appliedFields = $this->trackAppliedFields($existingContract, $payload);
if (empty($appliedFields)) {
return [
'action' => 'skipped',
'entity' => $existingContract,
'message' => 'No changes detected',
];
}
$existingContract->fill($payload);
$existingContract->save();
return [
'action' => 'updated',
'entity' => $existingContract,
'applied_fields' => $appliedFields,
];
}
}
// Check for existing contract (using resolve method which handles client scoping)
$existing = $this->resolve($mapped, $context);
// Check for reactivation request
$reactivate = $this->shouldReactivate($context);
// Handle reactivation if entity is soft-deleted or inactive
if ($existing && $reactivate && $this->needsReactivation($existing)) {
$reactivated = $this->attemptReactivation($existing, $context);
if ($reactivated) {
return [
'action' => 'reactivated',
'entity' => $existing,
'message' => 'Contract reactivated',
];
}
}
// Determine if we should update or skip based on mode
$mode = $this->getOption('update_mode', 'update');
if ($existing) {
// Check for reactivation FIRST (before update_mode check)
$reactivate = $this->shouldReactivate($context);
Log::info('ContractHandler: Found existing Contract', [
'contract_id' => $existing->id,
'reference' => $mapped['reference'] ?? null,
'context' => $context['import']
]);
if ($reactivate && $this->needsReactivation($existing)) {
$reactivated = $this->attemptReactivation($existing, $context);
Log::info('ContractHandler: Reactivate', ['reactivated' => $reactivated]);
if ($reactivated) {
return [
'action' => 'reactivated',
'entity' => $existing,
'message' => 'Contract reactivated',
];
}
}
// Check update mode
$mode = $this->getOption('update_mode', 'update');
if ($mode === 'skip') {
return [
'action' => 'skipped',
@@ -124,12 +83,9 @@ public function process(Import $import, array $mapped, array $raw, array $contex
];
}
// Update
// Update existing contract
$payload = $this->buildPayload($mapped, $existing);
// Merge JSON fields instead of overwriting
$payload = $this->mergeJsonFields($payload, $existing);
$appliedFields = $this->trackAppliedFields($existing, $payload);
if (empty($appliedFields)) {
@@ -200,7 +156,6 @@ protected function buildPayload(array $mapped, $model): array
// Map fields according to contract schema
$fieldMap = [
'reference' => 'reference',
'title' => 'title',
'description' => 'description',
'amount' => 'amount',
'currency' => 'currency',
@@ -286,7 +241,9 @@ protected function attemptReactivation(Contract $contract, array $context): bool
$contract->restore();
}
$contract->update(['active' => 1]);
$contract->active = 1;
$contract->save();
return true;
} catch (\Throwable $e) {
-2
View File
@@ -100,8 +100,6 @@ public function process(Import $import, ?Authenticatable $user = null): array
$rowNum++;
}
$isPg = DB::connection()->getDriverName() === 'pgsql';
// If retry mode, only process failed/invalid rows
if ($isRetry) {
$failedRows = ImportRow::where('import_id', $import->id)